@@ -13,6 +13,7 @@ module T = struct
13
13
; staged_ledger : Staged_ledger .t
14
14
; just_emitted_a_proof : bool
15
15
; transition_receipt_time : Time .t option
16
+ ; staged_ledger_hash : Staged_ledger_hash .t
16
17
}
17
18
[@@ deriving fields ]
18
19
@@ -31,17 +32,30 @@ module T = struct
31
32
32
33
let create ~validated_transition ~staged_ledger ~just_emitted_a_proof
33
34
~transition_receipt_time =
35
+ (* TODO This looks terrible, consider removing this in the hardfork by either
36
+ removing staged_ledger_hash from the header or computing it consistently
37
+ for the genesis block *)
38
+ let staged_ledger_hash =
39
+ if Mina_block.Validated. is_genesis validated_transition then
40
+ Staged_ledger. hash staged_ledger
41
+ else
42
+ Mina_block.Validated. header validated_transition
43
+ |> Mina_block.Header. protocol_state |> Protocol_state. blockchain_state
44
+ |> Blockchain_state. staged_ledger_hash
45
+ in
34
46
{ validated_transition
35
47
; staged_ledger
36
48
; just_emitted_a_proof
37
49
; transition_receipt_time
50
+ ; staged_ledger_hash
38
51
}
39
52
40
53
let to_yojson
41
54
{ validated_transition
42
55
; staged_ledger = _
43
56
; just_emitted_a_proof
44
57
; transition_receipt_time
58
+ ; staged_ledger_hash = _
45
59
} =
46
60
`Assoc
47
61
[ ( " validated_transition"
61
75
, staged_ledger
62
76
, just_emitted_a_proof
63
77
, transition_receipt_time
64
- , to_yojson )]
78
+ , to_yojson
79
+ , staged_ledger_hash )]
65
80
66
81
include Allocation_functor.Make. Basic (T )
67
82
@@ -398,7 +413,7 @@ module For_tests = struct
398
413
let body =
399
414
Mina_block.Body. create @@ Staged_ledger_diff. forget staged_ledger_diff
400
415
in
401
- let % bind ( `Hash_after_applying next_staged_ledger_hash
416
+ let % bind ( `Hash_after_applying staged_ledger_hash
402
417
, `Ledger_proof ledger_proof_opt
403
418
, `Staged_ledger _
404
419
, `Pending_coinbase_update _ ) =
@@ -436,7 +451,7 @@ module For_tests = struct
436
451
let next_blockchain_state =
437
452
Blockchain_state. create_value
438
453
~timestamp: (Block_time. now @@ Block_time.Controller. basic ~logger )
439
- ~staged_ledger_hash: next_staged_ledger_hash ~genesis_ledger_hash
454
+ ~staged_ledger_hash ~genesis_ledger_hash
440
455
~body_reference:
441
456
(Body. compute_reference
442
457
~tag: Mina_net2.Bitswap_tag. (to_enum Body )
0 commit comments