Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

o1vm/pickles: MISC fixes in the prover + debug information #2688

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions o1vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ In either case, `run-code.sh` will:
## Flavors

Different versions/flavors of the o1vm are available.
- [legacy](./src/legacy/mod.rs) - to be deprecated (currently default).
- [pickles](./src/pickles/mod.rs)
- [legacy](./src/legacy/mod.rs) - to be deprecated.
- [pickles](./src/pickles/mod.rs) (currently the default)

You can select the flavor you want to run with `run-code.sh` by using the
environment variable `O1VM_FLAVOR`.
Expand Down
6 changes: 3 additions & 3 deletions o1vm/run-vm.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

O1VM_FLAVOR="${O1VM_FLAVOR:-legacy}"
O1VM_FLAVOR="${O1VM_FLAVOR:-pickles}"

case ${O1VM_FLAVOR} in
"legacy")
Expand All @@ -11,8 +11,8 @@ case ${O1VM_FLAVOR} in
BINARY_FLAVOR="pickles_o1vm"
;;
*)
echo "${BASH_SOURCE[0]}:${LINENO}: only flavors 'legacy' (default) and \
'pickles' are supported for now. Use the environment variable \
echo "${BASH_SOURCE[0]}:${LINENO}: only flavors 'legacy' and \
'pickles' (default) are supported for now. Use the environment variable \
O1VM_FLAVOR to one of these values to run the flavor you would like";
exit 1
;;
Expand Down
6 changes: 3 additions & 3 deletions o1vm/src/pickles/column_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ impl<'a, F: FftField> TColumnEnvironment<'a, F, BerkeleyChallengeTerm, BerkeleyC

fn get_domain(&self, d: Domain) -> Radix2EvaluationDomain<F> {
match d {
Domain::D1 => self.domain.d1,
Domain::D2 => self.domain.d2,
Domain::D4 => self.domain.d4,
Domain::D8 => self.domain.d8,
Domain::D1 | Domain::D2 | Domain::D4 => {
panic!("Not supposed to be in MIPS. All columns are evaluated on d8")
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions o1vm/src/pickles/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pub fn main() -> ExitCode {
let mut curr_proof_inputs: ProofInputs<Vesta> = ProofInputs::new(DOMAIN_SIZE);
while !mips_wit_env.halt {
let _instr: Instruction = mips_wit_env.step(&configuration, &meta, &start);
// FIXME: add selectors
for (scratch, scratch_chunk) in mips_wit_env
.scratch_state
.iter()
Expand All @@ -125,7 +124,7 @@ pub fn main() -> ExitCode {
if curr_proof_inputs.evaluations.instruction_counter.len() == DOMAIN_SIZE {
// FIXME
let start_iteration = Instant::now();
debug!("Limit of {DOMAIN_SIZE} reached. We make a proof, verify it (for testing) and start with a new branch new chunk");
debug!("Limit of {DOMAIN_SIZE} reached. We make a proof, verify it (for testing) and start with a new chunk");
let _proof: Result<Proof<Vesta>, prover::ProverError> =
prover::prove::<
Vesta,
Expand Down
14 changes: 14 additions & 0 deletions o1vm/src/pickles/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use kimchi::{
groupmap::GroupMap,
plonk_sponge::FrSponge,
};
use log::debug;
use mina_poseidon::{sponge::ScalarChallenge, FqSponge};
use poly_commitment::{
commitment::{absorb_commitment, PolyComm},
Expand Down Expand Up @@ -75,6 +76,7 @@ where
////////////////////////////////////////////////////////////////////////////
type F<G> = DensePolynomial<<<G as AffineRepr>::Group as Group>::ScalarField>;

debug!("Prover: interpolating all columns, including the selectors");
let ProofInputs { evaluations } = inputs;
let polys: WitnessColumns<F<G>, [F<G>; N_MIPS_SEL_COLS]> = {
let WitnessColumns {
Expand Down Expand Up @@ -115,6 +117,7 @@ where
}
};

debug!("Prover: committing to all columns, including the selectors");
let commitments: WitnessColumns<PolyComm<G>, [PolyComm<G>; N_MIPS_SEL_COLS]> = {
let WitnessColumns {
scratch,
Expand All @@ -136,6 +139,7 @@ where
}
};

debug!("Prover: evaluating all columns, including the selectors, on d8");
// We evaluate on a domain higher than d1 for the quotient polynomial.
// Based on the regression test
// `test_regression_constraints_with_selectors`, the highest degree is 6.
Expand Down Expand Up @@ -204,6 +208,14 @@ where
}
};

debug!("Prover: computing the quotient polynomial");
// Hint:
// To debug individual constraint, you can revert the following commits that implement the
// check for individual constraints.
// ```
// git revert 8e87244a98d55b90d175ad389611a3c98bd16b34
// git revert 96d42c127ef025869c91e5fed680e0e383108706
// ```
let quotient_poly: DensePolynomial<G::ScalarField> = {
// Compute ∑ α^i constraint_i as an expression
let combined_expr =
Expand Down Expand Up @@ -251,6 +263,7 @@ where
// Round 3: Evaluations at ζ and ζω
////////////////////////////////////////////////////////////////////////////

debug!("Prover: evaluating all columns, including the selectors, at ζ and ζω");
let zeta_chal = ScalarChallenge(fq_sponge.challenge());

let zeta = zeta_chal.to_field(endo_r);
Expand Down Expand Up @@ -340,6 +353,7 @@ where

let group_map = G::Map::setup();

debug!("Prover: computing the (batched) opening proof using the IPA PCS");
// Computing the opening proof for the IPA PCS
let opening_proof = OpeningProof::open::<_, _, D<G::ScalarField>>(
srs,
Expand Down