Skip to content

Commit

Permalink
Complicate code for review nitpick
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmr1993 committed Oct 17, 2023
1 parent a1db6b3 commit 1c38d90
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/lib/pickles/proof_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,10 @@ let set_wrap_proof t ~keypair ~public_input proof =
in
let proof_json = Backend.Tock.Proof.to_yojson proof in
set_proof t ~verification_key ~public_input proof_json

let is_env_var_set_requesting_error_for_proofs () =
match Sys.getenv_opt "ERROR_ON_PROOF" with
| Some ("true" | "t" (* insert whatever value is okay here *)) ->
true
| None | Some _ ->
false
2 changes: 2 additions & 0 deletions src/lib/pickles/proof_cache.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ val set_wrap_proof :
-> public_input:Kimchi_bindings.FieldVectors.Fq.t
-> Backend.Tock.Proof.t
-> unit

val is_env_var_set_requesting_error_for_proofs : unit -> bool
3 changes: 2 additions & 1 deletion src/lib/pickles/step.ml
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ struct
with
| None ->
if
Option.is_some (Sys.getenv_opt "ERROR_ON_PROOF")
Proof_cache
.is_env_var_set_requesting_error_for_proofs ()
then failwith "Regenerated proof" ;
let%map.Promise proof = create_proof () in
Proof_cache.set_step_proof proof_cache ~keypair:pk
Expand Down
6 changes: 4 additions & 2 deletions src/lib/pickles/wrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,10 @@ let wrap
~public_input:public_inputs
with
| None ->
if Option.is_some (Sys.getenv_opt "ERROR_ON_PROOF") then
failwith "Regenerated proof" ;
if
Proof_cache.is_env_var_set_requesting_error_for_proofs
()
then failwith "Regenerated proof" ;
let%map.Promise proof = create_proof () in
Proof_cache.set_wrap_proof proof_cache ~keypair:pk
~public_input:public_inputs proof ;
Expand Down

0 comments on commit 1c38d90

Please sign in to comment.