Skip to content

Commit

Permalink
Merge branch 'master' into lem-new-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-barrett authored Jul 17, 2023
2 parents 92f7b8b + 409b8ed commit 4ef998e
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 54 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/upstream_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ jobs:
fi
shell: bash

- name: Rebase SCION onto ROOT
id: rebase
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git rebase origin/${{ env.ROOT }}
if: env.status == 'false'
continue-on-error: true

- uses: dtolnay/rust-toolchain@stable
if: steps.rebase.outcome == 'success'
- name: Run a trivial test
id: test
run: cargo check --all --tests --benches
if: steps.rebase.outcome == 'success'
continue-on-error: true

- name: Push the changes
run: |
git push origin HEAD:${{ env.SCION }} -f
SCION_COMMIT=$(git rev-parse HEAD)
echo "status=true" >> $GITHUB_ENV
echo "message=$SCION is rebased on $ROOT as of $SCION_COMMIT" >> $GITHUB_ENV
if: steps.rebase.outcome == 'success' && steps.test.outcome == 'success'

- name: Find the last report issue open
id: last_issue
uses: micalevisk/last-issue-action@v2
Expand All @@ -50,6 +75,8 @@ jobs:
echo ${{ env.message }}
echo ${{ steps.last_issue.outputs.has-found }}
echo ${{ steps.last_issue.outputs.issue-number }}
echo ${{ steps.rebase.outcome }}
echo ${{ steps.test.outcome }}
- name: Close last report open issue
if: env.status == 'true' && steps.last_issue.outputs.has-found == 'true'
Expand Down
5 changes: 3 additions & 2 deletions clutch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ impl ClutchState<F, Coproc<F>> {
commitment: Some(commitment),
};

self.expression_map.set(commitment, &committed_expression)?;
self.expression_map
.set(&commitment, &committed_expression)?;
Ok(Some(store.intern_maybe_opaque_comm(commitment.comm)))
}

Expand Down Expand Up @@ -365,7 +366,7 @@ impl ClutchState<F, Coproc<F>> {
commitment: Some(new_commitment),
};

self.expression_map.set(new_commitment, &new_function)?;
self.expression_map.set(&new_commitment, &new_function)?;

let interned_commitment = store.intern_maybe_opaque_comm(new_commitment.comm);
let mut handle = io::stdout().lock();
Expand Down
2 changes: 1 addition & 1 deletion fcomm/src/bin/fcomm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Commit {
function.commitment = Some(commitment);

function_map
.set(commitment, &function)
.set(&commitment, &function)
.expect("function_map set");
function.write_to_json_path(&self.function);

Expand Down
6 changes: 3 additions & 3 deletions fcomm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ impl<'a> Opening<S1> {
};

let function_map = committed_expression_store();
function_map.set(new_commitment, &new_function)?;
function_map.set(&new_commitment, &new_function)?;
assert_eq!(new_function, function_map.get(&new_commitment).unwrap());

(Some(new_commitment), result_expr)
Expand Down Expand Up @@ -891,7 +891,7 @@ impl<'a> Proof<'a, S1> {

proof.verify(pp, &lang).expect("Nova verification failed");

proof_map.set(key, &proof).unwrap();
proof_map.set(&key, &proof).unwrap();

Ok(proof)
}
Expand Down Expand Up @@ -1150,7 +1150,7 @@ mod test {

let function_map = committed_expression_store();
function_map
.set(commitment, &function)
.set(&commitment, &function)
.expect("function_map set");

for (function_input, _expected_output) in io {
Expand Down
2 changes: 1 addition & 1 deletion src/circuit/circuit_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5321,7 +5321,7 @@ mod tests {
let cs_verified = cs.is_satisfied() && cs.verify(&public_inputs);
let verified = multiframe
.clone()
.verify_groth16_proof(&pvk, proof)
.verify_groth16_proof(&pvk, &proof)
.unwrap();

if expect_success {
Expand Down
14 changes: 7 additions & 7 deletions src/eval/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ fn dont_discard_rest_env() {
#[test]
fn test_str_car_cdr_cons() {
let s = &mut Store::<Fr>::default();
let a = s.read(r#"#\a"#).unwrap();
let a = s.read(r"#\a").unwrap();
let apple = s.read(r#" "apple" "#).unwrap();
let a_pple = s.read(r#" (#\a . "pple") "#).unwrap();
let pple = s.read(r#" "pple" "#).unwrap();
Expand Down Expand Up @@ -1274,7 +1274,7 @@ fn test_str_car_cdr_cons() {
);
test_aux::<Coproc<Fr>>(
s,
r#"(strcons #\a #\b)"#,
r"(strcons #\a #\b)",
None,
None,
Some(error),
Expand Down Expand Up @@ -1358,8 +1358,8 @@ fn test_car_cdr_invalid_tag_error_sym() {
fn test_car_cdr_invalid_tag_error_char() {
let s = &mut Store::<Fr>::default();
let error = s.get_cont_error();
test_aux::<Coproc<Fr>>(s, r#"(car #\a)"#, None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r#"(cdr #\a)"#, None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r"(car #\a)", None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r"(cdr #\a)", None, None, Some(error), None, 2, None);
}

#[test]
Expand Down Expand Up @@ -1632,7 +1632,7 @@ fn num() {
#[test]
fn num_char() {
let s = &mut Store::<Fr>::default();
let expr = r#"(num #\a)"#;
let expr = r"(num #\a)";
let expected = s.num(97);
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(s, expr, Some(expected), None, Some(terminal), None, 2, None);
Expand All @@ -1642,7 +1642,7 @@ fn num_char() {
fn char_num() {
let s = &mut Store::<Fr>::default();
let expr = r#"(char 97)"#;
let expected_a = s.read(r#"#\a"#).unwrap();
let expected_a = s.read(r"#\a").unwrap();
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(
s,
Expand All @@ -1660,7 +1660,7 @@ fn char_num() {
fn char_coercion() {
let s = &mut Store::<Fr>::default();
let expr = r#"(char (- 0 4294967200))"#;
let expected_a = s.read(r#"#\a"#).unwrap();
let expected_a = s.read(r"#\a").unwrap();
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(
s,
Expand Down
2 changes: 1 addition & 1 deletion src/parser/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Pos {
/// Use the range information in a Position to pretty-print that range within
/// a string
pub fn range(
input: String,
input: &str,
from_line: usize,
from_column: usize,
upto_line: usize,
Expand Down
6 changes: 3 additions & 3 deletions src/parser/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,12 @@ pub mod tests {
fn unit_parse_hash_char() {
assert!(test(parse_hash_char(), "#\\a", Some(char!('a'))));
assert!(test(parse_hash_char(), "#\\b", Some(char!('b'))));
assert!(test(parse_hash_char(), r#"#\b"#, Some(char!('b'))));
assert!(test(parse_hash_char(), r"#\b", Some(char!('b'))));
assert!(test(parse_hash_char(), "#\\u{8f}", Some(char!('\u{8f}'))));
assert!(test(parse_syntax(), "#\\a", Some(char!('a'))));
assert!(test(parse_syntax(), "#\\b", Some(char!('b'))));
assert!(test(parse_syntax(), r#"#\b"#, Some(char!('b'))));
assert!(test(parse_syntax(), r#"#\u{8f}"#, Some(char!('\u{8f}'))));
assert!(test(parse_syntax(), r"#\b", Some(char!('b'))));
assert!(test(parse_syntax(), r"#\u{8f}", Some(char!('\u{8f}'))));
}

#[test]
Expand Down
19 changes: 8 additions & 11 deletions src/proof/groth16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ impl<C: Coprocessor<Scalar>> Groth16Prover<Bls12, C, Scalar> {
/// Verifies a single Groth16 proof using the given multi_frame, prepared verifier key, and proof.
pub fn verify_groth16_proof(
// multiframe need not have inner frames populated for verification purposes.
multiframe: MultiFrame<'_, Scalar, IO<Scalar>, Witness<Scalar>, C>,
multiframe: &MultiFrame<'_, Scalar, IO<Scalar>, Witness<Scalar>, C>,
pvk: &groth16::PreparedVerifyingKey<Bls12>,
proof: groth16::Proof<Bls12>,
proof: &groth16::Proof<Bls12>,
) -> Result<bool, SynthesisError> {
let inputs = multiframe.public_inputs();

verify_proof(pvk, &proof, &inputs)
verify_proof(pvk, proof, &inputs)
}

/// Verifies an aggregated Groth16 proof using the given prepared verifier key, SRS, public parameters, proof and rng.
Expand Down Expand Up @@ -291,19 +291,19 @@ impl<C: Coprocessor<Scalar>>
pub fn verify_groth16_proof(
self,
pvk: &groth16::PreparedVerifyingKey<Bls12>,
proof: groth16::Proof<Bls12>,
proof: &groth16::Proof<Bls12>,
) -> Result<bool, SynthesisError> {
let inputs: Vec<Scalar> = self.public_inputs();
verify_proof(pvk, &proof, inputs.as_slice())
verify_proof(pvk, proof, inputs.as_slice())
}
}

#[allow(dead_code)]
fn verify_sequential_groth16_proofs<C: Coprocessor<Scalar>>(
multiframe_proofs: Vec<(
multiframe_proofs: &[(
MultiFrame<'_, Scalar, IO<Scalar>, Witness<Scalar>, C>,
groth16::Proof<Bls12>,
)>,
)],
vk: &groth16::VerifyingKey<Bls12>,
) -> Result<bool, SynthesisError> {
let pvk = groth16::prepare_verifying_key(vk);
Expand All @@ -317,10 +317,7 @@ fn verify_sequential_groth16_proofs<C: Coprocessor<Scalar>>(
}
}

if !multiframe
.clone()
.verify_groth16_proof(&pvk, proof.clone())?
{
if !multiframe.clone().verify_groth16_proof(&pvk, proof)? {
return Ok(false);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/proof/nova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,7 @@ pub mod tests {
#[test]
fn test_prove_str_car() {
let s = &mut Store::<Fr>::default();
let expected_a = s.read(r#"#\a"#).unwrap();
let expected_a = s.read(r"#\a").unwrap();
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(
s,
Expand Down Expand Up @@ -2443,7 +2443,7 @@ pub mod tests {
let error = s.get_cont_error();
test_aux::<Coproc<Fr>>(
s,
r#"(strcons #\a 123)"#,
r"(strcons #\a 123)",
None,
None,
Some(error),
Expand Down Expand Up @@ -2506,8 +2506,8 @@ pub mod tests {
fn test_prove_car_cdr_invalid_tag_error_char() {
let s = &mut Store::<Fr>::default();
let error = s.get_cont_error();
test_aux::<Coproc<Fr>>(s, r#"(car #\a)"#, None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r#"(cdr #\a)"#, None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r"(car #\a)", None, None, Some(error), None, 2, None);
test_aux::<Coproc<Fr>>(s, r"(cdr #\a)", None, None, Some(error), None, 2, None);
}

#[test]
Expand Down Expand Up @@ -2678,7 +2678,7 @@ pub mod tests {
#[test]
fn test_prove_num_char() {
let s = &mut Store::<Fr>::default();
let expr = r#"(num #\a)"#;
let expr = r"(num #\a)";
let expected = s.num(97);
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(s, expr, Some(expected), None, Some(terminal), None, 2, None);
Expand All @@ -2688,7 +2688,7 @@ pub mod tests {
fn test_prove_char_num() {
let s = &mut Store::<Fr>::default();
let expr = r#"(char 97)"#;
let expected_a = s.read(r#"#\a"#).unwrap();
let expected_a = s.read(r"#\a").unwrap();
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(
s,
Expand All @@ -2707,8 +2707,8 @@ pub mod tests {
let s = &mut Store::<Fr>::default();
let expr = r#"(char (- 0 4294967200))"#;
let expr2 = r#"(char (- 0 4294967199))"#;
let expected_a = s.read(r#"#\a"#).unwrap();
let expected_b = s.read(r#"#\b"#).unwrap();
let expected_a = s.read(r"#\a").unwrap();
let expected_b = s.read(r"#\b").unwrap();
let terminal = s.get_cont_terminal();
test_aux::<Coproc<Fr>>(
s,
Expand Down Expand Up @@ -2857,7 +2857,7 @@ pub mod tests {
#[test]
fn test_str_car_cdr_cons() {
let s = &mut Store::<Fr>::default();
let a = s.read(r#"#\a"#).unwrap();
let a = s.read(r"#\a").unwrap();
let apple = s.read(r#" "apple" "#).unwrap();
let a_pple = s.read(r#" (#\a . "pple") "#).unwrap();
let pple = s.read(r#" "pple" "#).unwrap();
Expand Down Expand Up @@ -2930,7 +2930,7 @@ pub mod tests {

test_aux::<Coproc<Fr>>(
s,
r#"(strcons #\a #\b)"#,
r"(strcons #\a #\b)",
None,
None,
Some(error),
Expand Down
8 changes: 4 additions & 4 deletions src/public_parameters/file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl<K: ToString> FileIndex<K> {
V::read_from_path(self.key_path(key)).ok()
}

pub(crate) fn set<V: FileStore>(&self, key: K, data: &V) -> Result<(), Error> {
data.write_to_path(self.key_path(&key));
pub(crate) fn set<V: FileStore>(&self, key: &K, data: &V) -> Result<(), Error> {
data.write_to_path(self.key_path(key));
Ok(())
}
}
Expand Down Expand Up @@ -70,8 +70,8 @@ impl<K: ToString, V: FileStore> FileMap<K, V> {
V::read_from_path(self.key_path(key)).ok()
}

pub fn set(&self, key: K, data: &V) -> Result<(), Error> {
data.write_to_path(self.key_path(&key));
pub fn set(&self, key: &K, data: &V) -> Result<(), Error> {
data.write_to_path(self.key_path(key));
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/public_parameters/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Registry {
} else {
let pp = default(lang);
disk_cache
.set(key, &*pp)
.set(&key, &*pp)
.tap_ok(|_| eprintln!("Writing public params to disk-cache: {}", lang_key))
.map_err(|e| Error::CacheError(format!("Disk write error: {e}")))?;
Ok(pp)
Expand Down
8 changes: 4 additions & 4 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ impl<F: LurkField> Store<F> {
ptr
}

pub fn get_sym(&self, sym: Symbol) -> Option<Ptr<F>> {
let ptr = self.symbol_cache.get(&sym).cloned()?;
if sym == Symbol::nil() {
pub fn get_sym(&self, sym: &Symbol) -> Option<Ptr<F>> {
let ptr = self.symbol_cache.get(sym).cloned()?;
if *sym == Symbol::nil() {
Some(Ptr {
tag: ExprTag::Nil,
raw: ptr.raw,
Expand All @@ -496,7 +496,7 @@ impl<F: LurkField> Store<F> {

pub fn get_lurk_sym<T: AsRef<str>>(&self, name: T) -> Option<Ptr<F>> {
let sym = Symbol::lurk_sym(name.as_ref());
self.get_sym(sym)
self.get_sym(&sym)
}

pub fn intern_num<T: Into<Num<F>>>(&mut self, num: T) -> Ptr<F> {
Expand Down
4 changes: 2 additions & 2 deletions src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<F: LurkField> Store<F> {

fn fetch_syntax_aux(
&self,
lurk_syms: HashMap<Symbol, LurkSym>,
lurk_syms: &HashMap<Symbol, LurkSym>,
ptr: Ptr<F>,
) -> Option<Syntax<F>> {
let expr = self.fetch(&ptr)?;
Expand Down Expand Up @@ -221,7 +221,7 @@ impl<F: LurkField> Store<F> {

pub fn fetch_syntax(&self, ptr: Ptr<F>) -> Option<Syntax<F>> {
let lurk_syms = Symbol::lurk_syms();
self.fetch_syntax_aux(lurk_syms, ptr)
self.fetch_syntax_aux(&lurk_syms, ptr)
}
}

Expand Down
Loading

0 comments on commit 4ef998e

Please sign in to comment.