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

MinaProtocol / mina / 2908

12 Nov 2024 12:30PM UTC coverage: 36.715% (-25.0%) from 61.682%
2908

push

buildkite

web-flow
Merge pull request #16333 from MinaProtocol/dkijania/port_new_deb_s3_dev

[DEV] Use new version of deb-s3 for validating job publishing

24544 of 66850 relevant lines covered (36.72%)

20720.94 hits per line

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

17.65
/src/lib/bootstrap_controller/transition_cache.ml
1
open Mina_base
2✔
2
open Core
3
open Network_peer
4

5
type initial_valid_block_or_header =
6
  [ `Block of Mina_block.initial_valid_block
7
  | `Header of Mina_block.initial_valid_header ]
8

9
type element =
10
  initial_valid_block_or_header Envelope.Incoming.t
11
  * Mina_net2.Validation_callback.t option
12

13
let header_with_hash e =
14
  match e with
3✔
15
  | `Block b ->
3✔
16
      With_hash.map ~f:Mina_block.header
17
      @@ Mina_block.Validation.block_with_hash b
3✔
18
  | `Header h ->
×
19
      Mina_block.Validation.header_with_hash h
20

21
(* Cache represents a graph. The key is a State_hash, which is the node in
22
   the graph, and the value is the children transitions of the node *)
23

24
type t = element list State_hash.Table.t
25

26
let create () = State_hash.Table.create ()
×
27

28
let state_hash e =
29
  State_hash.With_state_hashes.state_hash @@ header_with_hash
×
30
  @@ Envelope.Incoming.data e
×
31

32
let logger = Logger.create ()
2✔
33

34
let merge (old_env, old_vc) (new_env, new_vc) =
35
  let old_b = Envelope.Incoming.data old_env in
×
36
  let vc =
×
37
    match (old_vc, new_vc) with
38
    | Some _, Some _ ->
×
39
        [%log warn] "Received gossip on $state_hash twice"
×
40
          ~metadata:
41
            [ ("state_hash", State_hash.to_yojson @@ state_hash old_env) ] ;
×
42
        old_vc
×
43
    | None, Some _ ->
×
44
        new_vc
45
    | _ ->
×
46
        old_vc
47
  in
48
  ( Envelope.Incoming.map new_env ~f:(fun new_b ->
×
49
        match new_b with `Block _ -> new_b | _ -> old_b )
×
50
  , vc )
51

52
let add (t : t) ~parent new_child =
53
  State_hash.Table.update t parent ~f:(function
×
54
    | None ->
×
55
        [ new_child ]
56
    | Some children ->
×
57
        let children', b =
58
          List.fold children ~init:([], false) ~f:(fun (acc, b) child ->
59
              (* If state hash was already among children, existing child is
60
                 merged with the new transition.
61
                 It's needed to maintain consistency about transitions that may
62
                 come from gossip or other ways; we want to preserve some
63
                 validation callback (and we don't expect two gossips for the
64
                 same).
65
                 Also, if we received a block after receiving a header
66
                 (possible when we'll simultaneously support both old and new
67
                 gossip topics), we want to preserve a block because it's more
68
                 than a header. *)
69
              if
×
70
                (not b)
71
                && State_hash.equal
×
72
                     (state_hash @@ fst child)
×
73
                     (state_hash @@ fst new_child)
×
74
              then (merge child new_child :: acc, true)
×
75
              else (acc, b) )
×
76
        in
77
        if b then children' else new_child :: children )
×
78

79
let data t =
80
  let collected_transitions = State_hash.Table.data t |> List.concat in
×
81
  assert (
×
82
    Stdlib.List.compare_lengths collected_transitions
×
83
      (List.stable_dedup collected_transitions)
×
84
    = 0 )
85
  (* TODO: make this assertion more efficient *) ;
86
  collected_transitions
4✔
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