Skip to content

Commit

Permalink
Chore: generalize the REPL's Lang
Browse files Browse the repository at this point in the history
* Remove hardcoded Coproc occurrences from the REPL implementation
* Use Coproc on the top-level call
  • Loading branch information
arthurpaulino committed Jan 5, 2024
1 parent bc13609 commit 23dc22d
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 115 deletions.
9 changes: 5 additions & 4 deletions benches/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use lurk::{
eval::lang::Lang,
field::LurkField,
lem::{
eval::{evaluate, make_eval_step_from_config, EvalConfig},
eval::{evaluate, make_cprocs_funcs_from_lang, make_eval_step_from_config, EvalConfig},
multiframe::MultiFrame,
pointers::Ptr,
store::Store,
Expand Down Expand Up @@ -134,7 +134,7 @@ fn sha256_ivc_prove<M: measurement::Measurement>(

let prover = NovaProver::new(prove_params.reduction_count, lang_rc.clone());

let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap();
let frames = &evaluate(Some((&lurk_step, &[], &lang)), ptr, store, limit).unwrap();

b.iter_batched(
|| frames,
Expand Down Expand Up @@ -215,7 +215,7 @@ fn sha256_ivc_prove_compressed<M: measurement::Measurement>(

let prover = NovaProver::new(prove_params.reduction_count, lang_rc.clone());

let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap();
let frames = &evaluate(Some((&lurk_step, &[], &lang)), ptr, store, limit).unwrap();

b.iter_batched(
|| frames,
Expand Down Expand Up @@ -274,6 +274,7 @@ fn sha256_nivc_prove<M: measurement::Measurement>(
let lang_rc = Arc::new(lang.clone());

let lurk_step = make_eval_step_from_config(&EvalConfig::new_ivc(&lang));
let cprocs = make_cprocs_funcs_from_lang(&lang);

// use cached public params
let instance = Instance::new(
Expand All @@ -298,7 +299,7 @@ fn sha256_nivc_prove<M: measurement::Measurement>(

let prover = SuperNovaProver::new(prove_params.reduction_count, lang_rc.clone());

let frames = &evaluate(Some((&lurk_step, &lang)), ptr, store, limit).unwrap();
let frames = &evaluate(Some((&lurk_step, &cprocs, &lang)), ptr, store, limit).unwrap();

b.iter_batched(
|| frames,
Expand Down
5 changes: 3 additions & 2 deletions examples/sha256_nivc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use lurk::{
eval::lang::Lang,
field::LurkField,
lem::{
eval::{evaluate, make_eval_step_from_config, EvalConfig},
eval::{evaluate, make_cprocs_funcs_from_lang, make_eval_step_from_config, EvalConfig},
multiframe::MultiFrame,
pointers::Ptr,
store::Store,
Expand Down Expand Up @@ -77,7 +77,8 @@ fn main() {
let lang_rc = Arc::new(lang.clone());

let lurk_step = make_eval_step_from_config(&EvalConfig::new_nivc(&lang));
let frames = evaluate(Some((&lurk_step, &lang)), call, store, 1000).unwrap();
let cprocs = make_cprocs_funcs_from_lang(&lang);
let frames = evaluate(Some((&lurk_step, &cprocs, &lang)), call, store, 1000).unwrap();

let supernova_prover = SuperNovaProver::<Fr, Sha256Coproc<Fr>, MultiFrame<'_, _, _>>::new(
REDUCTION_COUNT,
Expand Down
6 changes: 4 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
};

use crate::{
eval::lang::Coproc,
eval::lang::{Coproc, Lang},
field::{LanguageField, LurkField},
lem::{multiframe::MultiFrame, store::Store},
public_parameters::disk_cache::public_params_dir,
Expand Down Expand Up @@ -305,7 +305,9 @@ fn get_store<F: LurkField + for<'a> serde::de::Deserialize<'a>>(
macro_rules! new_repl {
( $cli: expr, $rc: expr, $limit: expr, $field: path, $backend: expr ) => {{
let store = get_store(&$cli.zstore).with_context(|| "reading store from file")?;
Repl::<$field>::new(store, $rc, $limit, $backend)
// TODO: pick a predefined `Lang` according to a CLI parameter
let lang = Lang::new();
Repl::<$field, Coproc<$field>>::new(store, lang, $rc, $limit, $backend)
}};
}

Expand Down
Loading

0 comments on commit 23dc22d

Please sign in to comment.