From 2dd9c037f9190a09312aae9e6525082b938f924d Mon Sep 17 00:00:00 2001 From: Morgan Thomas Date: Sun, 21 Apr 2024 12:50:28 -0400 Subject: [PATCH 1/3] issue/155: wip: generate public inputs --- basic/src/lib.rs | 81 ++++++++++++++++++++++++++---------------- basic_macro/src/lib.rs | 2 +- derive/src/lib.rs | 10 ++++-- machine/src/chip.rs | 6 +++- 4 files changed, 64 insertions(+), 35 deletions(-) diff --git a/basic/src/lib.rs b/basic/src/lib.rs index 29aef541..76dc22e8 100644 --- a/basic/src/lib.rs +++ b/basic/src/lib.rs @@ -50,8 +50,8 @@ use valida_machine::__internal::{ }; use valida_machine::{ generate_permutation_trace, verify_constraints, AdviceProvider, BusArgument, Chip, ChipProof, - Commitments, Instruction, Machine, MachineProof, OpenedValues, ProgramROM, StoppingFlag, - ValidaAirBuilder, + ColumnIndex, ColumnVector, Commitments, Instruction, Machine, MachineProof, OpenedValues, + ProgramROM, StoppingFlag, ValidaAirBuilder, }; use valida_memory::{MachineWithMemoryChip, MemoryChip}; use valida_output::{MachineWithOutputChip, OutputChip, WriteInstruction}; @@ -263,6 +263,7 @@ impl Machine for BasicMachine { let alpha: SC::Challenge = challenger.sample_ext_element(); let mut quotients: Vec> = vec![]; + let mut public_inputs: Vec)>> = vec![]; let mut i: usize = 0; @@ -287,6 +288,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.program(); @@ -310,6 +312,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; let chip = self.mem(); @@ -333,6 +336,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.add_u32(); @@ -356,6 +360,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.sub_u32(); @@ -379,6 +384,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.mul_u32(); @@ -402,6 +408,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.div_u32(); @@ -425,6 +432,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.shift_u32(); @@ -448,6 +456,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.lt_u32(); @@ -471,6 +480,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.com_u32(); @@ -494,6 +504,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.bitwise_u32(); @@ -517,6 +528,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.output(); @@ -540,6 +552,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; let chip = self.range(); @@ -563,6 +576,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(vec![]); i += 1; let chip = self.static_data(); @@ -586,6 +600,7 @@ impl Machine for BasicMachine { &perm_challenges, alpha, )); + public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; assert_eq!(quotients.len(), NUM_CHIPS); @@ -636,35 +651,39 @@ impl Machine for BasicMachine { .zip(perm_openings) .zip(quotient_openings) .zip(perm_traces) - .map(|((((log_degree, main), perm), quotient), perm_trace)| { - // TODO: add preprocessed openings - let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; - - let [main_local, main_next] = main.try_into().expect("Should have 2 openings"); - let [perm_local, perm_next] = perm.try_into().expect("Should have 2 openings"); - let [quotient_chunks] = quotient.try_into().expect("Should have 1 opening"); - - let opened_values = OpenedValues { - preprocessed_local, - preprocessed_next, - trace_local: main_local, - trace_next: main_next, - permutation_local: perm_local, - permutation_next: perm_next, - quotient_chunks, - }; - - let cumulative_sum = perm_trace - .row_slice(perm_trace.height() - 1) - .last() - .unwrap() - .clone(); - ChipProof { - log_degree: *log_degree, - opened_values, - cumulative_sum, - } - }) + .zip(public_inputs) + .map( + |(((((log_degree, main), perm), quotient), perm_trace), public_inputs)| { + // TODO: add preprocessed openings + let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; + + let [main_local, main_next] = main.try_into().expect("Should have 2 openings"); + let [perm_local, perm_next] = perm.try_into().expect("Should have 2 openings"); + let [quotient_chunks] = quotient.try_into().expect("Should have 1 opening"); + + let opened_values = OpenedValues { + preprocessed_local, + preprocessed_next, + trace_local: main_local, + trace_next: main_next, + permutation_local: perm_local, + permutation_next: perm_next, + quotient_chunks, + }; + + let cumulative_sum = perm_trace + .row_slice(perm_trace.height() - 1) + .last() + .unwrap() + .clone(); + ChipProof { + public_inputs, + log_degree: *log_degree, + opened_values, + cumulative_sum, + } + }, + ) .collect::>(); MachineProof { diff --git a/basic_macro/src/lib.rs b/basic_macro/src/lib.rs index 8d2b44ed..51c85f19 100644 --- a/basic_macro/src/lib.rs +++ b/basic_macro/src/lib.rs @@ -40,7 +40,7 @@ use valida_cpu::{CpuChip, MachineWithCpuChip}; use valida_derive::Machine; use valida_machine::{ AdviceProvider, BusArgument, Chip, ChipProof, Instruction, Machine, MachineProof, ProgramROM, - StoppingFlag, ValidaAirBuilder, + StoppingFlag, ValidaAirBuilder, ColumnVector, ColumnIndex, }; use valida_memory::{MachineWithMemoryChip, MemoryChip}; use valida_output::{MachineWithOutputChip, OutputChip, WriteInstruction}; diff --git a/derive/src/lib.rs b/derive/src/lib.rs index 34ec4f8e..646883e4 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -268,6 +268,9 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { &perm_challenges, alpha, )); + public_inputs.push(Chip::generate_public_inputs( + self.#chip_name() as &dyn Chip, + )); } }) .collect::(); @@ -283,7 +286,7 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { use ::valida_machine::__internal::p3_commit::{Pcs, UnivariatePcs, UnivariatePcsWithLde}; use ::valida_machine::__internal::p3_matrix::{Matrix, MatrixRowSlices, dense::RowMajorMatrix}; use ::valida_machine::__internal::p3_util::log2_strict_usize; - use ::valida_machine::{generate_permutation_trace, MachineProof, ChipProof, Commitments}; + use ::valida_machine::{generate_permutation_trace, Chip, MachineProof, ChipProof, Commitments}; use ::valida_machine::OpenedValues; use alloc::vec; use alloc::vec::Vec; @@ -360,6 +363,7 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { let alpha: SC::Challenge = challenger.sample_ext_element(); let mut quotients: Vec> = vec![]; + let mut public_inputs: Vec)>> = vec![]; #compute_quotients assert_eq!(quotients.len(), #num_chips); assert_eq!(log_quotient_degrees.len(), #num_chips); @@ -409,7 +413,8 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { .zip(perm_openings) .zip(quotient_openings) .zip(perm_traces) - .map(|((((log_degree, main), perm), quotient), perm_trace)| { + .zip(public_inputs) + .map(|(((((log_degree, main), perm), quotient), perm_trace), public_inputs)| { // TODO: add preprocessed openings let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; @@ -430,6 +435,7 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { let cumulative_sum = perm_trace.row_slice(perm_trace.height() - 1).last().unwrap().clone(); ChipProof { + public_inputs, log_degree: *log_degree, opened_values, cumulative_sum, diff --git a/machine/src/chip.rs b/machine/src/chip.rs index afd6e096..691d0fac 100644 --- a/machine/src/chip.rs +++ b/machine/src/chip.rs @@ -1,5 +1,5 @@ use crate::folding_builder::VerifierConstraintFolder; -use crate::Machine; +use crate::{Machine, ColumnVector, ColumnIndex}; use crate::__internal::{DebugConstraintBuilder, ProverConstraintFolder}; use alloc::vec; use alloc::vec::Vec; @@ -21,6 +21,10 @@ pub trait Chip, SC: StarkConfig>: /// Generate the main trace for the chip given the provided machine. fn generate_trace(&self, machine: &M) -> RowMajorMatrix; + fn generate_public_inputs(&self) -> Vec<(ColumnIndex, ColumnVector)> { + vec![] + } + fn local_sends(&self) -> Vec> { vec![] } From 62d30b1fa8c9d08e97bfb9968ae8ba8f987e7430 Mon Sep 17 00:00:00 2001 From: Dan Dore Date: Mon, 3 Jun 2024 14:23:48 -0700 Subject: [PATCH 2/3] adds Public type to Chips --- Cargo.lock | 224 +++++++++----------- Cargo.toml | 37 ++-- alu_u32/src/add/mod.rs | 6 +- alu_u32/src/bitwise/mod.rs | 6 +- alu_u32/src/com/mod.rs | 7 +- alu_u32/src/div/mod.rs | 3 + alu_u32/src/lt/mod.rs | 5 +- alu_u32/src/mul/mod.rs | 7 +- alu_u32/src/shift/mod.rs | 7 +- alu_u32/src/sub/mod.rs | 6 +- basic/src/lib.rs | 213 +++++++++++++------ basic_macro/src/lib.rs | 2 +- cpu/src/lib.rs | 5 +- machine/Cargo.toml | 6 +- machine/src/check_constraints.rs | 17 ++ machine/src/chip.rs | 31 ++- machine/src/debug_builder.rs | 16 +- machine/src/folding_builder.rs | 27 ++- machine/src/lib.rs | 2 + machine/src/public.rs | 181 ++++++++++++++++ machine/src/quotient.rs | 34 ++- machine/src/symbolic/symbolic_builder.rs | 13 +- machine/src/symbolic/symbolic_expression.rs | 2 +- machine/src/symbolic/symbolic_variable.rs | 10 + machine/src/verify.rs | 15 ++ memory/src/lib.rs | 5 +- native_field/src/lib.rs | 6 +- output/src/lib.rs | 10 +- program/src/lib.rs | 8 +- range/src/lib.rs | 6 +- static_data/src/lib.rs | 9 +- 31 files changed, 677 insertions(+), 249 deletions(-) create mode 100644 machine/src/public.rs diff --git a/Cargo.lock b/Cargo.lock index 05170ae6..df357ba7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,47 +34,48 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -82,9 +83,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" @@ -124,9 +125,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.96" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -205,7 +206,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -216,9 +217,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "core-foundation-sys" @@ -286,9 +287,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -323,9 +324,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -381,9 +382,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elf" @@ -399,9 +400,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -430,9 +431,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -517,6 +518,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -552,15 +559,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -607,9 +614,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -650,7 +657,7 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "p3-air" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-matrix", @@ -659,7 +666,7 @@ dependencies = [ [[package]] name = "p3-baby-bear" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "rand", @@ -669,7 +676,7 @@ dependencies = [ [[package]] name = "p3-challenger" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-maybe-rayon", @@ -680,7 +687,7 @@ dependencies = [ [[package]] name = "p3-commit" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-challenger", "p3-field", @@ -691,7 +698,7 @@ dependencies = [ [[package]] name = "p3-dft" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-matrix", @@ -702,7 +709,7 @@ dependencies = [ [[package]] name = "p3-field" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "itertools 0.12.1", "p3-util", @@ -713,7 +720,7 @@ dependencies = [ [[package]] name = "p3-fri" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -731,7 +738,7 @@ dependencies = [ [[package]] name = "p3-goldilocks" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-util", @@ -742,7 +749,7 @@ dependencies = [ [[package]] name = "p3-interpolation" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-matrix", @@ -753,7 +760,7 @@ dependencies = [ [[package]] name = "p3-keccak" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-symmetric", "tiny-keccak", @@ -762,7 +769,7 @@ dependencies = [ [[package]] name = "p3-matrix" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-maybe-rayon", @@ -773,7 +780,7 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "rayon", ] @@ -781,7 +788,7 @@ dependencies = [ [[package]] name = "p3-mds" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-baby-bear", "p3-dft", @@ -797,7 +804,7 @@ dependencies = [ [[package]] name = "p3-merkle-tree" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "itertools 0.12.1", "p3-commit", @@ -813,7 +820,7 @@ dependencies = [ [[package]] name = "p3-mersenne-31" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "criterion", "itertools 0.12.1", @@ -829,7 +836,7 @@ dependencies = [ [[package]] name = "p3-poseidon" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "p3-field", "p3-mds", @@ -840,7 +847,7 @@ dependencies = [ [[package]] name = "p3-symmetric" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "itertools 0.12.1", "p3-field", @@ -849,7 +856,7 @@ dependencies = [ [[package]] name = "p3-uni-stark" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "itertools 0.12.1", "p3-air", @@ -867,16 +874,16 @@ dependencies = [ [[package]] name = "p3-util" version = "0.1.0" -source = "git+https://github.com/valida-xyz/Plonky3.git?branch=valida-main#bdd338d61b3c1f24f17abd3b2848f1c910c49428" +source = "git+https://github.com/valida-xyz/Plonky3.git?branch=dorebell-public#32eeeae9efaa5583aa6adfa89aca8679686709ee" dependencies = [ "serde", ] [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -926,7 +933,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -948,9 +955,9 @@ checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -961,15 +968,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -992,9 +999,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -1165,15 +1172,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1192,29 +1199,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -1299,7 +1306,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1315,9 +1322,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -1326,22 +1333,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1365,9 +1372,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" @@ -1399,7 +1406,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1525,48 +1532,6 @@ dependencies = [ "valida-static-data", ] -[[package]] -name = "valida-basic-macro" -version = "0.1.0" -dependencies = [ - "byteorder", - "ciborium", - "clap", - "p3-air", - "p3-baby-bear", - "p3-challenger", - "p3-commit", - "p3-dft", - "p3-field", - "p3-fri", - "p3-goldilocks", - "p3-keccak", - "p3-matrix", - "p3-maybe-rayon", - "p3-mds", - "p3-merkle-tree", - "p3-poseidon", - "p3-symmetric", - "p3-uni-stark", - "p3-util", - "rand", - "rand_pcg", - "rand_seeder", - "tracing", - "valida-alu-u32", - "valida-assembler", - "valida-bus", - "valida-cpu", - "valida-derive", - "valida-machine", - "valida-memory", - "valida-opcodes", - "valida-output", - "valida-program", - "valida-range", - "valida-static-data", -] - [[package]] name = "valida-bus" version = "0.1.0" @@ -1626,6 +1591,7 @@ dependencies = [ "p3-commit", "p3-dft", "p3-field", + "p3-interpolation", "p3-matrix", "p3-maybe-rayon", "p3-uni-stark", @@ -1821,7 +1787,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -1843,7 +1809,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index ff8210b0..2b418276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "assembler", "alu_u32", "basic", - "basic_macro", + #"basic_macro", "bus", "cpu", "derive", @@ -22,20 +22,21 @@ members = [ ] [workspace.dependencies] -p3-air = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-baby-bear = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-commit = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-challenger = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-dft = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-field = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-fri = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-goldilocks = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-keccak = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-matrix = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-maybe-rayon = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-mds = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-merkle-tree = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-poseidon = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-symmetric = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-uni-stark = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } -p3-util = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "valida-main" } +p3-air = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-baby-bear = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-commit = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-challenger = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-dft = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-field = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-fri = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-goldilocks = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-interpolation = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-keccak = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-matrix = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-maybe-rayon = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-mds = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-merkle-tree = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-poseidon = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-symmetric = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-uni-stark = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } +p3-util = { git = "https://github.com/valida-xyz/Plonky3.git", branch = "dorebell-public" } diff --git a/alu_u32/src/add/mod.rs b/alu_u32/src/add/mod.rs index 1c8b7ba1..916cd0c1 100644 --- a/alu_u32/src/add/mod.rs +++ b/alu_u32/src/add/mod.rs @@ -6,7 +6,9 @@ use columns::{Add32Cols, ADD_COL_MAP, NUM_ADD_COLS}; use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, +}; use valida_opcodes::ADD32; use valida_range::MachineWithRangeChip; @@ -35,6 +37,8 @@ where M: MachineWithGeneralBus + MachineWithRangeBus8, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/bitwise/mod.rs b/alu_u32/src/bitwise/mod.rs index 9d98aef9..4b8b2df1 100644 --- a/alu_u32/src/bitwise/mod.rs +++ b/alu_u32/src/bitwise/mod.rs @@ -6,7 +6,9 @@ use columns::{Bitwise32Cols, COL_MAP, NUM_BITWISE_COLS}; use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, +}; use valida_opcodes::{AND32, OR32, XOR32}; use p3_air::VirtualPairCol; @@ -36,6 +38,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/com/mod.rs b/alu_u32/src/com/mod.rs index e05e98da..d2fcdd60 100644 --- a/alu_u32/src/com/mod.rs +++ b/alu_u32/src/com/mod.rs @@ -7,10 +7,11 @@ use core::iter; use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; -use valida_machine::StarkConfig; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, Word, MEMORY_CELL_BYTES, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, + MEMORY_CELL_BYTES, }; +use valida_machine::{PublicRow, StarkConfig}; use valida_opcodes::{EQ32, NE32}; use p3_air::VirtualPairCol; @@ -38,6 +39,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/div/mod.rs b/alu_u32/src/div/mod.rs index 9e18df46..16ff8138 100644 --- a/alu_u32/src/div/mod.rs +++ b/alu_u32/src/div/mod.rs @@ -8,6 +8,7 @@ use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::SDiv; use valida_machine::StarkConfig; +use valida_machine::ValidaPublicValues; use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Word}; use valida_opcodes::{DIV32, SDIV32}; use valida_range::MachineWithRangeChip; @@ -37,6 +38,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/lt/mod.rs b/alu_u32/src/lt/mod.rs index 05d1e83d..b35750d9 100644 --- a/alu_u32/src/lt/mod.rs +++ b/alu_u32/src/lt/mod.rs @@ -8,7 +8,8 @@ use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, Word, MEMORY_CELL_BYTES, + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + MEMORY_CELL_BYTES, }; use valida_opcodes::{LT32, LTE32, SLE32, SLT32}; @@ -40,6 +41,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/mul/mod.rs b/alu_u32/src/mul/mod.rs index dba1f987..3d59352f 100644 --- a/alu_u32/src/mul/mod.rs +++ b/alu_u32/src/mul/mod.rs @@ -5,7 +5,10 @@ use alloc::vec::Vec; use columns::{Mul32Cols, MUL_COL_MAP, NUM_MUL_COLS}; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Mulhs, Mulhu, Operands, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Mulhs, Mulhu, Operands, PublicRow, + ValidaPublicValues, Word, +}; use valida_opcodes::{MUL32, MULHS32, MULHU32}; use valida_range::MachineWithRangeChip; @@ -35,6 +38,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { const MIN_LENGTH: usize = 1 << 10; // for the range check counter diff --git a/alu_u32/src/shift/mod.rs b/alu_u32/src/shift/mod.rs index f368431e..9a0dfc4d 100644 --- a/alu_u32/src/shift/mod.rs +++ b/alu_u32/src/shift/mod.rs @@ -8,7 +8,10 @@ use columns::{Shift32Cols, COL_MAP, NUM_SHIFT_COLS}; use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Sra, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Operands, PublicRow, Sra, ValidaPublicValues, + Word, +}; use valida_opcodes::{DIV32, MUL32, SDIV32, SHL32, SHR32, SRA32}; use p3_air::VirtualPairCol; @@ -38,6 +41,8 @@ where M: MachineWithGeneralBus + MachineWithRangeBus8, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/alu_u32/src/sub/mod.rs b/alu_u32/src/sub/mod.rs index 1b78aec6..20da2e95 100644 --- a/alu_u32/src/sub/mod.rs +++ b/alu_u32/src/sub/mod.rs @@ -6,7 +6,9 @@ use columns::{Sub32Cols, NUM_SUB_COLS, SUB_COL_MAP}; use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, +}; use valida_opcodes::SUB32; use valida_range::MachineWithRangeChip; @@ -35,6 +37,8 @@ where M: MachineWithGeneralBus + MachineWithRangeBus8, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/basic/src/lib.rs b/basic/src/lib.rs index 76dc22e8..4d5700cc 100644 --- a/basic/src/lib.rs +++ b/basic/src/lib.rs @@ -44,14 +44,17 @@ use valida_cpu::{ ReadAdviceInstruction, StopInstruction, Store32Instruction, StoreU8Instruction, }; use valida_cpu::{CpuChip, MachineWithCpuChip}; +use valida_machine::PublicRow; +use valida_machine::PublicValues; +use valida_machine::ValidaPublicValues; use valida_machine::__internal::p3_challenger::{CanObserve, FieldChallenger}; use valida_machine::__internal::{ check_constraints, check_cumulative_sums, get_log_quotient_degree, quotient, }; use valida_machine::{ generate_permutation_trace, verify_constraints, AdviceProvider, BusArgument, Chip, ChipProof, - ColumnIndex, ColumnVector, Commitments, Instruction, Machine, MachineProof, OpenedValues, - ProgramROM, StoppingFlag, ValidaAirBuilder, + Commitments, Instruction, Machine, MachineProof, OpenedValues, ProgramROM, StoppingFlag, + ValidaAirBuilder, }; use valida_memory::{MachineWithMemoryChip, MemoryChip}; use valida_output::{MachineWithOutputChip, OutputChip, WriteInstruction}; @@ -148,7 +151,7 @@ impl Machine for BasicMachine { where SC: StarkConfig, { - let mut chips: [Box<&dyn Chip>; NUM_CHIPS] = [ + let mut chips: [Box<&dyn Chip>>; NUM_CHIPS] = [ Box::new(self.cpu()), Box::new(self.program()), Box::new(self.mem()), @@ -164,7 +167,6 @@ impl Machine for BasicMachine { Box::new(self.range()), Box::new(self.static_data()), ]; - let log_quotient_degrees: [usize; NUM_CHIPS] = [ get_log_quotient_degree::(self, self.cpu()), get_log_quotient_degree::(self, self.program()), @@ -200,6 +202,14 @@ impl Machine for BasicMachine { challenger.observe(preprocessed_commit.clone()); let mut preprocessed_trace_ldes = pcs.get_ldes(&preprocessed_data); + let mut public_values = + tracing::info_span!("generate public values vector").in_scope(|| { + chips + .par_iter() + .map(|chip| chip.generate_public_values()) + .collect::>() + }); + let main_traces: [RowMajorMatrix; NUM_CHIPS] = tracing::info_span!("generate main trace").in_scope(|| { chips @@ -229,20 +239,23 @@ impl Machine for BasicMachine { perm_challenges.push(challenger.sample_ext_element()); } - let perm_traces = tracing::info_span!("generate permutation traces").in_scope(|| { - chips - .into_par_iter() - .enumerate() - .map(|(i, chip)| { - generate_permutation_trace( - self, - *chip, - &main_traces[i], - perm_challenges.clone(), - ) - }) - .collect::>() - }); + let perm_traces: [RowMajorMatrix; NUM_CHIPS] = + tracing::info_span!("generate permutation traces").in_scope(|| { + chips + .into_par_iter() + .enumerate() + .map(|(i, chip)| { + generate_permutation_trace( + self, + *chip, + &main_traces[i], + perm_challenges.clone(), + ) + }) + .collect::>() + .try_into() + .unwrap() + }); let cumulative_sums = perm_traces .iter() @@ -263,19 +276,21 @@ impl Machine for BasicMachine { let alpha: SC::Challenge = challenger.sample_ext_element(); let mut quotients: Vec> = vec![]; - let mut public_inputs: Vec)>> = vec![]; let mut i: usize = 0; let chip = self.cpu(); #[cfg(debug_assertions)] + println!("checking cpu"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("cpu checked"); quotients.push(quotient( self, config, @@ -284,22 +299,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.program(); #[cfg(debug_assertions)] + println!("checking program"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("program checked"); quotients.push(quotient( self, config, @@ -308,22 +326,25 @@ impl Machine for BasicMachine { Some(preprocessed_trace_ldes.remove(0)), main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; let chip = self.mem(); #[cfg(debug_assertions)] + println!("checking mem"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("mem checked"); quotients.push(quotient( self, config, @@ -332,14 +353,15 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.add_u32(); + println!("checking add_u32"); #[cfg(debug_assertions)] check_constraints::( self, @@ -347,7 +369,9 @@ impl Machine for BasicMachine { &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("add_u32 checked"); quotients.push(quotient( self, config, @@ -356,22 +380,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.sub_u32(); #[cfg(debug_assertions)] + println!("checking sub_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("sub_u32 checked"); quotients.push(quotient( self, config, @@ -380,22 +407,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.mul_u32(); #[cfg(debug_assertions)] + println!("checking mul_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("mul_u32 checked"); quotients.push(quotient( self, config, @@ -404,22 +434,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.div_u32(); #[cfg(debug_assertions)] + println!("checking div_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("div_u32 checked"); quotients.push(quotient( self, config, @@ -428,22 +461,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.shift_u32(); #[cfg(debug_assertions)] + println!("checking shift_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("shift_u32 checked"); quotients.push(quotient( self, config, @@ -452,22 +488,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.lt_u32(); #[cfg(debug_assertions)] + println!("checking lt_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("lt_u32 checked"); quotients.push(quotient( self, config, @@ -476,22 +515,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.com_u32(); #[cfg(debug_assertions)] + println!("checking com_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("com_u32 checked"); quotients.push(quotient( self, config, @@ -500,22 +542,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.bitwise_u32(); #[cfg(debug_assertions)] + println!("checking bitwise_u32"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("bitwise_u32 checked"); quotients.push(quotient( self, config, @@ -524,22 +569,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.output(); #[cfg(debug_assertions)] + println!("checking output"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("output checked"); quotients.push(quotient( self, config, @@ -548,22 +596,25 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; let chip = self.range(); #[cfg(debug_assertions)] + println!("checking range"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("range checked"); quotients.push(quotient( self, config, @@ -572,22 +623,25 @@ impl Machine for BasicMachine { Some(preprocessed_trace_ldes.remove(0)), main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(vec![]); i += 1; let chip = self.static_data(); #[cfg(debug_assertions)] + println!("checking static data"); check_constraints::( self, chip, &main_traces[i], &perm_traces[i], &perm_challenges, + &public_values[i], ); + println!("static data checked"); quotients.push(quotient( self, config, @@ -596,11 +650,11 @@ impl Machine for BasicMachine { None::>, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[i], cumulative_sums[i], &perm_challenges, alpha, )); - public_inputs.push(Chip::generate_public_inputs(chip as &dyn Chip)); i += 1; assert_eq!(quotients.len(), NUM_CHIPS); @@ -651,39 +705,35 @@ impl Machine for BasicMachine { .zip(perm_openings) .zip(quotient_openings) .zip(perm_traces) - .zip(public_inputs) - .map( - |(((((log_degree, main), perm), quotient), perm_trace), public_inputs)| { - // TODO: add preprocessed openings - let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; - - let [main_local, main_next] = main.try_into().expect("Should have 2 openings"); - let [perm_local, perm_next] = perm.try_into().expect("Should have 2 openings"); - let [quotient_chunks] = quotient.try_into().expect("Should have 1 opening"); - - let opened_values = OpenedValues { - preprocessed_local, - preprocessed_next, - trace_local: main_local, - trace_next: main_next, - permutation_local: perm_local, - permutation_next: perm_next, - quotient_chunks, - }; - - let cumulative_sum = perm_trace - .row_slice(perm_trace.height() - 1) - .last() - .unwrap() - .clone(); - ChipProof { - public_inputs, - log_degree: *log_degree, - opened_values, - cumulative_sum, - } - }, - ) + .map(|((((log_degree, main), perm), quotient), perm_trace)| { + // TODO: add preprocessed openings + let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; + + let [main_local, main_next] = main.try_into().expect("Should have 2 openings"); + let [perm_local, perm_next] = perm.try_into().expect("Should have 2 openings"); + let [quotient_chunks] = quotient.try_into().expect("Should have 1 opening"); + + let opened_values = OpenedValues { + preprocessed_local, + preprocessed_next, + trace_local: main_local, + trace_next: main_next, + permutation_local: perm_local, + permutation_next: perm_next, + quotient_chunks, + }; + + let cumulative_sum = perm_trace + .row_slice(perm_trace.height() - 1) + .last() + .unwrap() + .clone(); + ChipProof { + log_degree: *log_degree, + opened_values, + cumulative_sum, + } + }) .collect::>(); MachineProof { @@ -697,7 +747,7 @@ impl Machine for BasicMachine { where SC: StarkConfig, { - let mut chips: [Box<&dyn Chip>; NUM_CHIPS] = [ + let mut chips: [Box<&dyn Chip>; NUM_CHIPS] = [ Box::new(self.cpu()), Box::new(self.program()), Box::new(self.mem()), @@ -859,10 +909,12 @@ impl Machine for BasicMachine { let mut i = 0; let chip = self.cpu(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -874,10 +926,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.program(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -889,10 +943,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.mem(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -904,10 +960,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.add_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -919,10 +977,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.sub_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -934,10 +994,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.mul_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -949,10 +1011,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.div_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -964,10 +1028,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.shift_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -979,10 +1045,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.lt_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -994,10 +1062,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.com_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -1009,10 +1079,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.bitwise_u32(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -1024,10 +1096,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.output(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -1039,10 +1113,13 @@ impl Machine for BasicMachine { i += 1; let chip = self.range(); + let public_values = + as Chip>::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], @@ -1054,10 +1131,12 @@ impl Machine for BasicMachine { i += 1; let chip = self.static_data(); + let public_values = >::generate_public_values(&chip); verify_constraints::( self, chip, &proof.chip_proofs[i].opened_values, + &public_values, proof.chip_proofs[i].cumulative_sum, proof.chip_proofs[i].log_degree, g_subgroups[i], diff --git a/basic_macro/src/lib.rs b/basic_macro/src/lib.rs index 51c85f19..8d2b44ed 100644 --- a/basic_macro/src/lib.rs +++ b/basic_macro/src/lib.rs @@ -40,7 +40,7 @@ use valida_cpu::{CpuChip, MachineWithCpuChip}; use valida_derive::Machine; use valida_machine::{ AdviceProvider, BusArgument, Chip, ChipProof, Instruction, Machine, MachineProof, ProgramROM, - StoppingFlag, ValidaAirBuilder, ColumnVector, ColumnIndex, + StoppingFlag, ValidaAirBuilder, }; use valida_memory::{MachineWithMemoryChip, MemoryChip}; use valida_output::{MachineWithOutputChip, OutputChip, WriteInstruction}; diff --git a/cpu/src/lib.rs b/cpu/src/lib.rs index 52885c95..19317488 100644 --- a/cpu/src/lib.rs +++ b/cpu/src/lib.rs @@ -11,9 +11,10 @@ use core::marker::Sync; use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithMemBus, MachineWithProgramBus}; use valida_machine::is_mul_4; +use valida_machine::ValidaPublicValues; use valida_machine::{ addr_of_word, index_of_byte, instructions, AdviceProvider, Chip, Instruction, InstructionWord, - Interaction, Operands, Word, + Interaction, Operands, PublicRow, Word, }; use valida_memory::{MachineWithMemoryChip, Operation as MemoryOperation}; use valida_opcodes::{ @@ -76,6 +77,8 @@ where + Sync, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, machine: &M) -> RowMajorMatrix { let mut rows = self .operations diff --git a/machine/Cargo.toml b/machine/Cargo.toml index 33a050af..b082edff 100644 --- a/machine/Cargo.toml +++ b/machine/Cargo.toml @@ -11,7 +11,10 @@ std = [] [dependencies] byteorder = "1.4.3" itertools = "0.12.0" -serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } +serde = { version = "1.0", default-features = false, features = [ + "derive", + "alloc", +] } tracing = "0.1.37" valida-opcodes = { path = "../opcodes" } @@ -22,6 +25,7 @@ p3-commit = { workspace = true } p3-challenger = { workspace = true } p3-dft = { workspace = true } p3-field = { workspace = true } +p3-interpolation = { workspace = true } p3-matrix = { workspace = true } p3-maybe-rayon = { workspace = true } p3-uni-stark = { workspace = true } diff --git a/machine/src/check_constraints.rs b/machine/src/check_constraints.rs index 97ecb3e5..330c7c31 100644 --- a/machine/src/check_constraints.rs +++ b/machine/src/check_constraints.rs @@ -2,6 +2,7 @@ use crate::__internal::DebugConstraintBuilder; use crate::chip::eval_permutation_constraints; use valida_machine::StarkConfig; +use crate::public::PublicValues; use crate::{Chip, Machine}; use p3_air::TwoRowMatrixView; use p3_field::{AbstractField, Field}; @@ -17,10 +18,12 @@ pub fn check_constraints( main: &RowMajorMatrix, perm: &RowMajorMatrix, perm_challenges: &[SC::Challenge], + public: &Option, ) where M: Machine, A: Chip, SC: StarkConfig, + A::Public: Sync, { assert_eq!(main.height(), perm.height()); let height = main.height(); @@ -38,6 +41,16 @@ pub fn check_constraints( let main_local = main.row_slice(i); let main_next = main.row_slice(i_next); + let public_local = if public.is_some() { + public.as_ref().unwrap().row_slice(i) + } else { + &[] + }; + let public_next = if public.is_some() { + public.as_ref().unwrap().row_slice(i_next) + } else { + &[] + }; let preprocessed_local = if preprocessed.is_some() { preprocessed.as_ref().unwrap().row_slice(i) } else { @@ -57,6 +70,10 @@ pub fn check_constraints( local: &main_local, next: &main_next, }, + public_values: TwoRowMatrixView { + local: &public_local, + next: &public_next, + }, preprocessed: TwoRowMatrixView { local: &preprocessed_local, next: &preprocessed_next, diff --git a/machine/src/chip.rs b/machine/src/chip.rs index 691d0fac..fb119df7 100644 --- a/machine/src/chip.rs +++ b/machine/src/chip.rs @@ -1,28 +1,33 @@ -use crate::folding_builder::VerifierConstraintFolder; -use crate::{Machine, ColumnVector, ColumnIndex}; use crate::__internal::{DebugConstraintBuilder, ProverConstraintFolder}; +use crate::folding_builder::VerifierConstraintFolder; +use crate::public::PublicValues; +use crate::Machine; use alloc::vec; use alloc::vec::Vec; use crate::config::StarkConfig; use crate::symbolic::symbolic_builder::SymbolicAirBuilder; use p3_air::ExtensionBuilder; -use p3_air::{Air, PairBuilder, PermutationAirBuilder, VirtualPairCol}; +use p3_air::{Air, AirBuilderWithPublicValues, PairBuilder, PermutationAirBuilder, VirtualPairCol}; use p3_field::{AbstractField, ExtensionField, Field, Powers}; use p3_matrix::{dense::RowMajorMatrix, Matrix, MatrixRowSlices}; use valida_util::batch_multiplicative_inverse_allowing_zero; -pub trait Chip, SC: StarkConfig>: +pub trait Chip: for<'a> Air> + for<'a> Air> + for<'a> Air> + for<'a> Air> +where + M: Machine, + SC: StarkConfig, { + type Public: PublicValues; /// Generate the main trace for the chip given the provided machine. fn generate_trace(&self, machine: &M) -> RowMajorMatrix; - fn generate_public_inputs(&self) -> Vec<(ColumnIndex, ColumnVector)> { - vec![] + fn generate_public_values(&self) -> Option { + None } fn local_sends(&self) -> Vec> { @@ -71,7 +76,9 @@ pub trait Chip, SC: StarkConfig>: } } -pub trait ValidaAirBuilder: PairBuilder + PermutationAirBuilder { +pub trait ValidaAirBuilder: + PairBuilder + PermutationAirBuilder + AirBuilderWithPublicValues +{ type Machine; fn machine(&self) -> &Self::Machine; @@ -122,15 +129,16 @@ impl Interaction { /// Generate the permutation trace for a chip with the provided machine. /// This is called only after `generate_trace` has been called on all chips. -pub fn generate_permutation_trace( +pub fn generate_permutation_trace( machine: &M, - chip: &dyn Chip, + chip: &dyn Chip, main: &RowMajorMatrix, random_elements: Vec, ) -> RowMajorMatrix where M: Machine, SC: StarkConfig, + P: PublicValues, { let all_interactions = chip.all_interactions(machine); let (alphas_local, alphas_global) = generate_rlc_elements(machine, chip, &random_elements); @@ -292,14 +300,15 @@ pub fn eval_permutation_constraints( ); } -fn generate_rlc_elements( +fn generate_rlc_elements( machine: &M, - chip: &dyn Chip, + chip: &dyn Chip, random_elements: &[SC::Challenge], ) -> (Vec, Vec) where M: Machine, SC: StarkConfig, + P: PublicValues, { let alphas_local = random_elements[0] .powers() diff --git a/machine/src/debug_builder.rs b/machine/src/debug_builder.rs index 93b794bb..ded85f50 100644 --- a/machine/src/debug_builder.rs +++ b/machine/src/debug_builder.rs @@ -1,5 +1,8 @@ use crate::{Machine, ValidaAirBuilder}; -use p3_air::{AirBuilder, ExtensionBuilder, PairBuilder, PermutationAirBuilder, TwoRowMatrixView}; +use p3_air::{ + AirBuilder, AirBuilderWithPublicValues, ExtensionBuilder, PairBuilder, PermutationAirBuilder, + TwoRowMatrixView, +}; use p3_field::AbstractField; use valida_machine::StarkConfig; /// An `AirBuilder` which asserts that each constraint is zero, allowing any failed constraints to @@ -13,6 +16,7 @@ pub struct DebugConstraintBuilder<'a, M: Machine, SC: StarkConfig> { pub(crate) is_first_row: SC::Val, pub(crate) is_last_row: SC::Val, pub(crate) is_transition: SC::Val, + pub(crate) public_values: TwoRowMatrixView<'a, SC::Val>, } impl<'a, M, SC> AirBuilder for DebugConstraintBuilder<'a, M, SC> @@ -112,3 +116,13 @@ where self.machine } } + +impl<'a, M: Machine, SC> AirBuilderWithPublicValues for DebugConstraintBuilder<'a, M, SC> +where + M: Machine, + SC: StarkConfig, +{ + fn public_values(&self) -> Self::M { + self.public_values + } +} diff --git a/machine/src/folding_builder.rs b/machine/src/folding_builder.rs index 9f91b6e9..e456d329 100644 --- a/machine/src/folding_builder.rs +++ b/machine/src/folding_builder.rs @@ -1,10 +1,14 @@ use crate::{Machine, ValidaAirBuilder}; -use p3_air::{AirBuilder, ExtensionBuilder, PairBuilder, PermutationAirBuilder, TwoRowMatrixView}; +use p3_air::{ + AirBuilder, AirBuilderWithPublicValues, ExtensionBuilder, PairBuilder, PermutationAirBuilder, + TwoRowMatrixView, +}; use p3_field::AbstractField; use valida_machine::StarkConfig; pub struct ProverConstraintFolder<'a, M: Machine, SC: StarkConfig> { pub(crate) machine: &'a M, + pub(crate) public_values: TwoRowMatrixView<'a, SC::PackedVal>, pub(crate) preprocessed: TwoRowMatrixView<'a, SC::PackedVal>, pub(crate) main: TwoRowMatrixView<'a, SC::PackedVal>, pub(crate) perm: TwoRowMatrixView<'a, SC::PackedChallenge>, @@ -20,6 +24,7 @@ pub struct VerifierConstraintFolder<'a, M, SC: StarkConfig> { pub(crate) machine: &'a M, pub(crate) preprocessed: TwoRowMatrixView<'a, SC::Challenge>, pub(crate) main: TwoRowMatrixView<'a, SC::Challenge>, + pub(crate) public_values: TwoRowMatrixView<'a, SC::Challenge>, pub(crate) perm: TwoRowMatrixView<'a, SC::Challenge>, pub(crate) perm_challenges: &'a [SC::Challenge], pub(crate) is_first_row: SC::Challenge, @@ -124,6 +129,16 @@ where } } +impl<'a, M, SC> AirBuilderWithPublicValues for ProverConstraintFolder<'a, M, SC> +where + M: Machine, + SC: StarkConfig, +{ + fn public_values(&self) -> Self::M { + self.public_values + } +} + impl<'a, M, SC> AirBuilder for VerifierConstraintFolder<'a, M, SC> where M: Machine, @@ -215,3 +230,13 @@ where self.machine } } + +impl<'a, M, SC> AirBuilderWithPublicValues for VerifierConstraintFolder<'a, M, SC> +where + M: Machine, + SC: StarkConfig, +{ + fn public_values(&self) -> Self::M { + self.public_values + } +} diff --git a/machine/src/lib.rs b/machine/src/lib.rs index 3437db03..b99aa7ee 100644 --- a/machine/src/lib.rs +++ b/machine/src/lib.rs @@ -15,6 +15,7 @@ mod folding_builder; mod machine; mod program; mod proof; +mod public; mod quotient; mod symbolic; mod verify; @@ -27,6 +28,7 @@ pub use error::*; pub use machine::*; pub use program::*; pub use proof::*; +pub use public::*; pub use verify::*; pub const OPERAND_ELEMENTS: usize = 5; diff --git a/machine/src/public.rs b/machine/src/public.rs new file mode 100644 index 00000000..844ab8e5 --- /dev/null +++ b/machine/src/public.rs @@ -0,0 +1,181 @@ +use alloc::slice; +use core::iter::Cloned; +use p3_field::{AbstractExtensionField, AbstractField, ExtensionField, TwoAdicField}; +use p3_interpolation; +use p3_matrix::{ + dense::{RowMajorMatrix, RowMajorMatrixView}, + Matrix, MatrixGet, MatrixRowSlices, MatrixRows, +}; +use p3_util::log2_strict_usize; + +pub trait PublicValues: MatrixRowSlices + MatrixGet +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ + fn interpolate(&self, zeta: E, offset: usize) -> Vec + where + Self: core::marker::Sized, + { + let height = self.height(); + let log_height = log2_strict_usize(height); + let g = F::two_adic_generator(log_height); + let shift = g.powers().nth(offset).unwrap(); + + p3_interpolation::interpolate_coset::(self, shift, zeta) + } +} + +impl PublicValues for RowMajorMatrix +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ +} + +impl PublicValues for RowMajorMatrixView<'_, F> +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ +} + +// In the case that the public values are a vector rather than a matrix, +// we view it as a matrix with a single row repeated as many times as desired. +pub struct PublicRow(pub Vec); +pub struct PublicRowView<'a, F>(pub &'a [F]); + +impl Matrix for PublicRow { + fn width(&self) -> usize { + self.0.len() + } + fn height(&self) -> usize { + 1 + } +} +impl Matrix for PublicRowView<'_, T> { + fn width(&self) -> usize { + self.0.len() + } + fn height(&self) -> usize { + 1 + } +} + +impl MatrixRows for PublicRow { + type Row<'a> = Cloned> where T: 'a, Self: 'a; + + fn row(&self, _r: usize) -> Self::Row<'_> { + self.0.iter().cloned() + } +} +impl MatrixRows for PublicRowView<'_, T> { + type Row<'a> = Cloned> where T: 'a, Self: 'a; + + fn row(&self, _r: usize) -> Self::Row<'_> { + self.0.iter().cloned() + } +} + +impl MatrixRowSlices for PublicRow { + fn row_slice(&self, _r: usize) -> &[T] { + self.0.iter().as_slice() + } +} +impl MatrixRowSlices for PublicRowView<'_, T> { + fn row_slice(&self, _r: usize) -> &[T] { + self.0.iter().as_slice() + } +} + +impl MatrixGet for PublicRow { + fn get(&self, _r: usize, c: usize) -> T { + self.0[c].clone() + } +} +impl MatrixGet for PublicRowView<'_, T> { + fn get(&self, _r: usize, c: usize) -> T { + self.0[c].clone() + } +} + +impl PublicValues for PublicRow +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ + fn interpolate(&self, _zeta: E, _offset: usize) -> Vec { + self.0.iter().map(|v| E::from_base(v.clone())).collect() + } +} +impl PublicValues for PublicRowView<'_, F> +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ + fn interpolate(&self, _zeta: E, _offset: usize) -> Vec { + self.0.iter().map(|v| E::from_base(v.clone())).collect() + } +} + +pub enum ValidaPublicValues { + PublicTrace(RowMajorMatrix), + PublicVector(PublicRow), +} + +impl Matrix for ValidaPublicValues { + fn width(&self) -> usize { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.width(), + ValidaPublicValues::PublicVector(row) => row.width(), + } + } + fn height(&self) -> usize { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.height(), + ValidaPublicValues::PublicVector(row) => row.height(), + } + } +} + +impl MatrixRows for ValidaPublicValues { + type Row<'a> = Cloned> where F: 'a, Self: 'a; + + fn row(&self, r: usize) -> Self::Row<'_> { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.row(r), + ValidaPublicValues::PublicVector(row) => row.row(r), + } + } +} + +impl MatrixGet for ValidaPublicValues { + fn get(&self, r: usize, c: usize) -> F { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.get(r, c), + ValidaPublicValues::PublicVector(row) => row.get(r, c), + } + } +} + +impl MatrixRowSlices for ValidaPublicValues { + fn row_slice(&self, r: usize) -> &[F] { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.row_slice(r), + ValidaPublicValues::PublicVector(row) => row.row_slice(r), + } + } +} + +impl PublicValues for ValidaPublicValues +where + F: TwoAdicField, + E: ExtensionField + TwoAdicField, +{ + fn interpolate(&self, zeta: E, offset: usize) -> Vec { + match self { + ValidaPublicValues::PublicTrace(mat) => mat.interpolate(zeta, offset), + ValidaPublicValues::PublicVector(row) => row.interpolate(zeta, offset), + } + } +} diff --git a/machine/src/quotient.rs b/machine/src/quotient.rs index c7b1eadc..4da52be7 100644 --- a/machine/src/quotient.rs +++ b/machine/src/quotient.rs @@ -1,5 +1,6 @@ use crate::__internal::ProverConstraintFolder; use crate::config::StarkConfig; +use crate::public::PublicValues; use crate::symbolic::symbolic_builder::get_log_quotient_degree; use crate::{eval_permutation_constraints, Chip, Machine}; use itertools::Itertools; @@ -10,7 +11,7 @@ use p3_field::{ TwoAdicField, }; use p3_matrix::dense::RowMajorMatrix; -use p3_matrix::{MatrixGet, MatrixRows}; +use p3_matrix::{Matrix, MatrixGet, MatrixRows}; use p3_maybe_rayon::prelude::*; use p3_uni_stark::{decompose_and_flatten, ZerofierOnCoset}; use tracing::instrument; @@ -23,6 +24,7 @@ pub fn quotient( preprocessed_trace_lde: Option, main_trace_lde: MainTraceLde, perm_trace_lde: PermTraceLde, + public_values: &Option, cumulative_sum: SC::Challenge, perm_challenges: &[SC::Challenge], alpha: SC::Challenge, @@ -34,6 +36,7 @@ where PreprocessedTraceLde: MatrixRows + MatrixGet + Sync, MainTraceLde: MatrixRows + MatrixGet + Sync, PermTraceLde: MatrixRows + MatrixGet + Sync, + A::Public: Send + Sync, { let pcs = config.pcs(); let log_quotient_degree = get_log_quotient_degree::(machine, air); @@ -55,6 +58,7 @@ where preprocessed_trace_lde_for_quotient, main_trace_lde_for_quotient, perm_trace_lde_for_quotient, + public_values, cumulative_sum, perm_challenges, alpha, @@ -77,6 +81,7 @@ fn quotient_values( preprocessed_trace_lde: Option, main_trace_lde: MainTraceLde, perm_trace_lde: PermTraceLde, + public_values: &Option, cumulative_sum: SC::Challenge, perm_challenges: &[SC::Challenge], alpha: SC::Challenge, @@ -85,6 +90,7 @@ where M: Machine, SC: StarkConfig, A: Chip, + A::Public: Send + Sync, PreprocessedTraceLde: MatrixRows + MatrixGet + Sync, MainTraceLde: MatrixRows + MatrixGet + Sync, PermTraceLde: MatrixRows + MatrixGet + Sync, @@ -196,9 +202,35 @@ where }) .collect(); + let (public_local, public_next): (Vec<_>, Vec<_>) = match public_values { + Some(ref public_values) => ( + (0..public_values.width()) + .map(|col| { + SC::PackedVal::from_fn(|offset| { + let row = wrap(i_local_start + offset); + public_values.get(row, col) + }) + }) + .collect(), + (0..public_values.width()) + .map(|col| { + SC::PackedVal::from_fn(|offset| { + let row = wrap(i_next_start + offset); + public_values.get(row, col) + }) + }) + .collect(), + ), + None => (vec![], vec![]), + }; + let accumulator = SC::PackedChallenge::zero(); let mut folder = ProverConstraintFolder { machine, + public_values: TwoRowMatrixView { + local: &public_local, + next: &public_next, + }, preprocessed: TwoRowMatrixView { local: &preprocessed_local, next: &preprocessed_next, diff --git a/machine/src/symbolic/symbolic_builder.rs b/machine/src/symbolic/symbolic_builder.rs index da9c3742..9ba105c5 100644 --- a/machine/src/symbolic/symbolic_builder.rs +++ b/machine/src/symbolic/symbolic_builder.rs @@ -1,10 +1,9 @@ -use alloc::vec; use alloc::vec::Vec; use crate::config::StarkConfig; use crate::{Machine, ValidaAirBuilder}; -use p3_air::ExtensionBuilder; use p3_air::{Air, AirBuilder, PairBuilder, PermutationAirBuilder}; +use p3_air::{AirBuilderWithPublicValues, ExtensionBuilder}; use p3_field::AbstractExtensionField; use p3_matrix::dense::RowMajorMatrix; use p3_util::log2_ceil_usize; @@ -59,6 +58,7 @@ pub struct SymbolicAirBuilder<'a, M: Machine, SC: StarkConfig> { preprocessed: RowMajorMatrix>, main: RowMajorMatrix>, permutation: RowMajorMatrix>, + public_values: RowMajorMatrix>, constraints: Vec>, } @@ -70,6 +70,7 @@ impl<'a, M: Machine, SC: StarkConfig> SymbolicAirBuilder<'a, M, SC> { preprocessed: SymbolicVariable::window(Trace::Preprocessed, width), main: SymbolicVariable::window(Trace::Main, width), permutation: SymbolicVariable::window(Trace::Permutation, width), + public_values: SymbolicVariable::window(Trace::Public, width), constraints: vec![], } } @@ -152,3 +153,11 @@ impl<'a, M: Machine, SC: StarkConfig> ValidaAirBuilder for SymbolicAirB self.machine } } + +impl<'a, M: Machine, SC: StarkConfig> AirBuilderWithPublicValues + for SymbolicAirBuilder<'a, M, SC> +{ + fn public_values(&self) -> Self::M { + self.public_values.clone() + } +} diff --git a/machine/src/symbolic/symbolic_expression.rs b/machine/src/symbolic/symbolic_expression.rs index 8740fbbe..b84365fe 100644 --- a/machine/src/symbolic/symbolic_expression.rs +++ b/machine/src/symbolic/symbolic_expression.rs @@ -40,7 +40,7 @@ impl SymbolicExpression { /// Returns the multiple of `n` (the trace length) in this expression's degree. pub(crate) fn degree_multiple(&self) -> usize { match self { - SymbolicExpression::Variable(_) => 1, + SymbolicExpression::Variable(v) => v.degree_multiple(), SymbolicExpression::IsFirstRow => 1, SymbolicExpression::IsLastRow => 1, SymbolicExpression::IsTransition => 0, diff --git a/machine/src/symbolic/symbolic_variable.rs b/machine/src/symbolic/symbolic_variable.rs index 38190454..0b783ef3 100644 --- a/machine/src/symbolic/symbolic_variable.rs +++ b/machine/src/symbolic/symbolic_variable.rs @@ -11,6 +11,7 @@ pub enum Trace { Preprocessed, Main, Permutation, + Public, } /// A variable within the evaluation window, i.e. a column in either the local or next row. @@ -46,6 +47,15 @@ impl SymbolicVariable { _phantom: PhantomData, } } + + pub(crate) fn degree_multiple(&self) -> usize { + match self.trace { + Trace::Preprocessed => 1, + Trace::Main => 1, + Trace::Permutation => 1, + Trace::Public => 0, + } + } } impl From> for SymbolicExpression { diff --git a/machine/src/verify.rs b/machine/src/verify.rs index 0e7620da..6efda30a 100644 --- a/machine/src/verify.rs +++ b/machine/src/verify.rs @@ -4,6 +4,7 @@ use p3_field::{AbstractField, Field}; use p3_util::reverse_slice_index_bits; use crate::folding_builder::VerifierConstraintFolder; +use crate::public::PublicValues; use crate::{ eval_permutation_constraints, Chip, Machine, OodEvaluationMismatch, OpenedValues, StarkConfig, }; @@ -12,6 +13,7 @@ pub fn verify_constraints( machine: &M, chip: &C, opened_values: &OpenedValues, + public_values: &Option, cumulative_sum: SC::Challenge, log_degree: usize, g: SC::Val, @@ -39,6 +41,15 @@ where quotient_chunks, } = opened_values; + let (public_local, public_next) = if let Some(ref public_values) = public_values { + ( + public_values.interpolate(zeta, 0), + public_values.interpolate(zeta, 1), + ) + } else { + (vec![], vec![]) + }; + let monomials = (0..SC::Challenge::D) .map(SC::Challenge::monomial) .collect::>(); @@ -77,6 +88,10 @@ where local: &trace_local, next: &trace_next, }, + public_values: TwoRowMatrixView { + local: &public_local, + next: &public_next, + }, perm: TwoRowMatrixView { local: &unflatten(permutation_local), next: &unflatten(permutation_next), diff --git a/memory/src/lib.rs b/memory/src/lib.rs index 1bb80eac..0621be3c 100644 --- a/memory/src/lib.rs +++ b/memory/src/lib.rs @@ -2,7 +2,7 @@ extern crate alloc; -use valida_machine::MEMORY_CELL_BYTES; +use valida_machine::{ValidaPublicValues, MEMORY_CELL_BYTES}; use crate::alloc::string::ToString; use crate::columns::{MemoryCols, MEM_COL_MAP, NUM_MEM_COLS}; @@ -16,6 +16,7 @@ use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::prelude::*; use valida_bus::MachineWithMemBus; +use valida_machine::PublicRow; use valida_machine::StarkConfig; use valida_machine::{Chip, Interaction, Machine, Word}; use valida_util::batch_multiplicative_inverse_allowing_zero; @@ -140,6 +141,8 @@ where M: MachineWithMemBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let mut ops = self .operations diff --git a/native_field/src/lib.rs b/native_field/src/lib.rs index affa7faf..85669aeb 100644 --- a/native_field/src/lib.rs +++ b/native_field/src/lib.rs @@ -8,7 +8,9 @@ use columns::{NativeFieldCols, COL_MAP, NUM_NATIVE_FIELD_COLS}; use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{instructions, Chip, Instruction, Interaction, Operands, Word}; +use valida_machine::{ + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, +}; use valida_opcodes::{ADD, MUL, SUB}; use valida_range::MachineWithRangeChip; use valida_util::pad_to_power_of_two; @@ -38,6 +40,8 @@ where M: MachineWithGeneralBus + MachineWithRangeBus8, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let rows = self .operations diff --git a/output/src/lib.rs b/output/src/lib.rs index c11908e0..89bd8763 100644 --- a/output/src/lib.rs +++ b/output/src/lib.rs @@ -4,7 +4,8 @@ use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, CPU_MEMORY_CHANNELS, MEMORY_CELL_BYTES, + instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, + CPU_MEMORY_CHANNELS, MEMORY_CELL_BYTES, }; use valida_opcodes::WRITE; @@ -34,6 +35,8 @@ where M: MachineWithGeneralBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let table_len = self.values.len() as u32; let mut rows = self @@ -96,6 +99,11 @@ where RowMajorMatrix::new(values, NUM_OUTPUT_COLS) } + fn generate_public_values(&self) -> Option { + //TODO: This should give the output vector, without clock values + None + } + //fn local_sends(&self) -> Vec> { // let sends = Interaction { // fields: vec![VirtualPairCol::single_main(OUTPUT_COL_MAP.diff)], diff --git a/program/src/lib.rs b/program/src/lib.rs index 367fe101..8865f64f 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -2,11 +2,15 @@ extern crate alloc; +use core::mem::transmute; + use crate::columns::NUM_PROGRAM_COLS; use alloc::vec; use alloc::vec::Vec; +use columns::{ProgramPreprocessedCols, NUM_PREPROCESSED_COLS}; +use p3_air::BaseAir; use valida_bus::MachineWithProgramBus; -use valida_machine::{Chip, Interaction, Machine, ProgramROM}; +use valida_machine::{Chip, Interaction, Machine, ProgramROM, ValidaPublicValues}; use valida_util::pad_to_power_of_two; use p3_field::{AbstractField, Field}; @@ -35,6 +39,8 @@ where M: MachineWithProgramBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let mut values = self .counts diff --git a/range/src/lib.rs b/range/src/lib.rs index 6d104d9b..3be11026 100644 --- a/range/src/lib.rs +++ b/range/src/lib.rs @@ -8,13 +8,13 @@ use alloc::vec::Vec; use columns::{RangeCols, NUM_RANGE_COLS, RANGE_COL_MAP}; use core::mem::transmute; use valida_bus::MachineWithRangeBus8; -use valida_machine::Interaction; use valida_machine::{Chip, Machine, Word}; +use valida_machine::{Interaction, ValidaPublicValues}; use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; -use valida_machine::StarkConfig; +use valida_machine::{PublicRow, StarkConfig}; pub mod columns; pub mod stark; @@ -29,6 +29,8 @@ where M: MachineWithRangeBus8, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let mut rows = vec![[SC::Val::zero(); NUM_RANGE_COLS]; MAX as usize]; for (n, row) in rows.iter_mut().enumerate() { diff --git a/static_data/src/lib.rs b/static_data/src/lib.rs index cbe3615b..6e71091d 100644 --- a/static_data/src/lib.rs +++ b/static_data/src/lib.rs @@ -11,7 +11,7 @@ use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; use valida_bus::MachineWithMemBus; -use valida_machine::{Chip, Interaction, StarkConfig, Word}; +use valida_machine::{Chip, Interaction, StarkConfig, ValidaPublicValues, Word}; use valida_memory::MachineWithMemoryChip; pub mod columns; @@ -57,6 +57,8 @@ where M: MachineWithMemBus, SC: StarkConfig, { + type Public = ValidaPublicValues; + fn generate_trace(&self, _machine: &M) -> RowMajorMatrix { let mut rows = self .cells @@ -78,6 +80,11 @@ where RowMajorMatrix::new(rows, NUM_STATIC_DATA_COLS) } + //TODO: fill this in with the static data values + fn generate_public_values(&self) -> Option { + None + } + fn global_sends(&self, machine: &M) -> Vec> { let addr = VirtualPairCol::single_main(STATIC_DATA_COL_MAP.addr); let value = STATIC_DATA_COL_MAP.value.0.map(VirtualPairCol::single_main); From da4f49cc18f085cf4382a10011f470a0a04a66e5 Mon Sep 17 00:00:00 2001 From: Dan Dore Date: Mon, 3 Jun 2024 19:14:18 -0700 Subject: [PATCH 3/3] fixes macro version --- Cargo.lock | 42 ++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- alu_u32/src/add/mod.rs | 2 +- alu_u32/src/bitwise/mod.rs | 2 +- alu_u32/src/com/mod.rs | 2 +- alu_u32/src/lt/mod.rs | 2 +- alu_u32/src/mul/mod.rs | 3 +-- alu_u32/src/shift/mod.rs | 3 +-- alu_u32/src/sub/mod.rs | 2 +- basic/src/lib.rs | 28 --------------------- cpu/src/lib.rs | 2 +- derive/src/lib.rs | 31 ++++++++++++++--------- machine/src/check_constraints.rs | 1 - machine/src/public.rs | 2 +- machine/src/quotient.rs | 1 - memory/src/lib.rs | 1 - native_field/src/lib.rs | 2 +- output/src/lib.rs | 2 +- program/src/lib.rs | 3 --- range/src/lib.rs | 2 +- 20 files changed, 75 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df357ba7..fb90ffbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1532,6 +1532,48 @@ dependencies = [ "valida-static-data", ] +[[package]] +name = "valida-basic-macro" +version = "0.1.0" +dependencies = [ + "byteorder", + "ciborium", + "clap", + "p3-air", + "p3-baby-bear", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-fri", + "p3-goldilocks", + "p3-keccak", + "p3-matrix", + "p3-maybe-rayon", + "p3-mds", + "p3-merkle-tree", + "p3-poseidon", + "p3-symmetric", + "p3-uni-stark", + "p3-util", + "rand", + "rand_pcg", + "rand_seeder", + "tracing", + "valida-alu-u32", + "valida-assembler", + "valida-bus", + "valida-cpu", + "valida-derive", + "valida-machine", + "valida-memory", + "valida-opcodes", + "valida-output", + "valida-program", + "valida-range", + "valida-static-data", +] + [[package]] name = "valida-bus" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 2b418276..f31bbd94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "assembler", "alu_u32", "basic", - #"basic_macro", + "basic_macro", "bus", "cpu", "derive", diff --git a/alu_u32/src/add/mod.rs b/alu_u32/src/add/mod.rs index 916cd0c1..1bdabc3c 100644 --- a/alu_u32/src/add/mod.rs +++ b/alu_u32/src/add/mod.rs @@ -7,7 +7,7 @@ use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, }; use valida_opcodes::ADD32; use valida_range::MachineWithRangeChip; diff --git a/alu_u32/src/bitwise/mod.rs b/alu_u32/src/bitwise/mod.rs index 4b8b2df1..a8e82103 100644 --- a/alu_u32/src/bitwise/mod.rs +++ b/alu_u32/src/bitwise/mod.rs @@ -7,7 +7,7 @@ use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, }; use valida_opcodes::{AND32, OR32, XOR32}; diff --git a/alu_u32/src/com/mod.rs b/alu_u32/src/com/mod.rs index d2fcdd60..d4118bdf 100644 --- a/alu_u32/src/com/mod.rs +++ b/alu_u32/src/com/mod.rs @@ -7,11 +7,11 @@ use core::iter; use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; +use valida_machine::StarkConfig; use valida_machine::{ instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, MEMORY_CELL_BYTES, }; -use valida_machine::{PublicRow, StarkConfig}; use valida_opcodes::{EQ32, NE32}; use p3_air::VirtualPairCol; diff --git a/alu_u32/src/lt/mod.rs b/alu_u32/src/lt/mod.rs index b35750d9..c665a3b9 100644 --- a/alu_u32/src/lt/mod.rs +++ b/alu_u32/src/lt/mod.rs @@ -8,7 +8,7 @@ use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, MEMORY_CELL_BYTES, }; use valida_opcodes::{LT32, LTE32, SLE32, SLT32}; diff --git a/alu_u32/src/mul/mod.rs b/alu_u32/src/mul/mod.rs index 3d59352f..3b476343 100644 --- a/alu_u32/src/mul/mod.rs +++ b/alu_u32/src/mul/mod.rs @@ -6,8 +6,7 @@ use columns::{Mul32Cols, MUL_COL_MAP, NUM_MUL_COLS}; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Mulhs, Mulhu, Operands, PublicRow, - ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Mulhs, Mulhu, Operands, ValidaPublicValues, Word, }; use valida_opcodes::{MUL32, MULHS32, MULHU32}; use valida_range::MachineWithRangeChip; diff --git a/alu_u32/src/shift/mod.rs b/alu_u32/src/shift/mod.rs index 9a0dfc4d..d2d249f8 100644 --- a/alu_u32/src/shift/mod.rs +++ b/alu_u32/src/shift/mod.rs @@ -9,8 +9,7 @@ use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, Sra, ValidaPublicValues, - Word, + instructions, Chip, Instruction, Interaction, Operands, Sra, ValidaPublicValues, Word, }; use valida_opcodes::{DIV32, MUL32, SDIV32, SHL32, SHR32, SRA32}; diff --git a/alu_u32/src/sub/mod.rs b/alu_u32/src/sub/mod.rs index 20da2e95..47803c53 100644 --- a/alu_u32/src/sub/mod.rs +++ b/alu_u32/src/sub/mod.rs @@ -7,7 +7,7 @@ use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, }; use valida_opcodes::SUB32; use valida_range::MachineWithRangeChip; diff --git a/basic/src/lib.rs b/basic/src/lib.rs index 4d5700cc..57b9284d 100644 --- a/basic/src/lib.rs +++ b/basic/src/lib.rs @@ -281,7 +281,6 @@ impl Machine for BasicMachine { let chip = self.cpu(); #[cfg(debug_assertions)] - println!("checking cpu"); check_constraints::( self, chip, @@ -290,7 +289,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("cpu checked"); quotients.push(quotient( self, config, @@ -308,7 +306,6 @@ impl Machine for BasicMachine { let chip = self.program(); #[cfg(debug_assertions)] - println!("checking program"); check_constraints::( self, chip, @@ -317,7 +314,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("program checked"); quotients.push(quotient( self, config, @@ -335,7 +331,6 @@ impl Machine for BasicMachine { let chip = self.mem(); #[cfg(debug_assertions)] - println!("checking mem"); check_constraints::( self, chip, @@ -344,7 +339,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("mem checked"); quotients.push(quotient( self, config, @@ -361,7 +355,6 @@ impl Machine for BasicMachine { i += 1; let chip = self.add_u32(); - println!("checking add_u32"); #[cfg(debug_assertions)] check_constraints::( self, @@ -371,7 +364,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("add_u32 checked"); quotients.push(quotient( self, config, @@ -389,7 +381,6 @@ impl Machine for BasicMachine { let chip = self.sub_u32(); #[cfg(debug_assertions)] - println!("checking sub_u32"); check_constraints::( self, chip, @@ -398,7 +389,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("sub_u32 checked"); quotients.push(quotient( self, config, @@ -416,7 +406,6 @@ impl Machine for BasicMachine { let chip = self.mul_u32(); #[cfg(debug_assertions)] - println!("checking mul_u32"); check_constraints::( self, chip, @@ -425,7 +414,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("mul_u32 checked"); quotients.push(quotient( self, config, @@ -443,7 +431,6 @@ impl Machine for BasicMachine { let chip = self.div_u32(); #[cfg(debug_assertions)] - println!("checking div_u32"); check_constraints::( self, chip, @@ -452,7 +439,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("div_u32 checked"); quotients.push(quotient( self, config, @@ -470,7 +456,6 @@ impl Machine for BasicMachine { let chip = self.shift_u32(); #[cfg(debug_assertions)] - println!("checking shift_u32"); check_constraints::( self, chip, @@ -479,7 +464,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("shift_u32 checked"); quotients.push(quotient( self, config, @@ -497,7 +481,6 @@ impl Machine for BasicMachine { let chip = self.lt_u32(); #[cfg(debug_assertions)] - println!("checking lt_u32"); check_constraints::( self, chip, @@ -506,7 +489,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("lt_u32 checked"); quotients.push(quotient( self, config, @@ -524,7 +506,6 @@ impl Machine for BasicMachine { let chip = self.com_u32(); #[cfg(debug_assertions)] - println!("checking com_u32"); check_constraints::( self, chip, @@ -533,7 +514,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("com_u32 checked"); quotients.push(quotient( self, config, @@ -551,7 +531,6 @@ impl Machine for BasicMachine { let chip = self.bitwise_u32(); #[cfg(debug_assertions)] - println!("checking bitwise_u32"); check_constraints::( self, chip, @@ -560,7 +539,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("bitwise_u32 checked"); quotients.push(quotient( self, config, @@ -578,7 +556,6 @@ impl Machine for BasicMachine { let chip = self.output(); #[cfg(debug_assertions)] - println!("checking output"); check_constraints::( self, chip, @@ -587,7 +564,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("output checked"); quotients.push(quotient( self, config, @@ -605,7 +581,6 @@ impl Machine for BasicMachine { let chip = self.range(); #[cfg(debug_assertions)] - println!("checking range"); check_constraints::( self, chip, @@ -614,7 +589,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("range checked"); quotients.push(quotient( self, config, @@ -632,7 +606,6 @@ impl Machine for BasicMachine { let chip = self.static_data(); #[cfg(debug_assertions)] - println!("checking static data"); check_constraints::( self, chip, @@ -641,7 +614,6 @@ impl Machine for BasicMachine { &perm_challenges, &public_values[i], ); - println!("static data checked"); quotients.push(quotient( self, config, diff --git a/cpu/src/lib.rs b/cpu/src/lib.rs index 19317488..c17cd985 100644 --- a/cpu/src/lib.rs +++ b/cpu/src/lib.rs @@ -14,7 +14,7 @@ use valida_machine::is_mul_4; use valida_machine::ValidaPublicValues; use valida_machine::{ addr_of_word, index_of_byte, instructions, AdviceProvider, Chip, Instruction, InstructionWord, - Interaction, Operands, PublicRow, Word, + Interaction, Operands, Word, }; use valida_memory::{MachineWithMemoryChip, Operation as MemoryOperation}; use valida_opcodes::{ diff --git a/derive/src/lib.rs b/derive/src/lib.rs index 646883e4..3c10b5b9 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -250,6 +250,7 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { &main_traces[#i], &perm_traces[#i], &perm_challenges, + &public_values[#i], ); // TODO: Needlessly regenerating preprocessed_trace() @@ -264,13 +265,11 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { preprocessed_trace_lde, main_trace_ldes.remove(0), perm_trace_ldes.remove(0), + &public_values[#i], cumulative_sums[#i], &perm_challenges, alpha, )); - public_inputs.push(Chip::generate_public_inputs( - self.#chip_name() as &dyn Chip, - )); } }) .collect::(); @@ -286,13 +285,13 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { use ::valida_machine::__internal::p3_commit::{Pcs, UnivariatePcs, UnivariatePcsWithLde}; use ::valida_machine::__internal::p3_matrix::{Matrix, MatrixRowSlices, dense::RowMajorMatrix}; use ::valida_machine::__internal::p3_util::log2_strict_usize; - use ::valida_machine::{generate_permutation_trace, Chip, MachineProof, ChipProof, Commitments}; + use ::valida_machine::{generate_permutation_trace, Chip, MachineProof, ChipProof, Commitments, ValidaPublicValues}; use ::valida_machine::OpenedValues; use alloc::vec; use alloc::vec::Vec; use alloc::boxed::Box; - let mut chips: [Box<&dyn Chip>; #num_chips] = [ #chip_list ]; + let mut chips: [Box<&dyn Chip>>; #num_chips] = [ #chip_list ]; let log_quotient_degrees: [usize; #num_chips] = [ #quotient_degree_calls ]; let mut challenger = config.challenger(); @@ -322,6 +321,15 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { .try_into().unwrap() ); + let public_values: Vec<_> = + tracing::info_span!("generate public values") + .in_scope(|| + chips.par_iter() + .map(|chip| chip.generate_public_values()) + .collect::>() + .try_into().unwrap() + ); + let degrees: [usize; #num_chips] = main_traces.iter() .map(|trace| trace.height()) .collect::>() @@ -363,7 +371,6 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { let alpha: SC::Challenge = challenger.sample_ext_element(); let mut quotients: Vec> = vec![]; - let mut public_inputs: Vec)>> = vec![]; #compute_quotients assert_eq!(quotients.len(), #num_chips); assert_eq!(log_quotient_degrees.len(), #num_chips); @@ -413,8 +420,7 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { .zip(perm_openings) .zip(quotient_openings) .zip(perm_traces) - .zip(public_inputs) - .map(|(((((log_degree, main), perm), quotient), perm_trace), public_inputs)| { + .map(|((((log_degree, main), perm), quotient), perm_trace)| { // TODO: add preprocessed openings let [preprocessed_local, preprocessed_next] = [vec![], vec![]]; @@ -435,7 +441,6 @@ fn prove_method(chips: &[&Field]) -> TokenStream2 { let cumulative_sum = perm_trace.row_slice(perm_trace.height() - 1).last().unwrap().clone(); ChipProof { - public_inputs, log_degree: *log_degree, opened_values, cumulative_sum, @@ -479,11 +484,15 @@ fn verify_method(chips: &[&Field]) -> TokenStream2 { .enumerate() .map(|(i, chip)| { let chip_name = chip.ident.as_ref().unwrap(); + let chip_type = &chip.ty; quote! { + let chip = self.#chip_name(); + let public_values = <#chip_type as Chip>::generate_public_values(&chip); verify_constraints::( self, self.#chip_name(), &proof.chip_proofs[#i].opened_values, + &public_values, proof.chip_proofs[#i].cumulative_sum, proof.chip_proofs[#i].log_degree, g_subgroups[#i], @@ -509,7 +518,7 @@ fn verify_method(chips: &[&Field]) -> TokenStream2 { use ::valida_machine::__internal::p3_commit::{Pcs, UnivariatePcs, UnivariatePcsWithLde}; use ::valida_machine::__internal::p3_matrix::Dimensions; use ::valida_machine::__internal::p3_util::log2_strict_usize; - use ::valida_machine::{verify_constraints, MachineProof, ChipProof, Commitments}; + use ::valida_machine::{verify_constraints, MachineProof, ChipProof, Commitments, ValidaPublicValues}; use ::valida_machine::OpenedValues; use ::valida_machine::{VerificationError, ProofShapeError, OodEvaluationMismatch}; use alloc::vec; @@ -517,7 +526,7 @@ fn verify_method(chips: &[&Field]) -> TokenStream2 { use alloc::boxed::Box; - let mut chips: [Box<&dyn Chip>; #num_chips] = [ #chip_list ]; + let mut chips: [Box<&dyn Chip>>; #num_chips] = [ #chip_list ]; let log_quotient_degrees: [usize; #num_chips] = [ #quotient_degree_calls ]; let mut challenger = config.challenger(); // TODO: Seed challenger with digest of all constraints & trace lengths. diff --git a/machine/src/check_constraints.rs b/machine/src/check_constraints.rs index 330c7c31..443c0439 100644 --- a/machine/src/check_constraints.rs +++ b/machine/src/check_constraints.rs @@ -2,7 +2,6 @@ use crate::__internal::DebugConstraintBuilder; use crate::chip::eval_permutation_constraints; use valida_machine::StarkConfig; -use crate::public::PublicValues; use crate::{Chip, Machine}; use p3_air::TwoRowMatrixView; use p3_field::{AbstractField, Field}; diff --git a/machine/src/public.rs b/machine/src/public.rs index 844ab8e5..8aa54b8c 100644 --- a/machine/src/public.rs +++ b/machine/src/public.rs @@ -1,6 +1,6 @@ use alloc::slice; use core::iter::Cloned; -use p3_field::{AbstractExtensionField, AbstractField, ExtensionField, TwoAdicField}; +use p3_field::{ExtensionField, TwoAdicField}; use p3_interpolation; use p3_matrix::{ dense::{RowMajorMatrix, RowMajorMatrixView}, diff --git a/machine/src/quotient.rs b/machine/src/quotient.rs index 4da52be7..a02c3a06 100644 --- a/machine/src/quotient.rs +++ b/machine/src/quotient.rs @@ -1,6 +1,5 @@ use crate::__internal::ProverConstraintFolder; use crate::config::StarkConfig; -use crate::public::PublicValues; use crate::symbolic::symbolic_builder::get_log_quotient_degree; use crate::{eval_permutation_constraints, Chip, Machine}; use itertools::Itertools; diff --git a/memory/src/lib.rs b/memory/src/lib.rs index 0621be3c..e0a69f05 100644 --- a/memory/src/lib.rs +++ b/memory/src/lib.rs @@ -16,7 +16,6 @@ use p3_field::{AbstractField, Field, PrimeField}; use p3_matrix::dense::RowMajorMatrix; use p3_maybe_rayon::prelude::*; use valida_bus::MachineWithMemBus; -use valida_machine::PublicRow; use valida_machine::StarkConfig; use valida_machine::{Chip, Interaction, Machine, Word}; use valida_util::batch_multiplicative_inverse_allowing_zero; diff --git a/native_field/src/lib.rs b/native_field/src/lib.rs index 85669aeb..3fb772ee 100644 --- a/native_field/src/lib.rs +++ b/native_field/src/lib.rs @@ -9,7 +9,7 @@ use core::mem::transmute; use valida_bus::{MachineWithGeneralBus, MachineWithRangeBus8}; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, Word, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, Word, }; use valida_opcodes::{ADD, MUL, SUB}; use valida_range::MachineWithRangeChip; diff --git a/output/src/lib.rs b/output/src/lib.rs index 89bd8763..a4289652 100644 --- a/output/src/lib.rs +++ b/output/src/lib.rs @@ -4,7 +4,7 @@ use core::mem::transmute; use valida_bus::MachineWithGeneralBus; use valida_cpu::MachineWithCpuChip; use valida_machine::{ - instructions, Chip, Instruction, Interaction, Operands, PublicRow, ValidaPublicValues, + instructions, Chip, Instruction, Interaction, Operands, ValidaPublicValues, CPU_MEMORY_CHANNELS, MEMORY_CELL_BYTES, }; use valida_opcodes::WRITE; diff --git a/program/src/lib.rs b/program/src/lib.rs index 8865f64f..7ef7c919 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -2,13 +2,10 @@ extern crate alloc; -use core::mem::transmute; - use crate::columns::NUM_PROGRAM_COLS; use alloc::vec; use alloc::vec::Vec; use columns::{ProgramPreprocessedCols, NUM_PREPROCESSED_COLS}; -use p3_air::BaseAir; use valida_bus::MachineWithProgramBus; use valida_machine::{Chip, Interaction, Machine, ProgramROM, ValidaPublicValues}; use valida_util::pad_to_power_of_two; diff --git a/range/src/lib.rs b/range/src/lib.rs index 3be11026..455f4d14 100644 --- a/range/src/lib.rs +++ b/range/src/lib.rs @@ -14,7 +14,7 @@ use valida_machine::{Interaction, ValidaPublicValues}; use p3_air::VirtualPairCol; use p3_field::{AbstractField, Field}; use p3_matrix::dense::RowMajorMatrix; -use valida_machine::{PublicRow, StarkConfig}; +use valida_machine::StarkConfig; pub mod columns; pub mod stark;