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

MinaProtocol / mina / 220

21 May 2025 10:28PM UTC coverage: 30.952% (-5.9%) from 36.812%
220

push

buildkite

web-flow
Merge pull request #17252 from MinaProtocol/georgeee/merge-compatible-to-develop-2025-05-21

Merge compatible to develop (21 May 2025)

113 of 362 new or added lines in 25 files covered. (31.22%)

5712 existing lines in 164 files now uncovered.

21883 of 70700 relevant lines covered (30.95%)

24875.73 hits per line

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

91.67
/src/app/missing_blocks_auditor/sql.ml
1
(* sql.ml -- (Postgresql) SQL queries for missing blocks auditor *)
2

3
module Unparented_blocks = struct
4
  (* parent_hashes represent ends of chains leading to an orphan block *)
5

6
  let query =
7
    Caqti_request.collect Caqti_type.unit
2✔
8
      Caqti_type.(tup4 int string int string)
2✔
9
      {sql|
10
           SELECT id, state_hash, height, parent_hash FROM blocks
11
           WHERE parent_id IS NULL
12
      |sql}
13

14
  let run (module Conn : Caqti_async.CONNECTION) () = Conn.collect_list query ()
2✔
15
end
16

17
module Missing_blocks_gap = struct
18
  let query =
19
    Caqti_request.find Caqti_type.int Caqti_type.int
2✔
20
      {sql| SELECT $1 - MAX(height) - 1 FROM blocks
21
            WHERE height < $1
22
      |sql}
23

UNCOV
24
  let run (module Conn : Caqti_async.CONNECTION) height = Conn.find query height
×
25
end
26

27
module Chain_status = struct
28
  let query_highest_canonical =
29
    Caqti_request.find Caqti_type.unit Caqti_type.int64
2✔
30
      {sql| SELECT max(height) FROM blocks
31
            WHERE chain_status = 'canonical'
32
      |sql}
33

34
  let run_highest_canonical (module Conn : Caqti_async.CONNECTION) () =
35
    Conn.find query_highest_canonical ()
2✔
36

37
  let query_count_pending_below =
38
    Caqti_request.find Caqti_type.int64 Caqti_type.int64
2✔
39
      {sql| SELECT count(*) FROM blocks
40
            WHERE chain_status = 'pending'
41
            AND height <= ?
42
      |sql}
43

44
  let run_count_pending_below (module Conn : Caqti_async.CONNECTION) height =
45
    Conn.find query_count_pending_below height
2✔
46

47
  let query_canonical_chain =
48
    Caqti_request.collect Caqti_type.int64
2✔
49
      Caqti_type.(tup3 int string string)
2✔
50
      {sql| WITH RECURSIVE chain AS (
51

52
               (SELECT id, state_hash, parent_id, chain_status
53

54
                FROM blocks b
55
                WHERE height = $1
56
                AND chain_status = 'canonical')
57

58
                UNION ALL
59

60
                SELECT b.id, b.state_hash, b.parent_id, b.chain_status
61

62
                FROM blocks b
63
                INNER JOIN chain
64
                ON b.id = chain.parent_id AND chain.id <> chain.parent_id
65
               )
66

67
              SELECT id,state_hash,chain_status
68
              FROM chain
69
              ORDER BY id ASC
70
      |sql}
71

72
  let run_canonical_chain (module Conn : Caqti_async.CONNECTION) height =
73
    Conn.collect_list query_canonical_chain height
2✔
74
end
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