Replies: 5 comments 14 replies
-
|
I'm trying to understand the special case of What is |
Beta Was this translation helpful? Give feedback.
-
|
I'm wondering if we can do one of these instead: check that the returned state is same as input state. Like so: let run (checked : _ Checked.t) =
if not (is_active_functor_id this_functor_id) then
failwithf
"Could not run this function.\n\n\
Hint: The module used to create this function had internal ID %i, \
but the module used to run it had internal ID %i. The same instance \
of Snarky.Snark.Run.Make must be used for both."
this_functor_id (active_functor_id ()) ()
else (
let state', x = Runner.run checked !state in
(if (not (Run_state.is_running !state)) && (Run_state.compare state' !state) = 0 then
failwith "This function can't be run outside of a checked computation." );
state := state' ;
x
)this way we can tell if it was a pure computation or not The problem I'm facing is that it seems like we've disabled comparisons in our codebase. So I have to implement I'm trying this: module T = struct
open Core_kernel
(** The internal state used to run a checked computation. *)
type 'field t =
{ system : 'field Constraint_system.t option
; input : 'field Vector.t
; aux : 'field Vector.t
; eval_constraints : bool
; num_inputs : int
; next_auxiliary : int ref
; has_witness : bool
; stack : string list
; handler : Request.Handler.t
; is_running : bool
; as_prover : bool ref
; log_constraint :
( ?at_label_boundary:[ `Start | `End ] * string
-> ('field Cvar.t, 'field) Constraint.t option
-> unit )
option
[@compare.ignore]
}
[@@deriving compare]
end
include Tbut it seems like I can't use that ppx to derive it on the GADTs ( The following doesn't seem to work: type 'f t =
| T :
(module Backend_intf.Constraint_system_intf
with type Field.t = 'f
and type t = 't )
* 't
-> 'f t
let compare (type f) (t1 : f t) (t2 : f t) =
match (t1, t2) with T ((module Cs1), t1), T (_, t2) -> Cs1.compare t1 t2I think I need to use Type_equal to first prove that Cs1 = Cs2, although now I'm wondering:
Perhaps a better solution here would be to use the kimchi_backend directly (it might also facilitate moving to a rust backend?) It is a bit annoying though, because that means we'd have to move the kimchi backend code in this repo OR create a functor for run_state instead of a top-level type (and I think we have enough functors) |
Beta Was this translation helpful? Give feedback.
-
|
We can get rid of |
Beta Was this translation helpful? Give feedback.
-
|
Interestingly, it always seems to be set to
|
Beta Was this translation helpful? Give feedback.
-
|
OK so my final understanding of
thus the only utility is to make sure that the imperative API never runs with a state that's not the global state it has set up (although in theory I could still create another state with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In
run_state.ml, the state contains a booleanis_running:What is this variable? It is used in two places in the imperative interface of
snark0.ml:this is exposed to snarkyjs and not used in snarky, so who knows what they're doing with it. (CC @mitschabaude)
The second one is used in:
runis evaluated whenever a user-facing function of the imperative API of snarky is evaluated (e.g.exists,as_prover,assert_r1cs,Field.equal, etc.)My guess is that it is making sure that we've initialized the state before running something. This is important because we're using a global state, and so we must:
Beta Was this translation helpful? Give feedback.
All reactions