• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 411

24 Jul 2025 03:14PM UTC coverage: 33.188% (-27.7%) from 60.871%
411

push

buildkite

web-flow
Merge pull request #17541 from MinaProtocol/brian/merge-compatible-into-develop

Merge compatible into develop

164 of 702 new or added lines in 96 files covered. (23.36%)

18243 existing lines in 393 files now uncovered.

23983 of 72264 relevant lines covered (33.19%)

24667.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.0
/src/lib/zkapp_command_builder/zkapp_command_builder.ml
1
(* zkapp_command_builder.ml -- combinators to build Zkapp_command.t for tests *)
2

81✔
3
open Core_kernel
4
open Mina_base
5

6
let mk_forest ps :
7
    (Account_update.Body.Simple.t, unit, unit) Zkapp_command.Call_forest.t =
UNCOV
8
  List.map ps ~f:(fun p -> { With_stack_hash.elt = p; stack_hash = () })
×
9

10
let mk_node account_update calls : _ Zkapp_command.Call_forest.Tree.t =
UNCOV
11
  { account_update; account_update_digest = (); calls = mk_forest calls }
×
12

UNCOV
13
let mk_account_update_body ?preconditions ?(increment_nonce = false)
×
UNCOV
14
    ?(update = Account_update.Update.noop) authorization_kind may_use_token kp
×
15
    token_id balance_change : Account_update.Body.Simple.t =
UNCOV
16
  let open Signature_lib in
×
17
  let preconditions =
18
    Option.value preconditions
19
      ~default:
20
        Account_update.Preconditions.
21
          { network = Zkapp_precondition.Protocol_state.accept
22
          ; account = Zkapp_precondition.Account.accept
23
          ; valid_while = Ignore
24
          }
25
  in
UNCOV
26
  { update
×
UNCOV
27
  ; public_key = Public_key.compress kp.Keypair.public_key
×
28
  ; token_id
29
  ; balance_change =
30
      Currency.Amount.Signed.create
31
        ~magnitude:
UNCOV
32
          (Currency.Amount.of_nanomina_int_exn (Int.abs balance_change))
×
UNCOV
33
        ~sgn:(if Int.is_negative balance_change then Sgn.Neg else Pos)
×
34
  ; increment_nonce
35
  ; events = []
36
  ; actions = []
37
  ; call_data = Pickles.Impls.Step.Field.Constant.zero
38
  ; call_depth = 0
39
  ; preconditions
40
  ; use_full_commitment = true
41
  ; implicit_account_creation_fee = false
42
  ; may_use_token
43
  ; authorization_kind
44
  }
45

46
let mk_zkapp_command ?memo ~fee ~fee_payer_pk ~fee_payer_nonce account_updates :
47
    Zkapp_command.t =
UNCOV
48
  let signature_kind = Mina_signature_kind.t_DEPRECATED in
×
49
  let fee_payer : Account_update.Fee_payer.t =
50
    Account_update.Fee_payer.make
51
      ~body:
52
        { public_key = fee_payer_pk
UNCOV
53
        ; fee = Currency.Fee.of_nanomina_int_exn fee
×
54
        ; valid_until = None
55
        ; nonce = fee_payer_nonce
56
        }
57
      ~authorization:Signature.dummy
58
  in
59
  let memo =
60
    Option.value_map memo ~default:Signed_command_memo.dummy
61
      ~f:Signed_command_memo.create_from_string_exn
62
  in
UNCOV
63
  Zkapp_command.write_all_proofs_to_disk ~signature_kind
×
UNCOV
64
    ~proof_cache_db:(Proof_cache_tag.For_tests.create_db ())
×
65
    { Zkapp_command.Poly.fee_payer
66
    ; memo
67
    ; account_updates =
UNCOV
68
        Zkapp_command.Call_forest.map account_updates
×
69
          ~f:(fun (body : Account_update.Body.Simple.t) ->
UNCOV
70
            let authorization =
×
71
              match body.authorization_kind with
UNCOV
72
              | None_given ->
×
73
                  Control.Poly.None_given
UNCOV
74
              | Proof _ ->
×
75
                  Control.Poly.Proof
UNCOV
76
                    (Lazy.force Mina_base.Proof.blockchain_dummy)
×
UNCOV
77
              | Signature ->
×
78
                  Control.Poly.Signature Signature.dummy
79
            in
80
            Account_update.with_no_aux
UNCOV
81
              ~body:(Account_update.Body.of_simple body)
×
82
              ~authorization )
83
    }
84

85
let proof_cache_db = Proof_cache_tag.For_tests.create_db ()
81✔
86

87
(* replace dummy signatures, proofs with valid ones for fee payer, other zkapp_command
88
   [keymap] maps compressed public keys to private keys
89
*)
90
let replace_authorizations ?prover ~keymap (zkapp_command : Zkapp_command.t) :
91
    Zkapp_command.t Async_kernel.Deferred.t =
UNCOV
92
  let signature_kind = Mina_signature_kind.t_DEPRECATED in
×
93
  let txn_commitment, full_txn_commitment =
94
    Zkapp_command.get_transaction_commitments ~signature_kind zkapp_command
95
  in
UNCOV
96
  let sign_for_account_update ~use_full_commitment sk =
×
UNCOV
97
    let commitment =
×
UNCOV
98
      if use_full_commitment then full_txn_commitment else txn_commitment
×
99
    in
100
    let signature_kind = Mina_signature_kind.t_DEPRECATED in
101
    Signature_lib.Schnorr.Chunked.sign ~signature_kind sk
UNCOV
102
      (Random_oracle.Input.Chunked.field commitment)
×
103
  in
104
  let fee_payer_sk =
105
    Signature_lib.Public_key.Compressed.Map.find_exn keymap
106
      zkapp_command.fee_payer.body.public_key
107
  in
UNCOV
108
  let fee_payer_signature =
×
109
    sign_for_account_update ~use_full_commitment:true fee_payer_sk
110
  in
UNCOV
111
  let fee_payer_with_valid_signature =
×
112
    { zkapp_command.fee_payer with authorization = fee_payer_signature }
113
  in
114
  let open Async_kernel.Deferred.Let_syntax in
115
  let%map account_updates_with_valid_authorizations =
UNCOV
116
    Zkapp_command.Call_forest.deferred_mapi zkapp_command.account_updates
×
117
      ~f:(fun _ndx ({ body; authorization; aux } : _ Account_update.Poly.t) tree
118
         ->
119
        let%map valid_authorization =
120
          match authorization with
UNCOV
121
          | Control.Poly.Signature _dummy ->
×
122
              let pk = body.Account_update.Body.public_key in
123
              let sk =
124
                match
125
                  Signature_lib.Public_key.Compressed.Map.find keymap pk
126
                with
UNCOV
127
                | Some sk ->
×
128
                    sk
129
                | None ->
×
130
                    failwithf
×
131
                      "Could not find private key for public key %s in keymap"
132
                      (Signature_lib.Public_key.Compressed.to_base58_check pk)
×
133
                      ()
134
              in
135
              let use_full_commitment = body.use_full_commitment in
136
              let signature = sign_for_account_update ~use_full_commitment sk in
UNCOV
137
              return (Control.Poly.Signature signature)
×
UNCOV
138
          | Proof _proof -> (
×
139
              match prover with
UNCOV
140
              | None ->
×
UNCOV
141
                  return authorization
×
UNCOV
142
              | Some prover ->
×
143
                  let txn_stmt = Zkapp_statement.of_tree tree in
UNCOV
144
                  let handler
×
145
                      (Snarky_backendless.Request.With { request; respond }) =
UNCOV
146
                    match request with _ -> respond Unhandled
×
147
                  in
148
                  let%map (), (), proof =
UNCOV
149
                    prover ?handler:(Some handler) txn_stmt
×
150
                  in
UNCOV
151
                  Control.Poly.Proof
×
UNCOV
152
                    (Proof_cache_tag.write_proof_to_disk proof_cache_db proof) )
×
UNCOV
153
          | None_given ->
×
UNCOV
154
              return authorization
×
155
        in
UNCOV
156
        { Account_update.Poly.body; authorization = valid_authorization; aux } )
×
157
  in
UNCOV
158
  { zkapp_command with
×
159
    fee_payer = fee_payer_with_valid_signature
160
  ; account_updates = account_updates_with_valid_authorizations
161
  }
162✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc