From afff348e3494efe5857a6756fbb16a4a76abce5a Mon Sep 17 00:00:00 2001 From: Sai Deng Date: Wed, 17 Apr 2024 10:58:59 -0700 Subject: [PATCH 1/9] local plonky2 --- Cargo.lock | 21 ++++++++++++--------- Cargo.toml | 4 ++-- examples/Cargo.lock | 4 ---- sdk/Cargo.toml | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7864a6564..0ed9a23fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -944,7 +944,7 @@ dependencies = [ "mozak-runner", "mozak-sdk", "plonky2", - "plonky2_maybe_rayon", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", "proptest", "serde", "serde_json", @@ -1016,7 +1016,7 @@ dependencies = [ "itertools 0.12.1", "lazy_static", "plonky2", - "plonky2_maybe_rayon", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", ] [[package]] @@ -1169,7 +1169,6 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "plonky2" version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" dependencies = [ "ahash", "anyhow", @@ -1180,7 +1179,7 @@ dependencies = [ "log", "num", "plonky2_field", - "plonky2_maybe_rayon", + "plonky2_maybe_rayon 0.2.0", "plonky2_util", "rand", "rand_chacha", @@ -1200,7 +1199,7 @@ dependencies = [ "itertools 0.12.1", "num", "plonky2", - "plonky2_maybe_rayon", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", "rand", "rayon", "serde", @@ -1210,7 +1209,6 @@ dependencies = [ [[package]] name = "plonky2_field" version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" dependencies = [ "anyhow", "itertools 0.12.1", @@ -1222,6 +1220,13 @@ dependencies = [ "unroll", ] +[[package]] +name = "plonky2_maybe_rayon" +version = "0.2.0" +dependencies = [ + "rayon", +] + [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" @@ -1233,7 +1238,6 @@ dependencies = [ [[package]] name = "plonky2_util" version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" [[package]] name = "plotters" @@ -1699,7 +1703,6 @@ dependencies = [ [[package]] name = "starky" version = "0.3.0" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" dependencies = [ "ahash", "anyhow", @@ -1708,7 +1711,7 @@ dependencies = [ "log", "num-bigint", "plonky2", - "plonky2_maybe_rayon", + "plonky2_maybe_rayon 0.2.0", "plonky2_util", ] diff --git a/Cargo.toml b/Cargo.toml index a433270d1..1f4d98840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,6 @@ lto = "fat" lto = "thin" [patch.crates-io] -plonky2 = { git = "https://github.com/0xmozak/plonky2.git" } +plonky2 = { path = "../plonky2/plonky2" } plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git" } -starky = { git = "https://github.com/0xmozak/plonky2.git" } +starky = { path = "../plonky2/starky" } diff --git a/examples/Cargo.lock b/examples/Cargo.lock index a836f7b2a..6f434bb69 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -452,7 +452,6 @@ dependencies = [ [[package]] name = "plonky2" version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" dependencies = [ "ahash", "anyhow", @@ -474,7 +473,6 @@ dependencies = [ [[package]] name = "plonky2_field" version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" dependencies = [ "anyhow", "itertools", @@ -489,12 +487,10 @@ dependencies = [ [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" [[package]] name = "plonky2_util" version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" [[package]] name = "ppv-lite86" diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index aea61169a..22baf4d10 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -17,7 +17,7 @@ rkyv_derive = "=0.8.0-alpha.1" [target.'cfg(not(target_os="mozakvm"))'.dependencies] hex = "0.4" -plonky2 = { git = "https://github.com/0xmozak/plonky2.git", default-features = false } +plonky2 = { path = "../../plonky2/plonky2", default-features = false } rand = "0.8.5" rand_chacha = "0.3.1" serde = { version = "1.0", features = ["derive"] } From 2f7d4af39a6ee331c10c0db6a200c2770020813b Mon Sep 17 00:00:00 2001 From: Sai Deng Date: Wed, 17 Apr 2024 10:59:18 -0700 Subject: [PATCH 2/9] init --- circuits/src/stark/mozak_stark.rs | 2 +- circuits/src/stark/proof.rs | 1 + circuits/src/stark/prover.rs | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/circuits/src/stark/mozak_stark.rs b/circuits/src/stark/mozak_stark.rs index d78cc6939..d08f0d744 100644 --- a/circuits/src/stark/mozak_stark.rs +++ b/circuits/src/stark/mozak_stark.rs @@ -158,7 +158,7 @@ macro_rules! mozak_stark_helpers { } impl TableKind { - const COUNT: usize = $kind_count; + pub const COUNT: usize = $kind_count; } // Generate the set builder diff --git a/circuits/src/stark/proof.rs b/circuits/src/stark/proof.rs index 7adfefd96..8bed753bc 100644 --- a/circuits/src/stark/proof.rs +++ b/circuits/src/stark/proof.rs @@ -325,6 +325,7 @@ pub struct AllProof, C: GenericConfig, co pub mozak_memory_init_trace_cap: MerkleCap, pub public_inputs: PublicInputs, pub public_sub_table_values: TableKindArray>>, + // pub batch_fri_proof: FriProof, } pub(crate) struct AllProofChallenges, const D: usize> { diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 35110cca1..023f00deb 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -12,6 +12,7 @@ use plonky2::field::extension::Extendable; use plonky2::field::packable::Packable; use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; +use plonky2::fri::batch_oracle::BatchFriOracle; use plonky2::fri::oracle::PolynomialBatch; use plonky2::hash::hash_types::RichField; use plonky2::iop::challenger::Challenger; @@ -86,6 +87,27 @@ where let rate_bits = config.fri_config.rate_bits; let cap_height = config.fri_config.cap_height; + let mut degree_logs: Vec<_> = traces_poly_values.iter().map(|t| t.len()).collect(); + degree_logs.sort_unstable_by(|a, b| b.cmp(a)); + degree_logs.dedup(); + + let mut all_trace_polys: Vec<_> = traces_poly_values.iter().flat_map(|v| v.clone()).collect(); + all_trace_polys.sort_by(|a, b| b.len().cmp(&a.len())); + let all_trace_polys_len = all_trace_polys.len(); + + let batch_trace_commitments: BatchFriOracle = timed!( + timing, + "Compute trace commitments for all tables", + BatchFriOracle::from_values( + all_trace_polys, + rate_bits, + false, + cap_height, + timing, + &vec![None; all_trace_polys_len], + ) + ); + let trace_commitments = timed!( timing, "Compute trace commitments for each table", @@ -108,6 +130,8 @@ where }) ); + let trace_caps = batch_trace_commitments.field_merkle_tree.cap; + let trace_caps = trace_commitments .each_ref() .map(|c| c.merkle_tree.cap.clone()); From a5ccb39caf7c7ce0cdfd388f95cab68fc577f837 Mon Sep 17 00:00:00 2001 From: Sai Deng Date: Wed, 17 Apr 2024 16:26:10 -0700 Subject: [PATCH 3/9] compute batch trace commitments and batch ctl_zs commitments --- circuits/src/stark/prover.rs | 172 +++++++++++++++++++++++++++++++++-- 1 file changed, 163 insertions(+), 9 deletions(-) diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 023f00deb..00a23e796 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -14,6 +14,7 @@ use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; use plonky2::fri::batch_oracle::BatchFriOracle; use plonky2::fri::oracle::PolynomialBatch; +use plonky2::fri::proof::FriProof; use plonky2::hash::hash_types::RichField; use plonky2::iop::challenger::Challenger; use plonky2::plonk::config::GenericConfig; @@ -31,7 +32,7 @@ use crate::cross_table_lookup::ctl_utils::debug_ctl; use crate::cross_table_lookup::{cross_table_lookup_data, CtlData}; use crate::generation::{debug_traces, generate_traces}; use crate::public_sub_table::public_sub_table_data_and_values; -use crate::stark::mozak_stark::{all_starks, PublicInputs}; +use crate::stark::mozak_stark::{all_kind, all_starks, PublicInputs}; use crate::stark::permutation::challenge::GrandProductChallengeTrait; use crate::stark::poly::compute_quotient_polys; @@ -87,24 +88,62 @@ where let rate_bits = config.fri_config.rate_bits; let cap_height = config.fri_config.cap_height; - let mut degree_logs: Vec<_> = traces_poly_values.iter().map(|t| t.len()).collect(); + // We cannot batch prove these tables because trace caps are needed as public + // inputs for the following tables. + let public_table_kinds = vec![ + TableKind::Program, + TableKind::ElfMemoryInit, + TableKind::MozakMemoryInit, + ]; + + let separate_trace_commitments = timed!( + timing, + "Compute trace commitments for separate tables", + all_kind!(|kind| if public_table_kinds.contains(&kind) { + Some(PolynomialBatch::::from_values( + traces_poly_values[kind].clone(), + rate_bits, + false, + cap_height, + timing, + None, + )) + } else { + None + }) + ); + + let mut batch_traces_poly_values = all_kind!(|kind| if public_table_kinds.contains(&kind) { + None + } else { + Some(&traces_poly_values[kind]) + }); + let mut degree_logs: Vec = batch_traces_poly_values + .iter() + .filter_map(|t| *t) + .map(|t| t.len()) + .collect(); degree_logs.sort_unstable_by(|a, b| b.cmp(a)); degree_logs.dedup(); - let mut all_trace_polys: Vec<_> = traces_poly_values.iter().flat_map(|v| v.clone()).collect(); - all_trace_polys.sort_by(|a, b| b.len().cmp(&a.len())); - let all_trace_polys_len = all_trace_polys.len(); + let mut batch_trace_polys: Vec<_> = batch_traces_poly_values + .iter() + .filter_map(|t| *t) + .flat_map(|v| v.clone()) + .collect(); + batch_trace_polys.sort_by(|a, b| b.len().cmp(&a.len())); + let bacth_trace_polys_len = batch_trace_polys.len(); let batch_trace_commitments: BatchFriOracle = timed!( timing, - "Compute trace commitments for all tables", + "Compute trace commitments for batch tables", BatchFriOracle::from_values( - all_trace_polys, + batch_trace_polys, rate_bits, false, cap_height, timing, - &vec![None; all_trace_polys_len], + &vec![None; bacth_trace_polys_len], ) ); @@ -130,7 +169,8 @@ where }) ); - let trace_caps = batch_trace_commitments.field_merkle_tree.cap; + // TODO: todo + // let trace_caps = batch_trace_commitments.field_merkle_tree.cap; let trace_caps = trace_commitments .each_ref() @@ -397,6 +437,120 @@ where })) } +/// Given the traces generated from [`generate_traces`] along with their +/// commitments, prove a [`MozakStark`]. +/// +/// # Errors +/// Errors if proving fails. +#[allow(clippy::too_many_arguments)] +pub fn batch_prove_with_commitments( + mozak_stark: &MozakStark, + config: &StarkConfig, + public_table_kinds: &[TableKind], + public_inputs: &PublicInputs, + trace_commitments: &TableKindArray>, + traces_poly_values: &TableKindArray>>, + batch_trace_commitments: &BatchFriOracle, + separate_trace_commitments: &TableKindArray>, + ctl_data_per_table: &TableKindArray>, + public_sub_data_per_table: &TableKindArray>, + challenger: &mut Challenger, + timing: &mut TimingTree, +) -> Result>> +where + F: RichField + Extendable, + C: GenericConfig, { + let rate_bits = config.fri_config.rate_bits; + let cap_height = config.fri_config.cap_height; + + let cpu_stark = [public_inputs.entry_point]; + let public_inputs = TableKindSetBuilder::<&[_]> { + cpu_stark: &cpu_stark, + ..Default::default() + } + .build(); + + let separate_proofs = all_starks!(mozak_stark, |stark, kind| if public_table_kinds + .contains(&kind) + { + Some(prove_single_table( + stark, + config, + &traces_poly_values[kind], + &separate_trace_commitments[kind], + public_inputs[kind], + &ctl_data_per_table[kind], + &public_sub_data_per_table[kind], + challenger, + timing, + )?) + } else { + None + }); + + // TODO: we can remove duplicates in the ctl polynomials. + let batch_ctl_polys = all_kind!(|kind| { + if public_table_kinds.contains(&kind) { + None + } else { + let degree = traces_poly_values[kind][0].len(); + let degree_bits = log2_strict(degree); + let fri_params = config.fri_params(degree_bits); + assert!( + fri_params.total_arities() <= degree_bits + rate_bits - cap_height, + "FRI total reduction arity is too large.", + ); + + let z_poly_public_sub_table = ctl_data_per_table[kind].z_polys(); + + let z_polys = vec![ctl_data_per_table[kind].z_polys(), z_poly_public_sub_table] + .into_iter() + .flatten() + .collect_vec(); + + // TODO(Matthias): make the code work with empty z_polys, too. + assert!(!z_polys.is_empty()); + + Some(z_polys) + } + }); + + let mut batch_ctl_zs_polys: Vec<_> = batch_ctl_polys + .iter() + .filter_map(|t| t.as_ref()) + .flat_map(|v| v.iter().cloned()) + .collect(); + batch_ctl_zs_polys.sort_by(|a, b| b.len().cmp(&a.len())); + let batch_ctl_zs_polys_len = batch_ctl_zs_polys.len(); + + let batch_ctl_zs_commitments: BatchFriOracle = timed!( + timing, + "compute batch Zs commitment", + BatchFriOracle::from_values( + batch_ctl_zs_polys, + rate_bits, + false, + config.fri_config.cap_height, + timing, + &vec![None; batch_ctl_zs_polys_len], + ) + ); + + Ok(all_starks!(mozak_stark, |stark, kind| { + prove_single_table( + stark, + config, + &traces_poly_values[kind], + &trace_commitments[kind], + public_inputs[kind], + &ctl_data_per_table[kind], + &public_sub_data_per_table[kind], + challenger, + timing, + )? + })) +} + #[cfg(test)] mod tests { From 94074e0be620d2228525b856a7818405f394692c Mon Sep 17 00:00:00 2001 From: Sai Deng Date: Wed, 17 Apr 2024 20:37:57 -0700 Subject: [PATCH 4/9] wip --- circuits/src/stark/mozak_stark.rs | 2 +- circuits/src/stark/prover.rs | 52 +++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/circuits/src/stark/mozak_stark.rs b/circuits/src/stark/mozak_stark.rs index 871d0bed8..767c7e398 100644 --- a/circuits/src/stark/mozak_stark.rs +++ b/circuits/src/stark/mozak_stark.rs @@ -158,7 +158,7 @@ macro_rules! mozak_stark_helpers { } impl TableKind { - pub const COUNT: usize = $kind_count; + const COUNT: usize = $kind_count; } // Generate the set builder diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 00a23e796..055dcf02e 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -488,8 +488,7 @@ where None }); - // TODO: we can remove duplicates in the ctl polynomials. - let batch_ctl_polys = all_kind!(|kind| { + let batch_ctl_z_polys = all_kind!(|kind| { if public_table_kinds.contains(&kind) { None } else { @@ -515,7 +514,8 @@ where } }); - let mut batch_ctl_zs_polys: Vec<_> = batch_ctl_polys + // TODO: we can remove duplicates in the ctl polynomials. + let mut batch_ctl_zs_polys: Vec<_> = batch_ctl_z_polys .iter() .filter_map(|t| t.as_ref()) .flat_map(|v| v.iter().cloned()) @@ -536,6 +536,52 @@ where ) ); + let ctl_zs_commitments = all_starks!(mozak_stark, |stark, kind| timed!( + timing, + format!("{stark}: compute Zs commitment").as_str(), + if let Some(poly) = &batch_ctl_z_polys[kind] { + Some(PolynomialBatch::::from_values( + poly.clone(), + rate_bits, + false, + config.fri_config.cap_height, + timing, + None, + )) + } else { + None + } + )); + + let ctl_zs_cap = batch_ctl_zs_commitments.field_merkle_tree.cap.clone(); + challenger.observe_cap(&ctl_zs_cap); + + let alphas = challenger.get_n_challenges(config.num_challenges); + + let batch_quotient_polys = all_starks!(mozak_stark, |stark, kind| { + if let Some(ctl_zs_commitment) = ctl_zs_commitments[kind] { + let degree = traces_poly_values[kind][0].len(); + let degree_bits = log2_strict(degree); + timed!( + timing, + format!("{stark}: compute quotient polynomial").as_str(), + Some(compute_quotient_polys::::Packing, C, S, D>( + stark, + &trace_commitments[kind], + &ctl_zs_commitment, + public_inputs[kind], + &ctl_data_per_table[kind], + &public_sub_data_per_table[kind], + &alphas, + degree_bits, + config, + )) + ) + } else { + None + } + }); + Ok(all_starks!(mozak_stark, |stark, kind| { prove_single_table( stark, From ffa1ff178252aeb61d50b53f6ca4557c731282dc Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 18 Apr 2024 20:30:52 +0800 Subject: [PATCH 5/9] Foo --- circuits/src/stark/prover.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 055dcf02e..2ca0acfbe 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -443,6 +443,7 @@ where /// # Errors /// Errors if proving fails. #[allow(clippy::too_many_arguments)] +#[allow(clippy::similar_names)] pub fn batch_prove_with_commitments( mozak_stark: &MozakStark, config: &StarkConfig, @@ -565,7 +566,7 @@ where timed!( timing, format!("{stark}: compute quotient polynomial").as_str(), - Some(compute_quotient_polys::::Packing, C, S, D>( + Some(compute_quotient_polys::::Packing, C, _, D>( stark, &trace_commitments[kind], &ctl_zs_commitment, From 0983c73093b41cdd870ca80f48f7dd650a4a467d Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 18 Apr 2024 20:42:38 +0800 Subject: [PATCH 6/9] Stuff --- Cargo.lock | 341 ++++++++++++++++++++++++++--------- Cargo.toml | 15 +- circuits/Cargo.toml | 6 +- circuits/src/stark/prover.rs | 5 +- cli/Cargo.toml | 4 +- examples/Cargo.lock | 61 ++----- expr/Cargo.toml | 2 +- node/Cargo.toml | 4 +- recproofs/Cargo.toml | 4 +- runner/Cargo.toml | 2 +- signatures/Cargo.toml | 4 +- wasm-demo/Cargo.toml | 2 +- 12 files changed, 289 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01b4aaad8..c90eb28a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,9 +26,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -209,9 +209,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -221,9 +221,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -302,7 +302,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -484,7 +484,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 2.0.60", ] [[package]] @@ -495,7 +495,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -526,7 +526,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn", + "syn 2.0.60", "unicode-xid", ] @@ -542,9 +542,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "elf" @@ -569,7 +569,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -625,6 +625,15 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "static_assertions", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -813,6 +822,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -846,13 +864,23 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2bd4c29270e724d3eaadf7bdc8700af4221fc0ed771b855eadcd1b98d52851" +dependencies = [ + "primitive-types 0.10.1", + "tiny-keccak", +] + [[package]] name = "keccak-hash" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b286e6b663fb926e1eeb68528e69cb70ed46c6d65871a21b2215ae8154c6d3c" dependencies = [ - "primitive-types", + "primitive-types 0.12.2", "tiny-keccak", ] @@ -943,8 +971,8 @@ dependencies = [ "mozak-circuits-derive", "mozak-runner", "mozak-sdk", - "plonky2", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", + "plonky2 0.2.1", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", "proptest", "serde", "serde_json", @@ -961,7 +989,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -981,7 +1009,7 @@ dependencies = [ "mozak-node", "mozak-runner", "mozak-sdk", - "plonky2", + "plonky2 0.2.1", "proptest", "rkyv", "rkyv_derive", @@ -1002,7 +1030,7 @@ dependencies = [ "mozak-circuits", "mozak-recproofs", "mozak-sdk", - "plonky2", + "plonky2 0.2.1", "serde", ] @@ -1016,8 +1044,8 @@ dependencies = [ "iter_fixed", "itertools 0.12.1", "lazy_static", - "plonky2", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", + "plonky2 0.2.1", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", ] [[package]] @@ -1040,7 +1068,7 @@ dependencies = [ "mimalloc", "mozak-examples", "mozak-sdk", - "plonky2", + "plonky2 0.2.1", "proptest", "serde", "serde_json", @@ -1054,7 +1082,7 @@ dependencies = [ "hex", "itertools 0.12.1", "once_cell", - "plonky2", + "plonky2 0.2.2", "rand", "rand_chacha", "rkyv", @@ -1170,23 +1198,69 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "plonky2" version = "0.2.1" +source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" dependencies = [ "ahash", "anyhow", "getrandom", "hashbrown 0.14.3", "itertools 0.12.1", - "keccak-hash", + "keccak-hash 0.10.0", "log", "num", - "plonky2_field", + "plonky2_field 0.2.1", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "rand", + "serde", + "static_assertions", + "unroll 0.2.0", + "web-time", +] + +[[package]] +name = "plonky2" +version = "0.2.2" +dependencies = [ + "ahash", + "anyhow", + "getrandom", + "hashbrown 0.14.3", + "itertools 0.12.1", + "log", + "num", + "plonky2_field 0.2.2", "plonky2_maybe_rayon 0.2.0", - "plonky2_util", + "plonky2_util 0.2.0", + "rand", + "serde", + "static_assertions", + "tiny-keccak", + "unroll 0.2.0", +] + +[[package]] +name = "plonky2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85f26b090b989aebdeaf6a4eed748c1fbcabf67e7273a22e4e0c877b63846d0f" +dependencies = [ + "ahash", + "anyhow", + "getrandom", + "hashbrown 0.14.3", + "itertools 0.11.0", + "keccak-hash 0.8.0", + "log", + "num", + "plonky2_field 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plonky2_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand", "rand_chacha", "serde", "static_assertions", - "unroll", + "unroll 0.1.5", "web-time", ] @@ -1199,8 +1273,8 @@ dependencies = [ "hex", "itertools 0.12.1", "num", - "plonky2", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git)", + "plonky2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand", "rayon", "serde", @@ -1210,20 +1284,57 @@ dependencies = [ [[package]] name = "plonky2_field" version = "0.2.1" +source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" dependencies = [ "anyhow", "itertools 0.12.1", "num", - "plonky2_util", + "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", "rand", "serde", "static_assertions", - "unroll", + "unroll 0.2.0", ] +[[package]] +name = "plonky2_field" +version = "0.2.2" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "num", + "plonky2_util 0.2.0", + "rand", + "serde", + "static_assertions", + "unroll 0.2.0", +] + +[[package]] +name = "plonky2_field" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a1dca60ad900d81b1fe2df3d0b88d43345988e2935e6709176e96573f4bcf5d" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "num", + "plonky2_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand", + "serde", + "static_assertions", + "unroll 0.1.5", +] + +[[package]] +name = "plonky2_maybe_rayon" +version = "0.2.0" + [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ff44a90aaca13e10e7ddf8fab815ba1b404c3f7c3ca82aaf11c46beabaa923" dependencies = [ "rayon", ] @@ -1231,7 +1342,7 @@ dependencies = [ [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git#e4d5110fb3c8041f771e48f1a2e61b423fdccdbc" +source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" dependencies = [ "rayon", ] @@ -1240,6 +1351,17 @@ dependencies = [ name = "plonky2_util" version = "0.2.0" +[[package]] +name = "plonky2_util" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16136f5f3019c1e83035af76cccddd56d789a5e2933306270185c3f99f12259" + +[[package]] +name = "plonky2_util" +version = "0.2.0" +source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" + [[package]] name = "plotters" version = "0.3.5" @@ -1280,13 +1402,23 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "primitive-types" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +dependencies = [ + "fixed-hash 0.7.0", + "uint", +] + [[package]] name = "primitive-types" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ - "fixed-hash", + "fixed-hash 0.8.0", "uint", ] @@ -1298,7 +1430,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 2.0.60", "version_check", ] @@ -1314,9 +1446,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -1358,7 +1490,7 @@ checksum = "bb26b4ec087a56688b4dddd8c7bbed38ad1867042ba6e1314162e5b370edaaac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -1369,9 +1501,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1517,7 +1649,7 @@ checksum = "5d936536583355d1ef18b9473dbe2a59d0c9ffff278a92c171feb30f2489dd0a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -1562,9 +1694,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] @@ -1582,20 +1714,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -1638,7 +1770,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -1673,7 +1805,7 @@ dependencies = [ "itertools 0.12.1", "log", "num", - "plonky2", + "plonky2 0.2.1", "plonky2_crypto", "rand", "serde", @@ -1704,6 +1836,7 @@ dependencies = [ [[package]] name = "starky" version = "0.3.0" +source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" dependencies = [ "ahash", "anyhow", @@ -1711,9 +1844,9 @@ dependencies = [ "itertools 0.12.1", "log", "num-bigint", - "plonky2", - "plonky2_maybe_rayon 0.2.0", - "plonky2_util", + "plonky2 0.2.1", + "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", ] [[package]] @@ -1743,9 +1876,20 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.58" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -1788,7 +1932,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -1799,7 +1943,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", "test-case-core", ] @@ -1820,14 +1964,14 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -1846,9 +1990,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -1985,13 +2129,23 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unroll" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ad948c1cb799b1a70f836077721a92a35ac177d4daddf4c20a633786d4cf618" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "unroll" version = "0.2.0" source = "git+https://github.com/0xmozak/unroll.git#1602aa5cd0b9babacb883ae369389444071f0402" dependencies = [ "quote", - "syn", + "syn 2.0.60", ] [[package]] @@ -2052,7 +2206,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -2074,7 +2228,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2182,17 +2336,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -2203,9 +2358,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -2215,9 +2370,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -2227,9 +2382,15 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -2239,9 +2400,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -2251,9 +2412,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -2263,9 +2424,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -2275,15 +2436,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] @@ -2314,5 +2475,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.60", ] diff --git a/Cargo.toml b/Cargo.toml index 789f8d778..efe748f15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,14 @@ lto = "fat" lto = "thin" opt-level = 3 -[patch.crates-io] -plonky2 = { path = "../plonky2/plonky2" } -plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git" } -starky = { path = "../plonky2/starky" } +[workspace.dependencies] +plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } +plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } +starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } + +plonky2_crypto = { git = "https://github.com/0xmozak/plonky2-crypto.git" } + +# [patch.crates-io] +# plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } +# plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } +# starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } diff --git a/circuits/Cargo.toml b/circuits/Cargo.toml index 2736f351c..ddd9d0e71 100644 --- a/circuits/Cargo.toml +++ b/circuits/Cargo.toml @@ -20,11 +20,11 @@ log = "0.4" mozak-circuits-derive = { path = "./derive" } mozak-runner = { path = "../runner" } mozak-sdk = { path = "../sdk" } -plonky2 = { version = "0", default-features = false } -plonky2_maybe_rayon = { version = "0", default-features = false } +plonky2 = { workspace = true, default-features = false } +plonky2_maybe_rayon = { workspace = true, default-features = false } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -starky = { version = "0", default-features = false, features = ["std"] } +starky = { workspace = true, default-features = false, features = ["std"] } thiserror = "1.0" tt-call = "1.0" diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 2ca0acfbe..1ebd8f550 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -123,7 +123,8 @@ where .filter_map(|t| *t) .map(|t| t.len()) .collect(); - degree_logs.sort_unstable_by(|a, b| b.cmp(a)); + degree_logs.sort(); + degree_logs.reverse(); degree_logs.dedup(); let mut batch_trace_polys: Vec<_> = batch_traces_poly_values @@ -560,7 +561,7 @@ where let alphas = challenger.get_n_challenges(config.num_challenges); let batch_quotient_polys = all_starks!(mozak_stark, |stark, kind| { - if let Some(ctl_zs_commitment) = ctl_zs_commitments[kind] { + if let Some(ctl_zs_commitment) = ctl_zs_commitments[kind].as_ref() { let degree = traces_poly_values[kind][0].len(); let degree_bits = log2_strict(degree); timed!( diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9d6f3022b..db68aea19 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -30,11 +30,11 @@ env_logger = "0.11" itertools = "0.12" log = "0.4" mozak-examples = { path = "../examples-builder", features = ["mozak-sort"] } -plonky2 = { version = "0", default-features = false } +plonky2 = { workspace = true, default-features = false } rkyv = { version = "=0.8.0-alpha.1", default-features = false, features = ["pointer_width_32", "alloc"] } rkyv_derive = "=0.8.0-alpha.1" serde_json = "1.0" -starky = { version = "0", default-features = false } +starky = { workspace = true, default-features = false } tempfile = "3" [dev-dependencies] diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 6f434bb69..b90408eaf 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -76,12 +76,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "cfg-if" version = "1.0.0" @@ -169,15 +163,6 @@ dependencies = [ "mozak-sdk", ] -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "static_assertions", -] - [[package]] name = "funty" version = "2.0.0" @@ -287,16 +272,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "keccak-hash" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b286e6b663fb926e1eeb68528e69cb70ed46c6d65871a21b2215ae8154c6d3c" -dependencies = [ - "primitive-types", - "tiny-keccak", -] - [[package]] name = "libc" version = "0.2.153" @@ -353,6 +328,14 @@ dependencies = [ "toml", ] +[[package]] +name = "mozak-sort" +version = "0.1.0" +dependencies = [ + "mozak-sdk", + "rand", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -451,14 +434,13 @@ dependencies = [ [[package]] name = "plonky2" -version = "0.2.1" +version = "0.2.2" dependencies = [ "ahash", "anyhow", "getrandom", "hashbrown", "itertools", - "keccak-hash", "log", "num", "plonky2_field", @@ -467,12 +449,13 @@ dependencies = [ "rand", "serde", "static_assertions", + "tiny-keccak", "unroll", ] [[package]] name = "plonky2_field" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "itertools", @@ -498,16 +481,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "uint", -] - [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -829,18 +802,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-ident" version = "1.0.12" diff --git a/expr/Cargo.toml b/expr/Cargo.toml index 51440523e..956d5038e 100644 --- a/expr/Cargo.toml +++ b/expr/Cargo.toml @@ -11,4 +11,4 @@ version = "0.1.0" [dependencies] bumpalo = "3.14" -starky = { version = "0", default-features = false, features = ["std"] } +starky = { workspace = true, default-features = false, features = ["std"] } diff --git a/node/Cargo.toml b/node/Cargo.toml index f5e73a5d0..a47874363 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -10,13 +10,11 @@ license = "All rights reserved" readme = "README.md" repository = "https://github.com/0xmozak/mozak-node" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] itertools = "0.12" mozak-recproofs = { path = '../recproofs' } mozak-sdk = { path = '../sdk' } -plonky2 = "0" +plonky2 = { workspace = true, default-features = false } serde = { version = "1.0", features = ["derive"] } [dev-dependencies] diff --git a/recproofs/Cargo.toml b/recproofs/Cargo.toml index fe81423b0..5f024f191 100644 --- a/recproofs/Cargo.toml +++ b/recproofs/Cargo.toml @@ -14,8 +14,8 @@ anyhow = { version = "1.0", default-features = false } enumflags2 = "0.7" iter_fixed = "0.3" itertools = "0.12" -plonky2 = { version = "0", default-features = false } -plonky2_maybe_rayon = { version = "0", default-features = false } +plonky2 = { workspace = true, default-features = false } +plonky2_maybe_rayon = { workspace = true, default-features = false } [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] } diff --git a/runner/Cargo.toml b/runner/Cargo.toml index b13358277..8d1e74cb1 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -19,7 +19,7 @@ im = "15.1" itertools = "0.12" log = "0.4" mozak-sdk = { path = "../sdk" } -plonky2 = { version = "0", default-features = false } +plonky2 = { workspace = true, default-features = false } proptest = { version = "1.4", optional = true } serde = { version = "1.0", features = ["derive"] } diff --git a/signatures/Cargo.toml b/signatures/Cargo.toml index 1085840f7..0ee961579 100644 --- a/signatures/Cargo.toml +++ b/signatures/Cargo.toml @@ -17,8 +17,8 @@ hex = "0.4" itertools = "0.12" log = "0.4" num = "0.4" -plonky2 = "0" -plonky2_crypto = { git = "https://github.com/0xmozak/plonky2-crypto.git" } +plonky2 = { workspace = true, default-features = false } +plonky2_crypto = { workspace = true } serde = "1.0.197" sha2 = "0.10" sha3 = "0.10" diff --git a/wasm-demo/Cargo.toml b/wasm-demo/Cargo.toml index e20058cbb..734c309ad 100644 --- a/wasm-demo/Cargo.toml +++ b/wasm-demo/Cargo.toml @@ -18,5 +18,5 @@ crate-type = ["cdylib", "rlib"] console_error_panic_hook = "0.1" mozak-circuits = { path = "../circuits", features = ["test"] } mozak-runner = { path = "../runner" } -starky = { version = "0", features = ["std"] } +starky = { workspace = true, features = ["std"] } wasm-bindgen = "0.2" From 8060966fd880d1806db7b7020a8b6eb795c72401 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 18 Apr 2024 21:01:07 +0800 Subject: [PATCH 7/9] Syn under control --- Cargo.lock | 296 ++++++++----------------------------------------- Cargo.toml | 16 +-- sdk/Cargo.toml | 2 +- 3 files changed, 56 insertions(+), 258 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c97a085a6..04d3e9a0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,12 +195,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "cast" version = "0.3.0" @@ -302,7 +296,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -484,7 +478,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.60", + "syn", ] [[package]] @@ -495,7 +489,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -526,7 +520,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.60", + "syn", "unicode-xid", ] @@ -569,7 +563,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -625,24 +619,6 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "static_assertions", -] - [[package]] name = "fnv" version = "1.0.7" @@ -822,15 +798,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -864,26 +831,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "keccak-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2bd4c29270e724d3eaadf7bdc8700af4221fc0ed771b855eadcd1b98d52851" -dependencies = [ - "primitive-types 0.10.1", - "tiny-keccak", -] - -[[package]] -name = "keccak-hash" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b286e6b663fb926e1eeb68528e69cb70ed46c6d65871a21b2215ae8154c6d3c" -dependencies = [ - "primitive-types 0.12.2", - "tiny-keccak", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -971,8 +918,8 @@ dependencies = [ "mozak-circuits-derive", "mozak-runner", "mozak-sdk", - "plonky2 0.2.1", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "plonky2", + "plonky2_maybe_rayon", "proptest", "rand", "serde", @@ -990,7 +937,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1010,7 +957,7 @@ dependencies = [ "mozak-node", "mozak-runner", "mozak-sdk", - "plonky2 0.2.1", + "plonky2", "proptest", "rkyv", "rkyv_derive", @@ -1031,7 +978,7 @@ dependencies = [ "mozak-circuits", "mozak-recproofs", "mozak-sdk", - "plonky2 0.2.1", + "plonky2", "serde", ] @@ -1045,8 +992,8 @@ dependencies = [ "iter_fixed", "itertools 0.12.1", "lazy_static", - "plonky2 0.2.1", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "plonky2", + "plonky2_maybe_rayon", ] [[package]] @@ -1069,7 +1016,7 @@ dependencies = [ "mimalloc", "mozak-examples", "mozak-sdk", - "plonky2 0.2.1", + "plonky2", "proptest", "serde", "serde_json", @@ -1083,7 +1030,7 @@ dependencies = [ "hex", "itertools 0.12.1", "once_cell", - "plonky2 0.2.2", + "plonky2", "rand", "rand_chacha", "rkyv", @@ -1196,32 +1143,10 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "plonky2" -version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" -dependencies = [ - "ahash", - "anyhow", - "getrandom", - "hashbrown 0.14.3", - "itertools 0.12.1", - "keccak-hash 0.10.0", - "log", - "num", - "plonky2_field 0.2.1", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", - "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", - "rand", - "serde", - "static_assertions", - "unroll 0.2.0", - "web-time", -] - [[package]] name = "plonky2" version = "0.2.2" +source = "git+https://github.com/0xmozak/plonky2.git?branch=matthias/sai/add_batch_fri#7d053980f33284de674114862c4348052eed05d1" dependencies = [ "ahash", "anyhow", @@ -1230,120 +1155,54 @@ dependencies = [ "itertools 0.12.1", "log", "num", - "plonky2_field 0.2.2", - "plonky2_maybe_rayon 0.2.0", - "plonky2_util 0.2.0", - "rand", - "serde", - "static_assertions", - "tiny-keccak", - "unroll 0.2.0", -] - -[[package]] -name = "plonky2" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f26b090b989aebdeaf6a4eed748c1fbcabf67e7273a22e4e0c877b63846d0f" -dependencies = [ - "ahash", - "anyhow", - "getrandom", - "hashbrown 0.14.3", - "itertools 0.11.0", - "keccak-hash 0.8.0", - "log", - "num", - "plonky2_field 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "plonky2_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plonky2_field", + "plonky2_maybe_rayon", + "plonky2_util", "rand", "rand_chacha", "serde", "static_assertions", - "unroll 0.1.5", + "tiny-keccak", + "unroll", "web-time", ] [[package]] name = "plonky2_crypto" version = "0.1.0" -source = "git+https://github.com/0xmozak/plonky2-crypto.git#49b2ea39eff2776e9c1c903ce4ca36c19a55d998" +source = "git+https://github.com/0xmozak/plonky2-crypto.git#a9389c98fc53e07fd103a814377699524f0b1bd5" dependencies = [ "anyhow", "hex", "itertools 0.12.1", "num", - "plonky2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plonky2_maybe_rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plonky2", + "plonky2_maybe_rayon", "rand", "rayon", "serde", "serde_with", ] -[[package]] -name = "plonky2_field" -version = "0.2.1" -source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" -dependencies = [ - "anyhow", - "itertools 0.12.1", - "num", - "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", - "rand", - "serde", - "static_assertions", - "unroll 0.2.0", -] - [[package]] name = "plonky2_field" version = "0.2.2" +source = "git+https://github.com/0xmozak/plonky2.git?branch=matthias/sai/add_batch_fri#7d053980f33284de674114862c4348052eed05d1" dependencies = [ "anyhow", "itertools 0.12.1", "num", - "plonky2_util 0.2.0", + "plonky2_util", "rand", "serde", "static_assertions", - "unroll 0.2.0", -] - -[[package]] -name = "plonky2_field" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1dca60ad900d81b1fe2df3d0b88d43345988e2935e6709176e96573f4bcf5d" -dependencies = [ - "anyhow", - "itertools 0.11.0", - "num", - "plonky2_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand", - "serde", - "static_assertions", - "unroll 0.1.5", -] - -[[package]] -name = "plonky2_maybe_rayon" -version = "0.2.0" - -[[package]] -name = "plonky2_maybe_rayon" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ff44a90aaca13e10e7ddf8fab815ba1b404c3f7c3ca82aaf11c46beabaa923" -dependencies = [ - "rayon", + "unroll", ] [[package]] name = "plonky2_maybe_rayon" version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" +source = "git+https://github.com/0xmozak/plonky2.git?branch=matthias/sai/add_batch_fri#7d053980f33284de674114862c4348052eed05d1" dependencies = [ "rayon", ] @@ -1351,17 +1210,7 @@ dependencies = [ [[package]] name = "plonky2_util" version = "0.2.0" - -[[package]] -name = "plonky2_util" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16136f5f3019c1e83035af76cccddd56d789a5e2933306270185c3f99f12259" - -[[package]] -name = "plonky2_util" -version = "0.2.0" -source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" +source = "git+https://github.com/0xmozak/plonky2.git?branch=matthias/sai/add_batch_fri#7d053980f33284de674114862c4348052eed05d1" [[package]] name = "plotters" @@ -1403,26 +1252,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "primitive-types" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" -dependencies = [ - "fixed-hash 0.7.0", - "uint", -] - -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash 0.8.0", - "uint", -] - [[package]] name = "proc-macro-error" version = "2.0.0" @@ -1431,7 +1260,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn 2.0.60", + "syn", "version_check", ] @@ -1491,7 +1320,7 @@ checksum = "bb26b4ec087a56688b4dddd8c7bbed38ad1867042ba6e1314162e5b370edaaac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1650,7 +1479,7 @@ checksum = "5d936536583355d1ef18b9473dbe2a59d0c9ffff278a92c171feb30f2489dd0a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1721,7 +1550,7 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1771,7 +1600,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1806,7 +1635,7 @@ dependencies = [ "itertools 0.12.1", "log", "num", - "plonky2 0.2.1", + "plonky2", "plonky2_crypto", "rand", "serde", @@ -1836,8 +1665,8 @@ dependencies = [ [[package]] name = "starky" -version = "0.3.0" -source = "git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri#c2168c5e42a75ff4bc8c63948706fd6c80d3d323" +version = "0.4.0" +source = "git+https://github.com/0xmozak/plonky2.git?branch=matthias/sai/add_batch_fri#7d053980f33284de674114862c4348052eed05d1" dependencies = [ "ahash", "anyhow", @@ -1845,9 +1674,9 @@ dependencies = [ "itertools 0.12.1", "log", "num-bigint", - "plonky2 0.2.1", - "plonky2_maybe_rayon 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", - "plonky2_util 0.2.0 (git+https://github.com/0xmozak/plonky2.git?branch=sai/add_batch_fri)", + "plonky2", + "plonky2_maybe_rayon", + "plonky2_util", ] [[package]] @@ -1875,17 +1704,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.60" @@ -1933,7 +1751,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -1944,7 +1762,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", "test-case-core", ] @@ -1965,7 +1783,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -2079,18 +1897,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unarray" version = "0.1.4" @@ -2130,23 +1936,13 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "unroll" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad948c1cb799b1a70f836077721a92a35ac177d4daddf4c20a633786d4cf618" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "unroll" version = "0.2.0" source = "git+https://github.com/0xmozak/unroll.git#1602aa5cd0b9babacb883ae369389444071f0402" dependencies = [ "quote", - "syn 2.0.60", + "syn", ] [[package]] @@ -2207,7 +2003,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn", "wasm-bindgen-shared", ] @@ -2229,7 +2025,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2476,5 +2272,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn", ] diff --git a/Cargo.toml b/Cargo.toml index efe748f15..8e32407b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,13 +50,15 @@ lto = "thin" opt-level = 3 [workspace.dependencies] -plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } -plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } -starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri", default-features = false } +plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri", default-features = false } +plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri", default-features = false } +starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri", default-features = false } plonky2_crypto = { git = "https://github.com/0xmozak/plonky2-crypto.git" } -# [patch.crates-io] -# plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } -# plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } -# starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "sai/add_batch_fri" } +[patch.crates-io] +unroll = { git = "https://github.com/0xmozak/unroll.git" } + +plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri" } +plonky2_maybe_rayon = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri" } +starky = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri" } diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 3c8d93eaa..5ce45bc22 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -17,7 +17,7 @@ rkyv_derive = "=0.8.0-alpha.1" [target.'cfg(not(target_os="mozakvm"))'.dependencies] hex = "0.4" -plonky2 = { path = "../../plonky2/plonky2", default-features = false } +plonky2 = { git = "https://github.com/0xmozak/plonky2.git", branch = "matthias/sai/add_batch_fri", default-features = false } rand = "0.8" rand_chacha = "0.3" serde = { version = "1.0", features = ["derive"] } From df5f7165209705acbc75c99ad5895a8dd69bf93c Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 18 Apr 2024 21:14:15 +0800 Subject: [PATCH 8/9] Make Clippy Happy --- circuits/src/stark/prover.rs | 86 ++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 1ebd8f550..8afbdf27f 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -1,5 +1,7 @@ #![allow(clippy::too_many_lines)] +use std::cmp::Reverse; +use std::collections::BTreeSet; use std::fmt::Display; use anyhow::{ensure, Result}; @@ -14,7 +16,6 @@ use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; use plonky2::fri::batch_oracle::BatchFriOracle; use plonky2::fri::oracle::PolynomialBatch; -use plonky2::fri::proof::FriProof; use plonky2::hash::hash_types::RichField; use plonky2::iop::challenger::Challenger; use plonky2::plonk::config::GenericConfig; @@ -90,52 +91,49 @@ where // We cannot batch prove these tables because trace caps are needed as public // inputs for the following tables. - let public_table_kinds = vec![ + let public_table_kinds = [ TableKind::Program, TableKind::ElfMemoryInit, TableKind::MozakMemoryInit, ]; - let separate_trace_commitments = timed!( + let _separate_trace_commitments = timed!( timing, "Compute trace commitments for separate tables", - all_kind!(|kind| if public_table_kinds.contains(&kind) { - Some(PolynomialBatch::::from_values( + all_kind!(|kind| public_table_kinds.contains(&kind).then(|| { + PolynomialBatch::::from_values( traces_poly_values[kind].clone(), rate_bits, false, cap_height, timing, None, - )) - } else { - None - }) + ) + })) ); - let mut batch_traces_poly_values = all_kind!(|kind| if public_table_kinds.contains(&kind) { - None - } else { - Some(&traces_poly_values[kind]) - }); - let mut degree_logs: Vec = batch_traces_poly_values + let batch_traces_poly_values = all_kind!(|kind| public_table_kinds + .contains(&kind) + .then_some(&traces_poly_values[kind])); + let _degree_logs: Vec = batch_traces_poly_values .iter() .filter_map(|t| *t) - .map(|t| t.len()) + .map(Vec::len) + .collect::>() + .into_iter() + .rev() .collect(); - degree_logs.sort(); - degree_logs.reverse(); - degree_logs.dedup(); - let mut batch_trace_polys: Vec<_> = batch_traces_poly_values + let batch_trace_polys: Vec<_> = batch_traces_poly_values .iter() .filter_map(|t| *t) - .flat_map(|v| v.clone()) + .flatten() + .cloned() + .sorted_by_key(|p| Reverse(p.len())) .collect(); - batch_trace_polys.sort_by(|a, b| b.len().cmp(&a.len())); let bacth_trace_polys_len = batch_trace_polys.len(); - let batch_trace_commitments: BatchFriOracle = timed!( + let _batch_trace_commitments: BatchFriOracle = timed!( timing, "Compute trace commitments for batch tables", BatchFriOracle::from_values( @@ -452,7 +450,7 @@ pub fn batch_prove_with_commitments( public_inputs: &PublicInputs, trace_commitments: &TableKindArray>, traces_poly_values: &TableKindArray>>, - batch_trace_commitments: &BatchFriOracle, + _batch_trace_commitments: &BatchFriOracle, separate_trace_commitments: &TableKindArray>, ctl_data_per_table: &TableKindArray>, public_sub_data_per_table: &TableKindArray>, @@ -472,7 +470,7 @@ where } .build(); - let separate_proofs = all_starks!(mozak_stark, |stark, kind| if public_table_kinds + let _separate_proofs = all_starks!(mozak_stark, |stark, kind| if public_table_kinds .contains(&kind) { Some(prove_single_table( @@ -517,12 +515,12 @@ where }); // TODO: we can remove duplicates in the ctl polynomials. - let mut batch_ctl_zs_polys: Vec<_> = batch_ctl_z_polys + let batch_ctl_zs_polys: Vec<_> = batch_ctl_z_polys .iter() .filter_map(|t| t.as_ref()) .flat_map(|v| v.iter().cloned()) + .sorted_by_key(|b| Reverse(b.len())) .collect(); - batch_ctl_zs_polys.sort_by(|a, b| b.len().cmp(&a.len())); let batch_ctl_zs_polys_len = batch_ctl_zs_polys.len(); let batch_ctl_zs_commitments: BatchFriOracle = timed!( @@ -541,8 +539,9 @@ where let ctl_zs_commitments = all_starks!(mozak_stark, |stark, kind| timed!( timing, format!("{stark}: compute Zs commitment").as_str(), - if let Some(poly) = &batch_ctl_z_polys[kind] { - Some(PolynomialBatch::::from_values( + batch_ctl_z_polys[kind] + .as_ref() + .map(|poly| PolynomialBatch::::from_values( poly.clone(), rate_bits, false, @@ -550,9 +549,6 @@ where timing, None, )) - } else { - None - } )); let ctl_zs_cap = batch_ctl_zs_commitments.field_merkle_tree.cap.clone(); @@ -560,24 +556,26 @@ where let alphas = challenger.get_n_challenges(config.num_challenges); - let batch_quotient_polys = all_starks!(mozak_stark, |stark, kind| { + let _batch_quotient_polys = all_starks!(mozak_stark, |stark, kind| { if let Some(ctl_zs_commitment) = ctl_zs_commitments[kind].as_ref() { let degree = traces_poly_values[kind][0].len(); let degree_bits = log2_strict(degree); timed!( timing, format!("{stark}: compute quotient polynomial").as_str(), - Some(compute_quotient_polys::::Packing, C, _, D>( - stark, - &trace_commitments[kind], - &ctl_zs_commitment, - public_inputs[kind], - &ctl_data_per_table[kind], - &public_sub_data_per_table[kind], - &alphas, - degree_bits, - config, - )) + Some( + compute_quotient_polys::::Packing, C, _, D>( + stark, + &trace_commitments[kind], + ctl_zs_commitment, + public_inputs[kind], + &ctl_data_per_table[kind], + &public_sub_data_per_table[kind], + &alphas, + degree_bits, + config, + ) + ) ) } else { None From e2d4c830e3b0c6b6060b671ff15328ab0bce1b7a Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Thu, 18 Apr 2024 21:32:19 +0800 Subject: [PATCH 9/9] Simpler --- circuits/src/stark/prover.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/circuits/src/stark/prover.rs b/circuits/src/stark/prover.rs index 8afbdf27f..cfc392d4d 100644 --- a/circuits/src/stark/prover.rs +++ b/circuits/src/stark/prover.rs @@ -117,8 +117,7 @@ where .then_some(&traces_poly_values[kind])); let _degree_logs: Vec = batch_traces_poly_values .iter() - .filter_map(|t| *t) - .map(Vec::len) + .filter_map(|p| p.map(Vec::len)) .collect::>() .into_iter() .rev()