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

MinaProtocol / mina / 2863

05 Nov 2024 06:20PM UTC coverage: 30.754% (-16.6%) from 47.311%
2863

push

buildkite

web-flow
Merge pull request #16296 from MinaProtocol/dkijania/more_multi_jobs

more multi jobs in CI

20276 of 65930 relevant lines covered (30.75%)

8631.7 hits per line

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

20.51
/src/lib/transition_frontier/frontier_base/diff.ml
1
open Core_kernel
3✔
2
open Mina_base
3

4
type full = Full
5

6
type lite = Lite
7

8
module Node = struct
9
  type 'a t =
10
    | Full : Breadcrumb.t -> full t
11
    | Lite : Mina_block.Validated.Stable.V2.t -> lite t
12
end
13

14
module Node_list = struct
15
  type full_node =
16
    { transition : Mina_block.Validated.t
17
    ; scan_state : Staged_ledger.Scan_state.t
18
    }
19

20
  type lite_node = State_hash.t
21

22
  (* Full representation unfortunately cannot be breadcrumbs since they
23
   * will no longer be linked after mutation *)
24
  type _ t = Full : full_node list -> full t | Lite : lite_node list -> lite t
25

26
  type 'repr node_list = 'repr t
27

28
  let to_lite =
29
    List.map ~f:(fun { transition; _ } ->
30
        Mina_block.Validated.state_hash transition )
×
31

32
  module Lite = struct
33
    module Binable_arg = struct
34
      [%%versioned
35
      module Stable = struct
36
        [@@@no_toplevel_latest_type]
37

38
        module V1 = struct
39
          type t = State_hash.Stable.V1.t list
3✔
40

41
          let to_latest = Fn.id
42
        end
43
      end]
44
    end
45

46
    [%%versioned_binable
47
    module Stable = struct
48
      module V1 = struct
49
        type t = lite node_list
3✔
50

51
        module T_nonbinable = struct
52
          type nonrec t = t
53

54
          let to_binable (Lite ls) = ls
×
55

56
          let of_binable ls = Lite ls
×
57
        end
58

59
        include Binable.Of_binable (Binable_arg.Stable.V1) (T_nonbinable)
60

61
        let to_latest = Fn.id
62
      end
63
    end]
64
  end
65
end
66

67
module Root_transition = struct
68
  type 'repr root_transition_scan_state =
69
    | Lite : lite root_transition_scan_state
70
    | Full : Staged_ledger.Scan_state.t -> full root_transition_scan_state
71

72
  type 'repr t =
73
    { new_root : Root_data.Limited.t
74
    ; garbage : 'repr Node_list.t
75
    ; old_root_scan_state : 'repr root_transition_scan_state
76
    ; just_emitted_a_proof : bool
77
    }
78

79
  type 'repr root_transition = 'repr t
80

81
  module Lite_binable = struct
82
    [%%versioned
83
    module Stable = struct
84
      [@@@no_toplevel_latest_type]
85

86
      module V4 = struct
87
        type t =
6✔
88
          { new_root : Root_data.Limited.Stable.V3.t
89
          ; garbage : Node_list.Lite.Stable.V1.t
90
          ; just_emitted_a_proof : bool
91
          }
15✔
92

93
        let to_latest = Fn.id
94
      end
95
    end]
96
  end
97

98
  module Lite = struct
99
    module Binable_arg = struct
100
      [%%versioned
101
      module Stable = struct
102
        [@@@no_toplevel_latest_type]
103

104
        module V4 = struct
105
          type t = Lite_binable.Stable.V4.t
3✔
106

107
          let to_latest = Fn.id
108
        end
109
      end]
110
    end
111

112
    [%%versioned_binable
113
    module Stable = struct
114
      module V4 = struct
115
        type t = lite root_transition
3✔
116

117
        module T_nonbinable = struct
118
          type nonrec t = t
119

120
          let to_binable
121
              ({ new_root
122
               ; garbage
123
               ; just_emitted_a_proof
124
               ; old_root_scan_state = Lite
125
               } :
126
                t ) : Binable_arg.Stable.V4.t =
127
            { new_root; garbage; just_emitted_a_proof }
×
128

129
          let of_binable
130
              ({ new_root; garbage; just_emitted_a_proof } :
131
                Binable_arg.Stable.V4.t ) : t =
132
            { new_root
×
133
            ; garbage
134
            ; old_root_scan_state = Lite
135
            ; just_emitted_a_proof
136
            }
137
        end
138

139
        include Binable.Of_binable (Binable_arg.Stable.V4) (T_nonbinable)
140

141
        let to_latest = Fn.id
142
      end
143
    end]
144
  end
145
end
146

147
type ('repr, 'mutant) t =
148
  | New_node : 'repr Node.t -> ('repr, unit) t
149
  | Root_transitioned : 'repr Root_transition.t -> ('repr, State_hash.t) t
150
  | Best_tip_changed : State_hash.t -> (_, State_hash.t) t
151

152
type ('repr, 'mutant) diff = ('repr, 'mutant) t
153

154
let name : type repr mutant. (repr, mutant) t -> string = function
155
  | Root_transitioned _ ->
×
156
      "Root_transitioned"
157
  | New_node _ ->
×
158
      "New_node"
159
  | Best_tip_changed _ ->
×
160
      "Best_tip_changed"
161

162
let to_yojson (type repr mutant) (key : (repr, mutant) t) =
163
  let json_key =
×
164
    match key with
165
    | New_node (Full breadcrumb) ->
×
166
        State_hash.to_yojson (Breadcrumb.state_hash breadcrumb)
×
167
    | New_node (Lite transition) ->
×
168
        State_hash.to_yojson (Mina_block.Validated.state_hash transition)
×
169
    | Root_transitioned
×
170
        { new_root; garbage; just_emitted_a_proof; old_root_scan_state = _ } ->
171
        let garbage_hashes =
172
          match garbage with
173
          | Node_list.Full nodes ->
×
174
              Node_list.to_lite nodes
×
175
          | Node_list.Lite hashes ->
×
176
              hashes
177
        in
178
        `Assoc
179
          [ ( "new_root"
180
            , State_hash.to_yojson
×
181
                (Root_data.Limited.hashes new_root).state_hash )
×
182
          ; ("garbage", `List (List.map ~f:State_hash.to_yojson garbage_hashes))
×
183
          ; ("just_emitted_a_proof", `Bool just_emitted_a_proof)
184
          ]
185
    | Best_tip_changed breadcrumb ->
×
186
        State_hash.to_yojson breadcrumb
×
187
  in
188
  `Assoc [ (name key, json_key) ]
×
189

190
let to_lite (type mutant) (diff : (full, mutant) t) : (lite, mutant) t =
191
  match diff with
×
192
  | New_node (Full breadcrumb) ->
×
193
      let external_transition = Breadcrumb.validated_transition breadcrumb in
194
      New_node (Lite external_transition)
×
195
  | Root_transitioned
×
196
      { new_root
197
      ; garbage = Full garbage_nodes
198
      ; old_root_scan_state = Full _
199
      ; just_emitted_a_proof
200
      } ->
201
      Root_transitioned
202
        { new_root
203
        ; garbage = Lite (Node_list.to_lite garbage_nodes)
×
204
        ; old_root_scan_state = Lite
205
        ; just_emitted_a_proof
206
        }
207
  | Best_tip_changed b ->
×
208
      Best_tip_changed b
209

210
module Lite = struct
211
  type 'mutant t = (lite, 'mutant) diff
212

213
  module E = struct
214
    type t = E : (lite, 'mutant) diff -> t [@@unboxed]
215
  end
216
end
217

218
module Full = struct
219
  type 'mutant t = (full, 'mutant) diff
220

221
  module E = struct
222
    type t = E : (full, 'mutant) diff -> t
223

224
    let to_lite (E diff) = Lite.E.E (to_lite diff)
×
225

226
    let to_yojson (E diff) = to_yojson diff
×
227
  end
228

229
  module With_mutant = struct
230
    type t = E : (full, 'mutant) diff * 'mutant -> t
231
  end
232
end
6✔
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