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

MinaProtocol / mina / 125

27 Apr 2025 07:35PM UTC coverage: 32.491% (-28.4%) from 60.865%
125

push

buildkite

web-flow
Merge pull request #16925 from zeko-labs/fix-aarch64

Fix support for aarch64-linux

23315 of 71759 relevant lines covered (32.49%)

25158.68 hits per line

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

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

24✔
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 =
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 =
11
  { account_update; account_update_digest = (); calls = mk_forest calls }
×
12

13
let mk_account_update_body ?preconditions ?(increment_nonce = false)
×
14
    ?(update = Account_update.Update.noop) authorization_kind may_use_token kp
×
15
    token_id balance_change : Account_update.Body.Simple.t =
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
26
  { update
×
27
  ; public_key = Public_key.compress kp.Keypair.public_key
×
28
  ; token_id
29
  ; balance_change =
30
      Currency.Amount.Signed.create
31
        ~magnitude:
32
          (Currency.Amount.of_nanomina_int_exn (Int.abs balance_change))
×
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 =
48
  let fee_payer : Account_update.Fee_payer.t =
×
49
    { body =
50
        { public_key = fee_payer_pk
51
        ; fee = Currency.Fee.of_nanomina_int_exn fee
×
52
        ; valid_until = None
53
        ; nonce = fee_payer_nonce
54
        }
55
    ; authorization = Signature.dummy
56
    }
57
  in
58
  let memo =
59
    Option.value_map memo ~default:Signed_command_memo.dummy
60
      ~f:Signed_command_memo.create_from_string_exn
61
  in
62
  Zkapp_command.map_proofs
×
63
    ~f:(const @@ Lazy.force Proof.For_tests.blockchain_dummy_tag)
×
64
    { Zkapp_command.Poly.fee_payer
65
    ; memo
66
    ; account_updates =
67
        Zkapp_command.Call_forest.map account_updates
×
68
          ~f:(fun (p : Account_update.Body.Simple.t) ->
69
            let authorization =
×
70
              match p.authorization_kind with
71
              | None_given ->
×
72
                  Control.Poly.None_given
73
              | Proof _ ->
×
74
                  Control.Poly.Proof
75
                    (Lazy.force Mina_base.Proof.blockchain_dummy)
×
76
              | Signature ->
×
77
                  Control.Poly.Signature Signature.dummy
78
            in
79
            { Account_update.Poly.body = Account_update.Body.of_simple p
×
80
            ; authorization
81
            } )
82
        |> Zkapp_command.Call_forest.accumulate_hashes_predicated
×
83
    }
84

85
let proof_cache_db = Proof_cache_tag.For_tests.create_db ()
24✔
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 =
92
  let txn_commitment, full_txn_commitment =
×
93
    Zkapp_command.get_transaction_commitments zkapp_command
94
  in
95
  let sign_for_account_update ~use_full_commitment sk =
×
96
    let commitment =
×
97
      if use_full_commitment then full_txn_commitment else txn_commitment
×
98
    in
99
    Signature_lib.Schnorr.Chunked.sign sk
100
      (Random_oracle.Input.Chunked.field commitment)
×
101
  in
102
  let fee_payer_sk =
103
    Signature_lib.Public_key.Compressed.Map.find_exn keymap
104
      zkapp_command.fee_payer.body.public_key
105
  in
106
  let fee_payer_signature =
×
107
    sign_for_account_update ~use_full_commitment:true fee_payer_sk
108
  in
109
  let fee_payer_with_valid_signature =
×
110
    { zkapp_command.fee_payer with authorization = fee_payer_signature }
111
  in
112
  let open Async_kernel.Deferred.Let_syntax in
113
  let%map account_updates_with_valid_authorizations =
114
    Zkapp_command.Call_forest.deferred_mapi zkapp_command.account_updates
×
115
      ~f:(fun _ndx ({ body; authorization } : _ Account_update.Poly.t) tree ->
116
        let%map valid_authorization =
117
          match authorization with
118
          | Control.Poly.Signature _dummy ->
×
119
              let pk = body.Account_update.Body.public_key in
120
              let sk =
121
                match
122
                  Signature_lib.Public_key.Compressed.Map.find keymap pk
123
                with
124
                | Some sk ->
×
125
                    sk
126
                | None ->
×
127
                    failwithf
×
128
                      "Could not find private key for public key %s in keymap"
129
                      (Signature_lib.Public_key.Compressed.to_base58_check pk)
×
130
                      ()
131
              in
132
              let use_full_commitment = body.use_full_commitment in
133
              let signature = sign_for_account_update ~use_full_commitment sk in
134
              return (Control.Poly.Signature signature)
×
135
          | Proof _proof -> (
×
136
              match prover with
137
              | None ->
×
138
                  return authorization
×
139
              | Some prover ->
×
140
                  let txn_stmt = Zkapp_statement.of_tree tree in
141
                  let handler
×
142
                      (Snarky_backendless.Request.With { request; respond }) =
143
                    match request with _ -> respond Unhandled
×
144
                  in
145
                  let%map (), (), proof =
146
                    prover ?handler:(Some handler) txn_stmt
×
147
                  in
148
                  Control.Poly.Proof
×
149
                    (Proof_cache_tag.write_proof_to_disk proof_cache_db proof) )
×
150
          | None_given ->
×
151
              return authorization
×
152
        in
153
        { Account_update.Poly.body; authorization = valid_authorization } )
×
154
  in
155
  { zkapp_command with
×
156
    fee_payer = fee_payer_with_valid_signature
157
  ; account_updates = account_updates_with_valid_authorizations
158
  }
48✔
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