Skip to content

Commit d6cb83f

Browse files
committed
Reorganize LedgerDB constraints
1 parent 573fb26 commit d6cb83f

File tree

11 files changed

+52
-29
lines changed

11 files changed

+52
-29
lines changed

ouroboros-consensus-cardano/app/snapshot-converter.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ checkSnapshotFileStructure m p (SomeHasFS fs) = case m of
166166

167167
load ::
168168
forall blk.
169-
( LedgerDbSerialiseConstraints blk
170-
, CanStowLedgerTables (LedgerState blk)
169+
( CanStowLedgerTables (LedgerState blk)
171170
, LedgerSupportsProtocol blk
172171
, LedgerSupportsLedgerDB blk
173172
) =>
@@ -218,8 +217,7 @@ load config@Config{inpath = pathToDiskSnapshot -> Just (fs@(SomeHasFS hasFS), pa
218217
load _ _ _ _ = error "Malformed input path!"
219218

220219
store ::
221-
( LedgerDbSerialiseConstraints blk
222-
, CanStowLedgerTables (LedgerState blk)
220+
( CanStowLedgerTables (LedgerState blk)
223221
, LedgerSupportsProtocol blk
224222
, LedgerSupportsLedgerDB blk
225223
) =>

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Run.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import Text.Printf (printf)
5757
openLedgerDB ::
5858
( LedgerSupportsProtocol blk
5959
, InspectLedger blk
60-
, LedgerDB.LedgerDbSerialiseConstraints blk
6160
, HasHardForkHistory blk
6261
, LedgerDB.LedgerSupportsLedgerDB blk
6362
) =>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
For top level release notes, leave all the headers commented out.
6+
-->
7+
8+
<!--
9+
### Patch
10+
11+
- A bullet item for the Patch category.
12+
13+
-->
14+
<!--
15+
### Non-Breaking
16+
17+
- A bullet item for the Non-Breaking category.
18+
19+
-->
20+
### Breaking
21+
22+
- Delete `LedgerSupportsOnDiskLedgerDB` constraint and created `LedgerSupports(V1|V2)LedgerDB`.

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Serialisation/Common.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ import Ouroboros.Consensus.Ledger.Query
105105
import Ouroboros.Consensus.Ledger.Tables
106106
import Ouroboros.Consensus.Node.NetworkProtocolVersion
107107
import Ouroboros.Consensus.Node.Run
108+
import Ouroboros.Consensus.Storage.LedgerDB
108109
import Ouroboros.Consensus.Storage.Serialisation
109110
import Ouroboros.Consensus.TypeFamilyWrappers
110111
import Ouroboros.Network.Block (Serialised)
@@ -200,7 +201,7 @@ class
200201
, -- LedgerTables on the HardForkBlock might not be compositionally
201202
-- defined, but we need to require this instances for any instantiation.
202203
HasLedgerTables (LedgerState (HardForkBlock xs))
203-
, SerializeTablesWithHint (LedgerState (HardForkBlock xs))
204+
, LedgerSupportsLedgerDB (HardForkBlock xs)
204205
) =>
205206
SerialiseHFC xs
206207
where

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ openDB ::
4848
, HasCallStack
4949
, HasHardForkHistory blk
5050
, LedgerSupportsLedgerDB blk
51-
, LedgerDbSerialiseConstraints blk
5251
) =>
5352
-- | Stateless initializaton arguments
5453
Complete LedgerDbArgs m blk ->

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/API.hs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ module Ouroboros.Consensus.Storage.LedgerDB.API
117117
, LedgerDbSerialiseConstraints
118118
, LedgerSupportsInMemoryLedgerDB
119119
, LedgerSupportsLedgerDB
120-
, LedgerSupportsOnDiskLedgerDB
120+
, LedgerSupportsLMDBLedgerDB
121+
, LedgerSupportsV1LedgerDB
122+
, LedgerSupportsV2LedgerDB
121123
, ResolveBlock
122124
, currentPoint
123125

@@ -722,7 +724,11 @@ data TraceReplayProgressEvent blk
722724
Updating ledger tables
723725
-------------------------------------------------------------------------------}
724726

725-
type LedgerSupportsInMemoryLedgerDB blk = (CanUpgradeLedgerTables (LedgerState blk))
727+
type LedgerSupportsInMemoryLedgerDB l =
728+
(CanUpgradeLedgerTables l, SerializeTablesWithHint l)
729+
730+
type LedgerSupportsV1LedgerDB l =
731+
(LedgerSupportsInMemoryLedgerDB l, LedgerSupportsLMDBLedgerDB l)
726732

727733
-- | When pushing differences on InMemory Ledger DBs, we will sometimes need to
728734
-- update ledger tables to the latest era. For unary blocks this is a no-op, but
@@ -761,12 +767,18 @@ instance
761767
Supporting On-Disk backing stores
762768
-------------------------------------------------------------------------------}
763769

764-
type LedgerSupportsOnDiskLedgerDB blk =
765-
(IndexedMemPack (LedgerState blk EmptyMK) (TxOut (LedgerState blk)))
770+
type LedgerSupportsLMDBLedgerDB l =
771+
(IndexedMemPack (l EmptyMK) (TxOut l), MemPackIdx l EmptyMK ~ l EmptyMK)
772+
773+
type LedgerSupportsV2LedgerDB l =
774+
(LedgerSupportsInMemoryLedgerDB l)
775+
776+
type LedgerSupportsLedgerDB blk = LedgerSupportsLedgerDB' (LedgerState blk) blk
766777

767-
type LedgerSupportsLedgerDB blk =
768-
( LedgerSupportsOnDiskLedgerDB blk
769-
, LedgerSupportsInMemoryLedgerDB blk
778+
type LedgerSupportsLedgerDB' l blk =
779+
( LedgerSupportsLMDBLedgerDB l
780+
, LedgerSupportsInMemoryLedgerDB l
781+
, LedgerDbSerialiseConstraints blk
770782
)
771783

772784
{-------------------------------------------------------------------------------

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ mkInitDb ::
7878
forall m blk.
7979
( LedgerSupportsProtocol blk
8080
, IOLike m
81-
, LedgerDbSerialiseConstraints blk
8281
, HasHardForkHistory blk
8382
, LedgerSupportsLedgerDB blk
8483
) =>

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1/BackingStore.hs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{-# LANGUAGE GADTs #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
66
{-# LANGUAGE TypeFamilies #-}
7-
{-# LANGUAGE TypeOperators #-}
87

98
-- | See "Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API" for the
109
-- documentation. This module just puts together the implementations for the
@@ -62,9 +61,7 @@ restoreBackingStore ::
6261
( IOLike m
6362
, HasLedgerTables l
6463
, HasCallStack
65-
, CanUpgradeLedgerTables l
66-
, MemPackIdx l EmptyMK ~ l EmptyMK
67-
, SerializeTablesWithHint l
64+
, LedgerSupportsV1LedgerDB l
6865
) =>
6966
Tracer m FlavorImplSpecificTrace ->
7067
Complete BackingStoreArgs m ->
@@ -80,9 +77,7 @@ newBackingStore ::
8077
( IOLike m
8178
, HasLedgerTables l
8279
, HasCallStack
83-
, CanUpgradeLedgerTables l
84-
, MemPackIdx l EmptyMK ~ l EmptyMK
85-
, SerializeTablesWithHint l
80+
, LedgerSupportsV1LedgerDB l
8681
) =>
8782
Tracer m FlavorImplSpecificTrace ->
8883
Complete BackingStoreArgs m ->
@@ -98,9 +93,7 @@ newBackingStoreInitialiser ::
9893
( IOLike m
9994
, HasLedgerTables l
10095
, HasCallStack
101-
, CanUpgradeLedgerTables l
102-
, MemPackIdx l EmptyMK ~ l EmptyMK
103-
, SerializeTablesWithHint l
96+
, LedgerSupportsV1LedgerDB l
10497
) =>
10598
Tracer m FlavorImplSpecificTrace ->
10699
Complete BackingStoreArgs m ->

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1/Snapshots.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ snapshotToTablesPath = mkFsPath . (\x -> [x, "tables"]) . snapshotToDirName
283283
loadSnapshot ::
284284
forall m blk.
285285
( IOLike m
286-
, LedgerDbSerialiseConstraints blk
287286
, LedgerSupportsProtocol blk
288-
, LedgerSupportsLedgerDB blk
287+
, LedgerSupportsV1LedgerDB (LedgerState blk)
288+
, LedgerDbSerialiseConstraints blk
289289
) =>
290290
Tracer m V1.FlavorImplSpecificTrace ->
291291
Complete BackingStoreArgs m ->

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mkInitDb ::
7373
, IOLike m
7474
, LedgerDbSerialiseConstraints blk
7575
, HasHardForkHistory blk
76-
, LedgerSupportsInMemoryLedgerDB blk
76+
, LedgerSupportsV2LedgerDB (LedgerState blk)
7777
) =>
7878
Complete LedgerDbArgs m blk ->
7979
HandleEnv m ->

0 commit comments

Comments
 (0)