Skip to content

Commit

Permalink
Merge pull request #16446 from MinaProtocol/feature/remove-constraint…
Browse files Browse the repository at this point in the history
…-constants-pickles-compile

Remove now-unnecessary `Pickles.compile` parameter `~constraint_constants`
  • Loading branch information
mrmr1993 authored Dec 29, 2024
2 parents c052db3 + 2b63e8c commit d3f9e39
Show file tree
Hide file tree
Showing 32 changed files with 47 additions and 207 deletions.
2 changes: 1 addition & 1 deletion src/app/disk_caching_stats/disk_caching_stats.ml
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ let () =
in
let%map.Async_kernel.Deferred vk =
let `VK vk, `Prover _ =
Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()
Transaction_snark.For_tests.create_trivial_snapp ()
in
vk
in
Expand Down
2 changes: 1 addition & 1 deletion src/app/heap_usage/heap_usage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let main ~genesis_constants ~constraint_constants () =
in
print_heap_usage "Zkapp_command.t" zkapp_command ;
print_heap_usage "Pickles.Side_loaded.Proof.t" @@ zkapp_proof ~zkapp_command ;
let%bind verification_key = verification_key ~constraint_constants in
let%bind verification_key = Lazy.force verification_key in
print_heap_usage "Mina_base.Side_loaded_verification_key.t" verification_key ;
print_heap_usage "Dummy Pickles.Side_loaded.Proof.t" dummy_proof ;
print_heap_usage "Dummy Mina_base.Side_loaded_verification_key.t" dummy_vk ;
Expand Down
13 changes: 7 additions & 6 deletions src/app/heap_usage/values.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ let dummy_proof =

let dummy_vk = Mina_base.Side_loaded_verification_key.dummy

let verification_key ~constraint_constants =
let `VK vk, `Prover _ =
Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()
in
let%map.Async.Deferred vk = vk in
With_hash.data vk
let verification_key =
lazy
(let `VK vk, `Prover _ =
Transaction_snark.For_tests.create_trivial_snapp ()
in
let%map.Async.Deferred vk = vk in
With_hash.data vk )

let applied = Mina_base.Transaction_status.Applied

Expand Down
6 changes: 0 additions & 6 deletions src/app/test_executive/verification_key_update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~branches:(module Pickles_types.Nat.N1)
~max_proofs_verified:(module Pickles_types.Nat.N0)
~name:"trivial1"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ -> [ Trivial_rule1.rule ])
in
let%bind.Async.Deferred vk1 =
Expand All @@ -137,9 +134,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~branches:(module Pickles_types.Nat.N1)
~max_proofs_verified:(module Pickles_types.Nat.N0)
~name:"trivial2"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ -> [ Trivial_rule2.rule ])
in
let%bind.Async.Deferred vk2 =
Expand Down
35 changes: 9 additions & 26 deletions src/app/zkapp_test_transaction/lib/commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ let parse_field_element_or_hash_string s ~f =
| Error e1 ->
Error.raise (Error.tag ~tag:"Expected a field element" e1)

let vk_and_prover ~constraint_constants =
lazy
(Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ())
let vk_and_prover = lazy (Transaction_snark.For_tests.create_trivial_snapp ())

let get_second_pass_ledger_mask ~ledger ~constraint_constants ~global_slot
~state_body zkapp_command =
Expand Down Expand Up @@ -61,9 +59,7 @@ let gen_proof ?(zkapp_account = None) (zkapp_command : Zkapp_command.t)
let open Async.Deferred.Let_syntax in
let%bind () =
Option.value_map zkapp_account ~default:(Deferred.return ()) ~f:(fun pk ->
let `VK vk, `Prover _ =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover _ = Lazy.force @@ vk_and_prover in
let%map vk = vk in
let id = Account_id.create pk Token_id.default in
Ledger.get_or_create_account ledger id
Expand Down Expand Up @@ -183,8 +179,7 @@ let generate_zkapp_txn (keypair : Signature_lib.Keypair.t) (ledger : Ledger.t)
in
let%bind zkapp_command =
Transaction_snark.For_tests.create_trivial_predicate_snapp
~constraint_constants ~protocol_state_predicate spec ledger
~snapp_kp:zkapp_kp
~protocol_state_predicate spec ledger ~snapp_kp:zkapp_kp
in
printf "ZkApp transaction yojson: %s\n\n%!"
(Zkapp_command.to_yojson zkapp_command |> Yojson.Safe.to_string) ;
Expand Down Expand Up @@ -424,9 +419,7 @@ let upgrade_zkapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down Expand Up @@ -506,9 +499,7 @@ let update_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~app_state
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down Expand Up @@ -546,9 +537,7 @@ let update_zkapp_uri ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile ~zkapp_uri
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down Expand Up @@ -588,9 +577,7 @@ let update_action_state ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down Expand Up @@ -628,9 +615,7 @@ let update_token_symbol ~debug ~keyfile ~fee ~nonce ~memo ~snapp_keyfile
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down Expand Up @@ -669,9 +654,7 @@ let update_snapp ~debug ~keyfile ~fee ~nonce ~memo ~zkapp_keyfile ~snapp_update
}
in
let%bind zkapp_command =
let `VK vk, `Prover prover =
Lazy.force @@ vk_and_prover ~constraint_constants
in
let `VK vk, `Prover prover = Lazy.force @@ vk_and_prover in
Transaction_snark.For_tests.update_states ~zkapp_prover_and_vk:(prover, vk)
~constraint_constants spec
in
Expand Down
3 changes: 0 additions & 3 deletions src/app/zkapps_examples/test/actions/actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ let%test_module "Actions test" =
~branches:(module Nat.N2)
~max_proofs_verified:(module Nat.N0)
~name:"no actions"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ ->
[ Zkapps_actions.initialize_rule pk_compressed
; Zkapps_actions.update_actions_rule pk_compressed
Expand Down
3 changes: 0 additions & 3 deletions src/app/zkapps_examples/test/add_events/add_events.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ let%test_module "Add events test" =
~branches:(module Nat.N2)
~max_proofs_verified:(module Nat.N0)
~name:"no events"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ ->
[ Zkapps_add_events.initialize_rule pk_compressed
; Zkapps_add_events.update_events_rule pk_compressed
Expand Down
3 changes: 0 additions & 3 deletions src/app/zkapps_examples/test/big_circuit/big_circuit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ let tag, _cache, _p_module, Pickles.Provers.[ prover ] =
~branches:(module Nat.N1)
~max_proofs_verified:(module Nat.N0)
~name:"big_circuit"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ ->
[ Zkapps_big_circuit.rule ~num_constraints pk_compressed ] )

Expand Down
3 changes: 0 additions & 3 deletions src/app/zkapps_examples/test/calls/calls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ let%test_module "Composability test" =
~branches:(module Nat.N4)
~max_proofs_verified:(module Nat.N0)
~name:"empty_update"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ ->
[ Zkapps_calls.Rules.Initialize_state.rule
; Zkapps_calls.Rules.Update_state.rule
Expand Down
3 changes: 0 additions & 3 deletions src/app/zkapps_examples/test/empty_update/empty_update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ let tag, _, p_module, Pickles.Provers.[ prover ] =
~branches:(module Nat.N1)
~max_proofs_verified:(module Nat.N0)
~name:"empty_update"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ -> [ Zkapps_empty_update.rule pk_compressed ])

module P = (val p_module)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ let%test_module "Initialize state test" =
~branches:(module Nat.N2)
~max_proofs_verified:(module Nat.N0)
~name:"empty_update"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self:_ ->
[ Zkapps_initialize_state.initialize_rule pk_compressed
; Zkapps_initialize_state.update_state_rule pk_compressed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ struct
open Pickles.Impls.Step
open Pickles_types

let constraint_constants =
{ Snark_keys_header.Constraint_constants.sub_windows_per_window = 0
; ledger_depth = 0
; work_delay = 0
; block_window_duration_ms = 0
; transaction_capacity = Log_2 0
; pending_coinbase_depth = 0
; coinbase_amount = Unsigned.UInt64.of_int 0
; supercharged_coinbase_factor = 0
; account_creation_fee = Unsigned.UInt64.of_int 0
; fork = None
}

let feature_flags =
{ Plonk_types.Features.none_bool with
rot = true
Expand All @@ -46,7 +33,7 @@ struct
Zkapps_examples.compile ~auxiliary_typ:Typ.unit
~branches:(module Nat.N1)
~max_proofs_verified:(module Nat.N0)
~name:"custom gates" ~constraint_constants
~name:"custom gates"
~choices:(fun ~self:_ ->
[ { identifier = "main"
; prevs = []
Expand Down
5 changes: 2 additions & 3 deletions src/app/zkapps_examples/zkapps_examples.ml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ let compile :
-> max_proofs_verified:
(module Nat.Add.Intf with type n = max_proofs_verified)
-> name:string
-> ?constraint_constants:_
-> choices:
( self:
( Zkapp_statement.Checked.t
Expand Down Expand Up @@ -588,7 +587,7 @@ let compile :
Deferred.t )
H3_2.T(Pickles.Prover).t =
fun ?self ?cache ?proof_cache ?disk_keys ?override_wrap_domain ~auxiliary_typ
~branches ~max_proofs_verified ~name ?constraint_constants ~choices () ->
~branches ~max_proofs_verified ~name ~choices () ->
let vk_hash = ref None in
let choices ~self =
let rec go :
Expand Down Expand Up @@ -649,7 +648,7 @@ let compile :
Pickles.compile_async () ?self ?cache ?proof_cache ?disk_keys
?override_wrap_domain ~public_input:(Output Zkapp_statement.typ)
~auxiliary_typ:Typ.(Prover_value.typ () * auxiliary_typ)
~branches ~max_proofs_verified ~name ?constraint_constants ~choices
~branches ~max_proofs_verified ~name ~choices
in
let () =
vk_hash :=
Expand Down
3 changes: 0 additions & 3 deletions src/lib/blockchain_snark/blockchain_snark_state.ml
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,6 @@ end) : S = struct
~branches:(module Nat.N1)
~max_proofs_verified:(module Nat.N2)
~name:"blockchain-snark"
~constraint_constants:
(Genesis_constants.Constraint_constants.to_snark_keys_header
constraint_constants )
~choices:(fun ~self ->
[ rule ~proof_level ~constraint_constants T.tag self ] )

Expand Down
3 changes: 1 addition & 2 deletions src/lib/mina_generators/zkapp_command_generators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,7 @@ let%test_module _ =
let constraint_constants =
Genesis_constants.For_unit_tests.Constraint_constants.t

let `VK vk, `Prover _ =
Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()
let `VK vk, `Prover _ = Transaction_snark.For_tests.create_trivial_snapp ()

let vk = Async.Thread_safe.block_on_async_exn (fun () -> vk)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_graphql/itn_zkapps.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ let send_zkapps ~(genesis_constants : Genesis_constants.t)
`Repeat (next_tm_next, counter + 1)
in
let `VK vk, `Prover prover =
Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()
Transaction_snark.For_tests.create_trivial_snapp ()
in
let%bind.Deferred vk = vk in
let account_queue = Queue.create () in
Expand Down
2 changes: 1 addition & 1 deletion src/lib/network_pool/transaction_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ let%test_module _ =
() )

let `VK vk, `Prover prover =
Transaction_snark.For_tests.create_trivial_snapp ~constraint_constants ()
Transaction_snark.For_tests.create_trivial_snapp ()

let vk = Async.Thread_safe.block_on_async_exn (fun () -> vk)

Expand Down
12 changes: 6 additions & 6 deletions src/lib/pickles/pickles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ module Make_str (_ : Wire_types.Concrete) = struct

let compile_promise ?self ?cache ?storables ?proof_cache ?disk_keys
?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ ~branches
~max_proofs_verified ~name ?constraint_constants ~choices () =
~max_proofs_verified ~name ~choices () =
compile_with_wrap_main_override_promise ?self ?cache ?storables ?proof_cache
?disk_keys ?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ
~branches ~max_proofs_verified ~name ?constraint_constants ~choices ()
~branches ~max_proofs_verified ~name ~choices ()

let compile ?self ?cache ?storables ?proof_cache ?disk_keys
?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ ~branches
~max_proofs_verified ~name ?constraint_constants ~choices () =
~max_proofs_verified ~name ~choices () =
let choices ~self =
let choices = choices ~self in
let rec go :
Expand All @@ -346,7 +346,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
let self, cache_handle, proof_module, provers =
compile_promise ?self ?cache ?storables ?proof_cache ?disk_keys
?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ ~branches
~max_proofs_verified ~name ?constraint_constants ~choices ()
~max_proofs_verified ~name ~choices ()
in
let rec adjust_provers :
type a1 a2 a3 s1 s2_inner.
Expand All @@ -363,7 +363,7 @@ module Make_str (_ : Wire_types.Concrete) = struct

let compile_async ?self ?cache ?storables ?proof_cache ?disk_keys
?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ ~branches
~max_proofs_verified ~name ?constraint_constants ~choices () =
~max_proofs_verified ~name ~choices () =
let choices ~self =
let choices = choices ~self in
let rec go :
Expand Down Expand Up @@ -391,7 +391,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
let self, cache_handle, proof_module, provers =
compile_promise ?self ?cache ?storables ?proof_cache ?disk_keys
?override_wrap_domain ?num_chunks ~public_input ~auxiliary_typ ~branches
~max_proofs_verified ~name ?constraint_constants ~choices ()
~max_proofs_verified ~name ~choices ()
in
let rec adjust_provers :
type a1 a2 a3 s1 s2_inner.
Expand Down
3 changes: 0 additions & 3 deletions src/lib/pickles/pickles_intf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ module type S = sig
-> max_proofs_verified:
(module Nat.Add.Intf with type n = 'max_proofs_verified)
-> name:string
-> ?constraint_constants:Snark_keys_header.Constraint_constants.t
-> choices:
( self:('var, 'value, 'max_proofs_verified, 'branches) Tag.t
-> ( 'prev_varss
Expand Down Expand Up @@ -470,7 +469,6 @@ module type S = sig
-> max_proofs_verified:
(module Nat.Add.Intf with type n = 'max_proofs_verified)
-> name:string
-> ?constraint_constants:Snark_keys_header.Constraint_constants.t
-> choices:
( self:('var, 'value, 'max_proofs_verified, 'branches) Tag.t
-> ( 'prev_varss
Expand Down Expand Up @@ -526,7 +524,6 @@ module type S = sig
-> max_proofs_verified:
(module Nat.Add.Intf with type n = 'max_proofs_verified)
-> name:string
-> ?constraint_constants:Snark_keys_header.Constraint_constants.t
-> choices:
( self:('var, 'value, 'max_proofs_verified, 'branches) Tag.t
-> ( 'prev_varss
Expand Down
Loading

0 comments on commit d3f9e39

Please sign in to comment.