@@ -287,18 +287,19 @@ struct
287
287
; verifier : (Verifier .t [@ sexp.opaque])
288
288
; genesis_constants : Genesis_constants .t
289
289
; slot_tx_end : Mina_numbers.Global_slot_since_hard_fork .t option
290
+ ; vk_cache_db : Zkapp_vk_cache_tag .cache_db
290
291
}
291
- [@@ deriving sexp_of ]
292
292
293
293
(* remove next line if there's a way to force [@@deriving make] write a
294
294
named parameter instead of an optional parameter *)
295
295
let make ~trust_system ~pool_max_size ~verifier ~genesis_constants
296
- ~slot_tx_end =
296
+ ~slot_tx_end ~ vk_cache_db =
297
297
{ trust_system
298
298
; pool_max_size
299
299
; verifier
300
300
; genesis_constants
301
301
; slot_tx_end
302
+ ; vk_cache_db
302
303
}
303
304
end
304
305
@@ -331,15 +332,17 @@ struct
331
332
module Vk_refcount_table = struct
332
333
type t =
333
334
{ verification_keys :
334
- (int * Verification_key_wire .t ) Zkapp_basic.F_map.Table .t
335
+ (int * Zkapp_vk_cache_tag .t ) Zkapp_basic.F_map.Table .t
335
336
; account_id_to_vks : int Zkapp_basic.F_map.Map .t Account_id.Table .t
336
337
; vk_to_account_ids : int Account_id.Map .t Zkapp_basic.F_map.Table .t
338
+ ; vk_cache_db : Zkapp_vk_cache_tag .cache_db
337
339
}
338
340
339
- let create () =
341
+ let create vk_cache_db () =
340
342
{ verification_keys = Zkapp_basic.F_map.Table. create ()
341
343
; account_id_to_vks = Account_id.Table. create ()
342
344
; vk_to_account_ids = Zkapp_basic.F_map.Table. create ()
345
+ ; vk_cache_db
343
346
}
344
347
345
348
let find_vk (t : t ) = Hashtbl. find t.verification_keys
@@ -365,7 +368,7 @@ struct
365
368
in
366
369
Hashtbl. update t.verification_keys vk.hash ~f: (function
367
370
| None ->
368
- (1 , vk)
371
+ (1 , Zkapp_vk_cache_tag. write_key_to_disk t.vk_cache_db vk)
369
372
| Some (count , vk ) ->
370
373
(count + 1 , vk) ) ;
371
374
Hashtbl. update t.account_id_to_vks account_id
@@ -425,13 +428,12 @@ struct
425
428
; mutable current_batch : int
426
429
; mutable remaining_in_batch : int
427
430
; config : Config .t
428
- ; logger : ( Logger .t [ @ sexp.opaque])
431
+ ; logger : Logger .t
429
432
; batcher : Batcher .t
430
- ; mutable best_tip_diff_relay : ( unit Deferred .t [ @ sexp.opaque]) Option .t
431
- ; mutable best_tip_ledger : ( Base_ledger .t [ @ sexp.opaque]) Option .t
432
- ; verification_key_table : ( Vk_refcount_table .t [ @ sexp.opaque])
433
+ ; mutable best_tip_diff_relay : unit Deferred .t Option .t
434
+ ; mutable best_tip_ledger : Base_ledger .t Option .t
435
+ ; verification_key_table : Vk_refcount_table .t
433
436
}
434
- [@@ deriving sexp_of ]
435
437
436
438
let member t x =
437
439
Indexed_pool. member t.pool (Transaction_hash.User_command. of_checked x)
@@ -837,7 +839,8 @@ struct
837
839
; batcher = Batcher. create ~logger config.verifier
838
840
; best_tip_diff_relay = None
839
841
; best_tip_ledger = None
840
- ; verification_key_table = Vk_refcount_table. create ()
842
+ ; verification_key_table =
843
+ Vk_refcount_table. create config.vk_cache_db ()
841
844
}
842
845
in
843
846
don't_wait_for
@@ -1169,7 +1172,12 @@ struct
1169
1172
in
1170
1173
let vks =
1171
1174
vks
1172
- |> List. map ~f: (fun vk -> (vk.hash, vk))
1175
+ |> List. map ~f: (fun vk_cached ->
1176
+ let vk =
1177
+ Zkapp_vk_cache_tag. read_key_from_disk
1178
+ vk_cached
1179
+ in
1180
+ (vk.hash, vk) )
1173
1181
|> Zkapp_basic.F_map.Map. of_alist_exn
1174
1182
in
1175
1183
(account_id, vks) )
@@ -1930,6 +1938,7 @@ let%test_module _ =
1930
1938
let config =
1931
1939
Test.Resource_pool. make_config ~trust_system ~pool_max_size ~verifier
1932
1940
~genesis_constants ~slot_tx_end
1941
+ ~vk_cache_db: (Zkapp_vk_cache_tag.For_tests. create_db () )
1933
1942
in
1934
1943
let pool_, _, _ =
1935
1944
Test. create ~config ~logger ~constraint_constants ~consensus_constants
0 commit comments