Skip to content

Commit e977188

Browse files
authored
Merge pull request #17790 from MinaProtocol/lyh/various-sig-kind-push-sep15
Various sig kind pushing
2 parents 371c411 + 10a6fd2 commit e977188

File tree

13 files changed

+75
-45
lines changed

13 files changed

+75
-45
lines changed

src/lib/bootstrap_controller/bootstrap_controller.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ let download_snarked_ledger ~trust_system ~preferred_peers ~transition_graph
288288
let run_cycle ~context:(module Context : CONTEXT) ~trust_system ~verifier
289289
~network ~consensus_local_state ~network_transition_pipe ~preferred_peers
290290
~persistent_root ~persistent_frontier ~initial_root_transition ~catchup_mode
291-
previous_cycles =
291+
~signature_kind previous_cycles =
292292
let open Context in
293293
(* The short-lived pipe allocated here will be closed
294294
when a follow-up pipe is allocated: in the next cycle of bootstrap
@@ -446,8 +446,7 @@ let run_cycle ~context:(module Context : CONTEXT) ~trust_system ~verifier
446446
|> Blockchain_state.snarked_local_state)
447447
~verifier ~constraint_constants ~scan_state
448448
~snarked_ledger:temp_mask ~expected_merkle_root
449-
~pending_coinbases ~get_state
450-
~signature_kind:Mina_signature_kind.t_DEPRECATED
449+
~pending_coinbases ~get_state ~signature_kind
451450
in
452451
ignore
453452
( Ledger.Maskable.unregister_mask_exn ~loc:__LOC__ temp_mask
@@ -679,14 +678,15 @@ let run_cycle ~context:(module Context : CONTEXT) ~trust_system ~verifier
679678
let run ~context:(module Context : CONTEXT) ~trust_system ~verifier ~network
680679
~consensus_local_state ~network_transition_pipe ~preferred_peers
681680
~persistent_root ~persistent_frontier ~initial_root_transition ~catchup_mode
682-
=
681+
~signature_kind =
683682
let open Context in
684683
let run_cycle =
685684
run_cycle
686685
~context:(module Context : CONTEXT)
687686
~trust_system ~verifier ~network ~consensus_local_state
688687
~network_transition_pipe ~preferred_peers ~persistent_root
689688
~persistent_frontier ~initial_root_transition ~catchup_mode
689+
~signature_kind
690690
in
691691
O1trace.thread "bootstrap"
692692
@@ fun () ->
@@ -905,7 +905,8 @@ let%test_module "Bootstrap_controller tests" =
905905
~trust_system ~verifier ~network:my_net.network ~preferred_peers:[]
906906
~consensus_local_state:my_net.state.consensus_local_state
907907
~network_transition_pipe ~persistent_root ~persistent_frontier
908-
~catchup_mode:`Super ~initial_root_transition )
908+
~catchup_mode:`Super ~initial_root_transition
909+
~signature_kind:Mina_signature_kind.t_DEPRECATED )
909910

910911
let assert_transitions_increasingly_sorted ~root
911912
(incoming_transitions : Transition_cache.element list) =

src/lib/bootstrap_controller/bootstrap_controller.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ val run :
5252
-> persistent_frontier:Transition_frontier.Persistent_frontier.t
5353
-> initial_root_transition:Mina_block.Validated.t
5454
-> catchup_mode:[ `Super ]
55+
-> signature_kind:Mina_signature_kind.t
5556
-> (Transition_frontier.t * Transition_cache.element list) Deferred.t

src/lib/mina_intf/transition_frontier_components_intf.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ module type Transition_router_intf = sig
341341
-> catchup_mode:[ `Super ]
342342
-> notify_online:(unit -> unit Deferred.t)
343343
-> ledger_backing:Mina_ledger.Ledger.Root.Config.backing_type
344+
-> signature_kind:Mina_signature_kind.t
344345
-> unit
345346
-> ( [ `Transition of Mina_block.Validated.t ]
346347
* [ `Source of [ `Gossip | `Catchup | `Internal ] ]

src/lib/mina_lib/mina_lib.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ let get_snarked_ledger_full t state_hash_opt =
726726
in
727727
Staged_ledger.Scan_state.get_snarked_ledger_async ~ledger
728728
~get_protocol_state ~apply_first_pass ~apply_second_pass
729-
~apply_first_pass_sparse_ledger
729+
~apply_first_pass_sparse_ledger ~signature_kind
730730
(Staged_ledger.scan_state
731731
(Transition_frontier.Breadcrumb.staged_ledger b) )
732732
|> Deferred.Result.map_error ~f:(fun e ->
@@ -2177,7 +2177,8 @@ let create ~commit_id ?wallets (config : Config.t) =
21772177
~most_recent_valid_block_writer
21782178
~get_completed_work:
21792179
(Network_pool.Snark_pool.get_completed_work snark_pool)
2180-
~notify_online ~transaction_pool_proxy ~ledger_backing ()
2180+
~notify_online ~transaction_pool_proxy ~ledger_backing
2181+
~signature_kind:Mina_signature_kind.t_DEPRECATED ()
21812182
in
21822183
let ( valid_transitions_for_network
21832184
, valid_transitions_for_api

src/lib/mina_lib/tests/tests.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ let%test_module "Epoch ledger sync tests" =
363363
~network_transition_reader:block_reader ~producer_transition_reader
364364
~get_most_recent_valid_block ~most_recent_valid_block_writer
365365
~notify_online ?transaction_pool_proxy:None ~ledger_backing:Stable_db
366-
()
366+
~signature_kind:Mina_signature_kind.t_DEPRECATED ()
367367
in
368368
let%bind () = Ivar.read initialization_finish_signal in
369369
let tr_tm1 = Unix.gettimeofday () in

src/lib/staged_ledger/staged_ledger.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ module T = struct
362362
Scan_state.get_staged_ledger_async
363363
~async_batch_size:transaction_application_scheduler_batch_size
364364
~ledger:snarked_ledger ~get_protocol_state:get_state ~apply_first_pass
365-
~apply_second_pass ~apply_first_pass_sparse_ledger scan_state
365+
~apply_second_pass ~apply_first_pass_sparse_ledger ~signature_kind
366+
scan_state
366367
in
367368
let staged_ledger_hash = Ledger.merkle_root snarked_ledger in
368369
let%bind () =
@@ -2834,7 +2835,8 @@ let%test_module "staged ledger tests" =
28342835
Sl.Scan_state.get_snarked_ledger_async
28352836
~ledger:snarked_ledger ~get_protocol_state:get_state
28362837
~apply_first_pass ~apply_second_pass
2837-
~apply_first_pass_sparse_ledger !sl.scan_state
2838+
~apply_first_pass_sparse_ledger ~signature_kind
2839+
!sl.scan_state
28382840
in
28392841
let target_snarked_ledger =
28402842
let stmt = Ledger_proof.Cached.statement proof in

src/lib/staged_ledger/staged_ledger.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ module Scan_state : sig
110110
-> Mina_transaction.Transaction.t
111111
-> Mina_ledger.Sparse_ledger.T.Transaction_partially_applied.t
112112
Or_error.t )
113+
-> signature_kind:Mina_signature_kind.t
113114
-> t
114115
-> unit Or_error.t
115116

@@ -141,6 +142,7 @@ module Scan_state : sig
141142
-> Mina_transaction.Transaction.t
142143
-> Mina_ledger.Sparse_ledger.T.Transaction_partially_applied.t
143144
Or_error.t )
145+
-> signature_kind:Mina_signature_kind.t
144146
-> t
145147
-> unit Deferred.Or_error.t
146148

src/lib/transaction_snark_scan_state/transaction_snark_scan_state.ml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
965965
expected_status status
966966
(Ledger.Transaction_partially_applied.command partially_applied_txn)
967967
in
968-
let apply_previous_incomplete_txns ~k (txns : Previous_incomplete_txns.t) =
968+
let apply_previous_incomplete_txns ~signature_kind ~k
969+
(txns : Previous_incomplete_txns.t) =
969970
(*Note: Previous incomplete transactions refer to the block's transactions from previous scan state tree that were split between the two trees.
970971
The set in the previous tree have gone through the first pass. For the second pass that is to happen after the rest of the set goes through the first pass, we need partially applied state - result of previous tree's transactions' first pass. To generate the partial state, we do a first pass application of previous tree's transaction on a sparse ledger created from witnesses stored in the scan state and then use it to apply to the ledger here*)
971972
let inject_ledger_info partially_applied_txn =
@@ -1016,7 +1017,7 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
10161017
{ command = t.command
10171018
; previous_hash = t.previous_hash
10181019
; original_first_pass_account_states
1019-
; signature_kind = Mina_signature_kind.t_DEPRECATED
1020+
; signature_kind
10201021
; constraint_constants = t.constraint_constants
10211022
; state_view = t.state_view
10221023
; global_state
@@ -1068,7 +1069,7 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
10681069
in
10691070
let rec apply_txns (previous_incomplete : Previous_incomplete_txns.t)
10701071
(ordered_txns : _ Transactions_ordered.Poly.t list)
1071-
~first_pass_ledger_hash =
1072+
~first_pass_ledger_hash ~signature_kind =
10721073
let previous_incomplete =
10731074
(*filter out any non-zkapp transactions for second pass application*)
10741075
match previous_incomplete with
@@ -1090,8 +1091,9 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
10901091
in
10911092
match ordered_txns with
10921093
| [] ->
1093-
apply_previous_incomplete_txns previous_incomplete ~k:(fun () ->
1094-
Ok (`Complete first_pass_ledger_hash) )
1094+
apply_previous_incomplete_txns ~signature_kind
1095+
~k:(fun () -> Ok (`Complete first_pass_ledger_hash))
1096+
previous_incomplete
10951097
| [ txns_per_block ] when stop_at_first_pass ->
10961098
(*Last block; don't apply second pass. This is for snarked ledgers which are first pass ledgers*)
10971099
apply_txns_first_pass txns_per_block.first_pass
@@ -1100,13 +1102,14 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
11001102
then there’d be at least two sets of txns_per_block and the
11011103
previous_incomplete txns will be applied when processing the first
11021104
set. The subsequent sets shouldn’t have any previous-incomplete.*)
1103-
apply_txns (Unapplied []) [] ~first_pass_ledger_hash )
1105+
apply_txns (Unapplied []) [] ~first_pass_ledger_hash ~signature_kind )
11041106
| txns_per_block :: ordered_txns' ->
11051107
(*Apply first pass of a blocks transactions either new or continued from previous tree*)
11061108
apply_txns_first_pass txns_per_block.first_pass
11071109
~k:(fun first_pass_ledger_hash partially_applied_txns ->
11081110
(*Apply second pass of previous tree's transactions, if any*)
1109-
apply_previous_incomplete_txns previous_incomplete ~k:(fun () ->
1111+
apply_previous_incomplete_txns previous_incomplete ~signature_kind
1112+
~k:(fun () ->
11101113
let continue_previous_tree's_txns =
11111114
(* If this is a continuation from previous tree for the same block (incomplete txns in both sets) then do second pass now*)
11121115
let previous_not_empty =
@@ -1127,11 +1130,11 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
11271130
if do_second_pass then
11281131
apply_txns_second_pass partially_applied_txns ~k:(fun () ->
11291132
apply_txns (Unapplied []) ordered_txns'
1130-
~first_pass_ledger_hash )
1133+
~first_pass_ledger_hash ~signature_kind )
11311134
else
11321135
(*Transactions not completed in this tree, so second pass after first pass of remaining transactions for the same block in the next tree*)
11331136
apply_txns (Partially_applied partially_applied_txns)
1134-
ordered_txns' ~first_pass_ledger_hash ) )
1137+
ordered_txns' ~first_pass_ledger_hash ~signature_kind ) )
11351138
in
11361139
let previous_incomplete =
11371140
Option.value_map (List.hd ordered_txns)
@@ -1148,7 +1151,7 @@ let apply_ordered_txns_stepwise ?(stop_at_first_pass = false) ordered_txns
11481151

11491152
let apply_ordered_txns_sync ?stop_at_first_pass ordered_txns ~ledger
11501153
~get_protocol_state ~apply_first_pass ~apply_second_pass
1151-
~apply_first_pass_sparse_ledger =
1154+
~apply_first_pass_sparse_ledger ~signature_kind =
11521155
let rec run = function
11531156
| Ok (`Continue k) ->
11541157
run (k ())
@@ -1160,11 +1163,11 @@ let apply_ordered_txns_sync ?stop_at_first_pass ordered_txns ~ledger
11601163
run
11611164
@@ apply_ordered_txns_stepwise ?stop_at_first_pass ordered_txns ~ledger
11621165
~get_protocol_state ~apply_first_pass ~apply_second_pass
1163-
~apply_first_pass_sparse_ledger
1166+
~apply_first_pass_sparse_ledger ~signature_kind
11641167

11651168
let apply_ordered_txns_async ?stop_at_first_pass ordered_txns
11661169
?(async_batch_size = 10) ~ledger ~get_protocol_state ~apply_first_pass
1167-
~apply_second_pass ~apply_first_pass_sparse_ledger =
1170+
~apply_second_pass ~apply_first_pass_sparse_ledger ~signature_kind =
11681171
let open Deferred.Result.Let_syntax in
11691172
let yield =
11701173
let f = Staged.unstage (Scheduler.yield_every ~n:async_batch_size) in
@@ -1183,36 +1186,38 @@ let apply_ordered_txns_async ?stop_at_first_pass ordered_txns
11831186
run
11841187
@@ apply_ordered_txns_stepwise ?stop_at_first_pass ordered_txns ~ledger
11851188
~get_protocol_state ~apply_first_pass ~apply_second_pass
1186-
~apply_first_pass_sparse_ledger
1189+
~apply_first_pass_sparse_ledger ~signature_kind
11871190

11881191
let get_snarked_ledger_sync ~ledger ~get_protocol_state ~apply_first_pass
1189-
~apply_second_pass ~apply_first_pass_sparse_ledger t =
1192+
~apply_second_pass ~apply_first_pass_sparse_ledger ~signature_kind t =
11901193
match latest_ledger_proof' t with
11911194
| None ->
11921195
Or_error.errorf "No transactions found"
11931196
| Some (_, txns_per_block) ->
11941197
apply_ordered_txns_sync ~stop_at_first_pass:true txns_per_block ~ledger
11951198
~get_protocol_state ~apply_first_pass ~apply_second_pass
1196-
~apply_first_pass_sparse_ledger
1199+
~apply_first_pass_sparse_ledger ~signature_kind
11971200
|> Or_error.ignore_m
11981201

11991202
let get_snarked_ledger_async ?async_batch_size ~ledger ~get_protocol_state
1200-
~apply_first_pass ~apply_second_pass ~apply_first_pass_sparse_ledger t =
1203+
~apply_first_pass ~apply_second_pass ~apply_first_pass_sparse_ledger
1204+
~signature_kind t =
12011205
match latest_ledger_proof' t with
12021206
| None ->
12031207
Deferred.Or_error.errorf "No transactions found"
12041208
| Some (_, txns_per_block) ->
12051209
apply_ordered_txns_async ~stop_at_first_pass:true txns_per_block
12061210
?async_batch_size ~ledger ~get_protocol_state ~apply_first_pass
1207-
~apply_second_pass ~apply_first_pass_sparse_ledger
1211+
~apply_second_pass ~apply_first_pass_sparse_ledger ~signature_kind
12081212
|> Deferred.Or_error.ignore_m
12091213

12101214
let get_staged_ledger_async ?async_batch_size ~ledger ~get_protocol_state
1211-
~apply_first_pass ~apply_second_pass ~apply_first_pass_sparse_ledger t =
1215+
~apply_first_pass ~apply_second_pass ~apply_first_pass_sparse_ledger
1216+
~signature_kind t =
12121217
let staged_transactions_with_state_hash = staged_transactions t in
12131218
apply_ordered_txns_async staged_transactions_with_state_hash ?async_batch_size
12141219
~ledger ~get_protocol_state ~apply_first_pass ~apply_second_pass
1215-
~apply_first_pass_sparse_ledger
1220+
~apply_first_pass_sparse_ledger ~signature_kind
12161221

12171222
let free_space t = Parallel_scan.free_space t.scan_state
12181223

src/lib/transaction_snark_scan_state/transaction_snark_scan_state.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ val get_snarked_ledger_sync :
138138
-> Mina_transaction.Transaction.t
139139
-> Mina_ledger.Sparse_ledger.T.Transaction_partially_applied.t
140140
Or_error.t )
141+
-> signature_kind:Mina_signature_kind.t
141142
-> t
142143
-> unit Or_error.t
143144

@@ -163,6 +164,7 @@ val get_snarked_ledger_async :
163164
-> Mina_transaction.Transaction.t
164165
-> Mina_ledger.Sparse_ledger.T.Transaction_partially_applied.t
165166
Or_error.t )
167+
-> signature_kind:Mina_signature_kind.t
166168
-> t
167169
-> unit Deferred.Or_error.t
168170

@@ -195,6 +197,7 @@ val get_staged_ledger_async :
195197
-> Mina_transaction.Transaction.t
196198
-> Mina_ledger.Sparse_ledger.T.Transaction_partially_applied.t
197199
Or_error.t )
200+
-> signature_kind:Mina_signature_kind.t
198201
-> t
199202
-> [ `First_pass_ledger_hash of Ledger_hash.t ] Deferred.Or_error.t
200203

src/lib/transition_frontier/full_frontier/full_frontier.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,11 @@ let move_root ({ context = (module Context); _ } as t) ~new_root_hash
508508
(State_hash.to_base58_check state_hash)
509509
in
510510
Or_error.ok_exn
511-
( Staged_ledger.Scan_state.get_snarked_ledger_sync ~ledger:mt
512-
~get_protocol_state ~apply_first_pass ~apply_second_pass
513-
~apply_first_pass_sparse_ledger
514-
(Staged_ledger.scan_state
515-
(Breadcrumb.staged_ledger new_root_node.breadcrumb) )
516-
: unit Or_error.t ) ;
511+
(Staged_ledger.Scan_state.get_snarked_ledger_sync ~ledger:mt
512+
~get_protocol_state ~apply_first_pass ~apply_second_pass
513+
~apply_first_pass_sparse_ledger ~signature_kind
514+
(Staged_ledger.scan_state
515+
(Breadcrumb.staged_ledger new_root_node.breadcrumb) ) ) ;
517516
(*Check that the new snarked ledger is as expected*)
518517
let new_snarked_ledger_hash = Ledger.merkle_root mt in
519518
let expected_snarked_ledger_hash =

0 commit comments

Comments
 (0)