@@ -6,7 +6,6 @@ open Cache_lib
6
6
open Pipe_lib
7
7
open Mina_numbers
8
8
open Mina_base
9
- open Mina_block
10
9
open Network_peer
11
10
12
11
module type CONTEXT = sig
@@ -138,6 +137,7 @@ let verify_transition ~context:(module Context : CONTEXT) ~trust_system
138
137
let transition_with_hash = Envelope.Incoming. data enveloped_transition in
139
138
let cached_initially_validated_transition_result =
140
139
let open Result.Let_syntax in
140
+ let open Mina_block in
141
141
let % bind initially_validated_transition =
142
142
transition_with_hash
143
143
|> Validation. skip_time_received_validation
@@ -150,20 +150,20 @@ let verify_transition ~context:(module Context : CONTEXT) ~trust_system
150
150
Envelope.Incoming. map enveloped_transition
151
151
~f: (Fn. const initially_validated_transition)
152
152
in
153
- Transition_handler.Validator. validate_transition
153
+ Transition_handler.Validator. validate_transition_is_relevant
154
154
~context: (module Context )
155
155
~frontier ~unprocessed_transition_cache ~slot_tx_end ~slot_chain_end
156
156
enveloped_initially_validated_transition
157
157
in
158
158
let state_hash =
159
- Validation. block_with_hash transition_with_hash
159
+ Mina_block. Validation. block_with_hash transition_with_hash
160
160
|> State_hash.With_state_hashes. state_hash |> State_hash. to_yojson
161
161
in
162
162
let open Deferred.Let_syntax in
163
163
match cached_initially_validated_transition_result with
164
164
| Ok x ->
165
165
Internal_tracing. with_state_hash
166
- ( Validation. block_with_hash transition_with_hash
166
+ ( Mina_block. Validation. block_with_hash transition_with_hash
167
167
|> State_hash.With_state_hashes. state_hash )
168
168
@@ fun () ->
169
169
[% log internal] " Validate_transition_done" ;
@@ -237,20 +237,20 @@ let verify_transition ~context:(module Context : CONTEXT) ~trust_system
237
237
[% log warn]
238
238
~metadata: [ (" state_hash" , state_hash) ]
239
239
" initial_validate: invalid protocol version" ;
240
- let transition = Validation. block transition_with_hash in
240
+ let transition = Mina_block. Validation. block transition_with_hash in
241
241
let % map () =
242
242
Trust_system. record_envelope_sender trust_system logger sender
243
243
( Trust_system.Actions. Sent_invalid_protocol_version
244
244
, Some
245
245
( " Invalid current or proposed protocol version in catchup block"
246
246
, [ ( " current_protocol_version"
247
247
, `String
248
- ( Header. current_protocol_version
248
+ ( Mina_block. Header. current_protocol_version
249
249
(Mina_block. header transition)
250
250
|> Protocol_version. to_string ) )
251
251
; ( " proposed_protocol_version"
252
252
, `String
253
- ( Header. proposed_protocol_version_opt
253
+ ( Mina_block. Header. proposed_protocol_version_opt
254
254
(Mina_block. header transition)
255
255
|> Option. value_map ~default: " <None>"
256
256
~f: Protocol_version. to_string ) )
@@ -261,7 +261,7 @@ let verify_transition ~context:(module Context : CONTEXT) ~trust_system
261
261
[% log warn]
262
262
~metadata: [ (" state_hash" , state_hash) ]
263
263
" initial_validate: mismatch protocol version" ;
264
- let transition = Validation. block transition_with_hash in
264
+ let transition = Mina_block. Validation. block transition_with_hash in
265
265
let % map () =
266
266
Trust_system. record_envelope_sender trust_system logger sender
267
267
( Trust_system.Actions. Sent_mismatched_protocol_version
@@ -270,7 +270,7 @@ let verify_transition ~context:(module Context : CONTEXT) ~trust_system
270
270
daemon protocol version"
271
271
, [ ( " block_current_protocol_version"
272
272
, `String
273
- ( Header. current_protocol_version
273
+ ( Mina_block. Header. current_protocol_version
274
274
(Mina_block. header transition)
275
275
|> Protocol_version. to_string ) )
276
276
; ( " daemon_current_protocol_version"
@@ -407,7 +407,7 @@ module Downloader = struct
407
407
type t = Mina_block .t
408
408
409
409
let key (t : t ) =
410
- ( ( Mina_block. header t |> Header. protocol_state
410
+ ( ( Mina_block. header t |> Mina_block. Header. protocol_state
411
411
|> Mina_state.Protocol_state. hashes )
412
412
.state_hash
413
413
, Mina_block. blockchain_length t )
@@ -520,8 +520,8 @@ module Initial_validate_batcher = struct
520
520
{ State_hash.State_hashes. state_hash
521
521
; state_body_hash = None
522
522
} )
523
- |> Validation. wrap )
524
- |> Validation. validate_proofs ~verifier ~genesis_state_hash
523
+ |> Mina_block. Validation. wrap )
524
+ |> Mina_block. Validation. validate_proofs ~verifier ~genesis_state_hash
525
525
>> | function
526
526
| Ok tvs ->
527
527
Ok (List. map tvs ~f: (fun x -> `Valid x))
@@ -543,7 +543,7 @@ module Verify_work_batcher = struct
543
543
let create ~verifier : _ t =
544
544
let works (x : input ) =
545
545
let wh, _ = x.data in
546
- Body. staged_ledger_diff (Mina_block. body wh.data)
546
+ Mina_block. Body. staged_ledger_diff (Mina_block. body wh.data)
547
547
|> Staged_ledger_diff. completed_works
548
548
in
549
549
create
@@ -555,7 +555,7 @@ module Verify_work_batcher = struct
555
555
~max_weight_per_call: 1000 ~how_to_add: `Insert
556
556
~compare_init: (fun e1 e2 ->
557
557
let len (x : input ) =
558
- Validation. block x.data |> Mina_block. blockchain_length
558
+ Mina_block. Validation. block x.data |> Mina_block. blockchain_length
559
559
in
560
560
match Length. compare (len e1) (len e2) with
561
561
| 0 ->
@@ -710,11 +710,11 @@ let create_node ~logger ~downloader t x =
710
710
| `Initial_validated (b , valid_cb ) ->
711
711
let t = (Cached. peek b).Envelope.Incoming. data in
712
712
let state_hash =
713
- Validation. block_with_hash t
713
+ Mina_block. Validation. block_with_hash t
714
714
|> State_hash.With_state_hashes. state_hash
715
715
in
716
716
let blockchain_length =
717
- Validation. block t |> Mina_block. blockchain_length
717
+ Mina_block. Validation. block t |> Mina_block. blockchain_length
718
718
in
719
719
Internal_tracing. with_state_hash state_hash
720
720
@@ fun () ->
@@ -726,9 +726,9 @@ let create_node ~logger ~downloader t x =
726
726
[% log internal] " To_verify" ;
727
727
( Node.State. To_verify (b, valid_cb)
728
728
, state_hash
729
- , Validation. block t |> Mina_block. blockchain_length
730
- , Validation. block t |> Mina_block. header
731
- |> Mina_block.Header. protocol_state
729
+ , Mina_block. Validation. block t |> Mina_block. blockchain_length
730
+ , Mina_block. Validation. block t
731
+ |> Mina_block. header |> Mina_block. Header. protocol_state
732
732
|> Mina_state.Protocol_state. previous_state_hash
733
733
, Ivar. create () )
734
734
in
@@ -954,7 +954,8 @@ let setup_state_machine_runner ~context:(module Context : CONTEXT) ~t ~verifier
954
954
let av =
955
955
{ av with
956
956
data =
957
- Validation. skip_frontier_dependencies_validation
957
+ Mina_block. Validation
958
+ .skip_frontier_dependencies_validation
958
959
`This_block_belongs_to_a_detached_subtree av.data
959
960
}
960
961
in
@@ -1105,7 +1106,9 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1105
1106
combine ! best
1106
1107
(Some
1107
1108
(With_hash. map
1108
- ~f: (Fn. compose Header. protocol_state Mina_block. header)
1109
+ ~f:
1110
+ (Fn. compose Mina_block.Header. protocol_state
1111
+ Mina_block. header )
1109
1112
x ) ) ) ;
1110
1113
! best
1111
1114
in
@@ -1203,15 +1206,16 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1203
1206
let target_length =
1204
1207
let len =
1205
1208
forest_pick forest |> Tuple2. get1 |> Cached. peek
1206
- |> Envelope.Incoming. data |> Validation. block
1209
+ |> Envelope.Incoming. data |> Mina_block. Validation. block
1207
1210
|> Mina_block. blockchain_length
1208
1211
in
1209
1212
Option. value_exn (Length. sub len (Length. of_int 1 ))
1210
1213
in
1211
1214
let blockchain_length_of_target_hash =
1212
1215
let blockchain_length_of_dangling_block =
1213
1216
List. hd_exn forest |> Rose_tree. root |> Tuple2. get1
1214
- |> Cached. peek |> Envelope.Incoming. data |> Validation. block
1217
+ |> Cached. peek |> Envelope.Incoming. data
1218
+ |> Mina_block.Validation. block
1215
1219
|> Mina_block. blockchain_length
1216
1220
in
1217
1221
Unsigned.UInt32. pred blockchain_length_of_dangling_block
@@ -1222,7 +1226,8 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1222
1226
~f: (fun (c , _vc ) ->
1223
1227
let h =
1224
1228
State_hash.With_state_hashes. state_hash
1225
- (Validation. block_with_hash (Cached. peek c).data)
1229
+ (Mina_block.Validation. block_with_hash
1230
+ (Cached. peek c).data )
1226
1231
in
1227
1232
( match (Cached. peek c).sender with
1228
1233
| Local ->
@@ -1236,7 +1241,8 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1236
1241
let % bind.Option p =
1237
1242
Transition_chain_verifier. verify ~target_hash: h
1238
1243
~transition_chain_proof:
1239
- ( ( Mina_block. header root |> Header. protocol_state
1244
+ ( ( Mina_block. header root
1245
+ |> Mina_block.Header. protocol_state
1240
1246
|> Mina_state.Protocol_state. hashes )
1241
1247
.state_hash
1242
1248
, path )
@@ -1288,7 +1294,7 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1288
1294
~f: (fun (cached_transition , _vc ) ->
1289
1295
Cached. peek cached_transition
1290
1296
|> Envelope.Incoming. data
1291
- |> Validation. block_with_hash
1297
+ |> Mina_block. Validation. block_with_hash
1292
1298
|> State_hash.With_state_hashes. state_hash )
1293
1299
in
1294
1300
[% log error]
@@ -1299,16 +1305,18 @@ let run_catchup ~context:(module Context : CONTEXT) ~trust_system ~verifier
1299
1305
~f: State_hash. to_yojson ) )
1300
1306
; ( " state_hash"
1301
1307
, State_hash. to_yojson
1302
- ( Validation. block_with_hash transition
1308
+ ( Mina_block.Validation. block_with_hash
1309
+ transition
1303
1310
|> State_hash.With_state_hashes. state_hash )
1304
1311
)
1305
1312
; ( " reason"
1306
1313
, `String
1307
1314
" no common ancestor with our transition \
1308
1315
frontier" )
1309
1316
; ( " protocol_state"
1310
- , Validation. block transition
1311
- |> Mina_block. header |> Header. protocol_state
1317
+ , Mina_block.Validation. block transition
1318
+ |> Mina_block. header
1319
+ |> Mina_block.Header. protocol_state
1312
1320
|> Mina_state.Protocol_state. value_to_yojson )
1313
1321
]
1314
1322
" Validation error: external transition with state \
@@ -1449,9 +1457,10 @@ let%test_module "Ledger_catchup tests" =
1449
1457
~pids:(Child_processes.Termination.create_pid_table ())) *)
1450
1458
1451
1459
let downcast_transition transition =
1460
+ let open Mina_block.Validation in
1452
1461
let transition =
1453
- transition |> Validation. reset_frontier_dependencies_validation
1454
- |> Validation. reset_staged_ledger_diff_validation
1462
+ transition |> reset_frontier_dependencies_validation
1463
+ |> reset_staged_ledger_diff_validation
1455
1464
in
1456
1465
Envelope.Incoming. wrap ~data: transition ~sender: Envelope.Sender. Local
1457
1466
0 commit comments