Skip to content

Commit 1f81012

Browse files
committed
Reorganize LedgerDB constraints
1 parent d983c14 commit 1f81012

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

@@ -726,7 +728,11 @@ data TraceReplayProgressEvent blk
726728
Updating ledger tables
727729
-------------------------------------------------------------------------------}
728730

729-
type LedgerSupportsInMemoryLedgerDB blk = (CanUpgradeLedgerTables (LedgerState blk))
731+
type LedgerSupportsInMemoryLedgerDB l =
732+
(CanUpgradeLedgerTables l, SerializeTablesWithHint l)
733+
734+
type LedgerSupportsV1LedgerDB l =
735+
(LedgerSupportsInMemoryLedgerDB l, LedgerSupportsLMDBLedgerDB l)
730736

731737
-- | When pushing differences on InMemory Ledger DBs, we will sometimes need to
732738
-- update ledger tables to the latest era. For unary blocks this is a no-op, but
@@ -765,12 +771,18 @@ instance
765771
Supporting On-Disk backing stores
766772
-------------------------------------------------------------------------------}
767773

768-
type LedgerSupportsOnDiskLedgerDB blk =
769-
(IndexedMemPack (LedgerState blk EmptyMK) (TxOut (LedgerState blk)))
774+
type LedgerSupportsLMDBLedgerDB l =
775+
(IndexedMemPack (l EmptyMK) (TxOut l), MemPackIdx l EmptyMK ~ l EmptyMK)
776+
777+
type LedgerSupportsV2LedgerDB l =
778+
(LedgerSupportsInMemoryLedgerDB l)
779+
780+
type LedgerSupportsLedgerDB blk = LedgerSupportsLedgerDB' (LedgerState blk) blk
770781

771-
type LedgerSupportsLedgerDB blk =
772-
( LedgerSupportsOnDiskLedgerDB blk
773-
, LedgerSupportsInMemoryLedgerDB blk
782+
type LedgerSupportsLedgerDB' l blk =
783+
( LedgerSupportsLMDBLedgerDB l
784+
, LedgerSupportsInMemoryLedgerDB l
785+
, LedgerDbSerialiseConstraints blk
774786
)
775787

776788
{-------------------------------------------------------------------------------

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
@@ -80,7 +80,6 @@ mkInitDb ::
8080
forall m blk.
8181
( LedgerSupportsProtocol blk
8282
, IOLike m
83-
, LedgerDbSerialiseConstraints blk
8483
, HasHardForkHistory blk
8584
, LedgerSupportsLedgerDB blk
8685
) =>

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
@@ -74,7 +74,7 @@ mkInitDb ::
7474
, IOLike m
7575
, LedgerDbSerialiseConstraints blk
7676
, HasHardForkHistory blk
77-
, LedgerSupportsInMemoryLedgerDB blk
77+
, LedgerSupportsV2LedgerDB (LedgerState blk)
7878
) =>
7979
Complete LedgerDbArgs m blk ->
8080
HandleEnv m ->

0 commit comments

Comments
 (0)