Skip to content

Commit 3854340

Browse files
committed
WIP
1 parent 9b2aa15 commit 3854340

8 files changed

Lines changed: 125 additions & 146 deletions

File tree

cardano-config/src/Cardano/Configuration.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ module Cardano.Configuration
4949

5050
-- * Basics
5151
, Basics.File (..)
52-
, Basics.Override (..)
5352
) where
5453

5554
import qualified Cardano.Configuration.Basics as Basics
@@ -89,6 +88,7 @@ data NodeConfiguration = NodeConfiguration
8988
, shutdownIPC :: Maybe Fd
9089
, shutdownOnTarget :: Maybe CLI.ShutdownOn
9190
}
91+
deriving Show
9292

9393
-- | Combine the cli arguments and configuration file values into a full
9494
-- configuration

cardano-config/src/Cardano/Configuration/Basics.hs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ module Cardano.Configuration.Basics
77
, anchorRelativePath
88

99
-- * Defaults
10-
, Override (..)
1110
, (.:=)
1211
) where
1312

14-
import Control.Applicative ((<|>))
1513
import Data.Aeson
1614
import Data.Aeson.Types (Parser)
1715
import Data.Default
@@ -41,27 +39,6 @@ anchorRelativePath fp1 (RelativeFile fp2) = fp1 </> fp2
4139

4240
--------------------------------------------------------------------------------
4341

44-
-- | Signal whether the default value should not be overriden, but don't provide
45-
-- a default at this level. The particular component will have to then apply
46-
-- whatever defaults it considers acceptable.
47-
data Override a = NoOverride | Override a deriving (Generic, Show, Eq)
48-
49-
instance Default (Override a) where
50-
def = NoOverride
51-
52-
instance FromJSON a => FromJSON (Override a) where
53-
parseJSON v =
54-
withText
55-
"Override"
56-
( \case
57-
"NoOverride" -> pure NoOverride
58-
_ -> fail "Not text"
59-
)
60-
v
61-
<|> Override <$> parseJSON v
62-
63-
--------------------------------------------------------------------------------
64-
6542
-- | If the key is missing, use the default value
6643
(.:=) :: (FromJSON a, Default a) => Object -> Key -> Parser a
6744
a .:= b = a .:? b .!= def

cardano-config/src/Cardano/Configuration/Common.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ import Options.Applicative
1717
-- | The databases that will be used by the node
1818
data NodeDatabasePaths
1919
= -- | Store everything in a single directory
20-
Unique (File "Database")
20+
SingleDB (File "Database")
2121
| -- | Store the immutable data in one (possibly slower) directory and the
2222
-- volatile data in a different (possible faster) directory
23-
Split (File "ImmutableDB") (File "VolatileDB")
23+
SplitDB (File "ImmutableDB") (File "VolatileDB")
2424
deriving (Generic, Show)
2525

2626
instance Default NodeDatabasePaths where
27-
def = Unique "mainnet/db"
27+
def = SingleDB "mainnet/db"
2828

2929
instance FromJSON NodeDatabasePaths where
3030
parseJSON v =
31-
withText "OneDatabase" (pure . Unique . File . T.unpack) v
31+
withText "OneDatabase" (pure . SingleDB . File . T.unpack) v
3232
<|> withObject
3333
"MultipleDatabases"
34-
(\v' -> Split <$> v' .: "ImmutablePath" <*> v' .: "VolatilePath")
34+
(\v' -> SplitDB <$> v' .: "ImmutablePath" <*> v' .: "VolatilePath")
3535
v
3636

3737
parseNodeDatabasePaths :: Parser (Maybe NodeDatabasePaths)
@@ -40,7 +40,7 @@ parseNodeDatabasePaths =
4040

4141
parseDbPath :: Parser NodeDatabasePaths
4242
parseDbPath =
43-
fmap Unique $
43+
fmap SingleDB $
4444
strOption $
4545
mconcat
4646
[ long "database-path"
@@ -50,7 +50,7 @@ parseDbPath =
5050
]
5151

5252
parseMultipleDbPaths :: Parser NodeDatabasePaths
53-
parseMultipleDbPaths = Split <$> parseImmutableDbPath <*> parseVolatileDbPath
53+
parseMultipleDbPaths = SplitDB <$> parseImmutableDbPath <*> parseVolatileDbPath
5454

5555
parseVolatileDbPath :: Parser (File "VolatileDB")
5656
parseVolatileDbPath =

cardano-config/src/Cardano/Configuration/File/Consensus.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Cardano.Configuration.Basics
88
import Cardano.Ledger.BaseTypes
99
import Data.Aeson
1010
import Data.Default
11+
import Data.Functor.Identity (Identity)
1112
import Data.Time.Clock (DiffTime)
1213
import GHC.Generics (Generic)
1314

@@ -23,6 +24,7 @@ instance Default ConsensusMode where
2324
newtype ConsensusConfiguration f = ConsensusConfiguration {getConsensusConfiguration :: f ConsensusMode}
2425

2526
deriving instance Show (ConsensusConfiguration Maybe)
27+
deriving instance Show (ConsensusConfiguration Identity)
2628

2729
instance FromJSON (ConsensusConfiguration Maybe) where
2830
parseJSON val =
@@ -40,14 +42,14 @@ instance FromJSON (ConsensusConfiguration Maybe) where
4042

4143
-- | Configuration options for Genesis parameters
4244
data GenesisConfigFlags = GenesisConfigFlags
43-
{ gcfEnableCSJ :: Override Bool
44-
, gcfEnableLoEAndGDD :: Override Bool
45-
, gcfEnableLoP :: Override Bool
46-
, gcfBlockFetchGracePeriod :: Override DiffTime
47-
, gcfBucketCapacity :: Override Integer
48-
, gcfBucketRate :: Override Integer
49-
, gcfCSJJumpSize :: Override SlotNo
50-
, gcfGDDRateLimit :: Override DiffTime
45+
{ gcfEnableCSJ :: Maybe Bool
46+
, gcfEnableLoEAndGDD :: Maybe Bool
47+
, gcfEnableLoP :: Maybe Bool
48+
, gcfBlockFetchGracePeriod :: Maybe DiffTime
49+
, gcfBucketCapacity :: Maybe Integer
50+
, gcfBucketRate :: Maybe Integer
51+
, gcfCSJJumpSize :: Maybe SlotNo
52+
, gcfGDDRateLimit :: Maybe DiffTime
5153
}
5254
deriving (Generic, Show)
5355

cardano-config/src/Cardano/Configuration/File/Network.hs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,34 @@ instance FromJSON ResponderCoreAffinityPolicy where
6161
x -> fail $ "Unknown responder core affinity policy: " <> T.unpack x
6262

6363
-- | Options related to Networking configuration. Most of the fields are
64-
-- @Override@ such that the networking layer can then set the appropriate
64+
-- @Maybe@ such that the networking layer can then set the appropriate
6565
-- defaults.
6666
data NetworkConfiguration = NetworkConfiguration
6767
{ pncDiffusionMode :: DiffusionMode
68-
, pncMaxConcurrencyBulkSync :: Override Word
69-
, pncMaxConcurrencyDeadline :: Override Word
70-
, pncProtocolIdleTimeout :: Override DiffTime
71-
, pncTimeWaitTimeout :: Override DiffTime
72-
, pncEgressPollInterval :: Override DiffTime
73-
, pncChainSyncIdleTimeout :: Override DiffTime
74-
, pncAcceptedConnectionsLimit :: Override AcceptedConnectionsLimit
75-
, pncDeadlineTargetOfRootPeers :: Override Int
76-
, pncDeadlineTargetOfKnownPeers :: Override Int
77-
, pncDeadlineTargetOfEstablishedPeers :: Override Int
78-
, pncDeadlineTargetOfActivePeers :: Override Int
79-
, pncDeadlineTargetOfKnownBigLedgerPeers :: Override Int
80-
, pncDeadlineTargetOfEstablishedBigLedgerPeers :: Override Int
81-
, pncDeadlineTargetOfActiveBigLedgerPeers :: Override Int
82-
, pncSyncTargetOfRootPeers :: Override Int
83-
, pncSyncTargetOfKnownPeers :: Override Int
84-
, pncSyncTargetOfEstablishedPeers :: Override Int
85-
, pncSyncTargetOfActivePeers :: Override Int
86-
, pncSyncTargetOfKnownBigLedgerPeers :: Override Int
87-
, pncSyncTargetOfEstablishedBigLedgerPeers :: Override Int
88-
, pncSyncTargetOfActiveBigLedgerPeers :: Override Int
89-
, pncMinBigLedgerPeersForTrustedState :: Override Int
90-
, pncPeerSharing :: Override PeerSharing
91-
, pncResponderCoreAffinityPolicy :: Override ResponderCoreAffinityPolicy
68+
, pncMaxConcurrencyBulkSync :: Maybe Word
69+
, pncMaxConcurrencyDeadline :: Maybe Word
70+
, pncProtocolIdleTimeout :: Maybe DiffTime
71+
, pncTimeWaitTimeout :: Maybe DiffTime
72+
, pncEgressPollInterval :: Maybe DiffTime
73+
, pncChainSyncIdleTimeout :: Maybe DiffTime
74+
, pncAcceptedConnectionsLimit :: Maybe AcceptedConnectionsLimit
75+
, pncDeadlineTargetOfRootPeers :: Maybe Int
76+
, pncDeadlineTargetOfKnownPeers :: Maybe Int
77+
, pncDeadlineTargetOfEstablishedPeers :: Maybe Int
78+
, pncDeadlineTargetOfActivePeers :: Maybe Int
79+
, pncDeadlineTargetOfKnownBigLedgerPeers :: Maybe Int
80+
, pncDeadlineTargetOfEstablishedBigLedgerPeers :: Maybe Int
81+
, pncDeadlineTargetOfActiveBigLedgerPeers :: Maybe Int
82+
, pncSyncTargetOfRootPeers :: Maybe Int
83+
, pncSyncTargetOfKnownPeers :: Maybe Int
84+
, pncSyncTargetOfEstablishedPeers :: Maybe Int
85+
, pncSyncTargetOfActivePeers :: Maybe Int
86+
, pncSyncTargetOfKnownBigLedgerPeers :: Maybe Int
87+
, pncSyncTargetOfEstablishedBigLedgerPeers :: Maybe Int
88+
, pncSyncTargetOfActiveBigLedgerPeers :: Maybe Int
89+
, pncMinBigLedgerPeersForTrustedState :: Maybe Int
90+
, pncPeerSharing :: Maybe PeerSharing
91+
, pncResponderCoreAffinityPolicy :: Maybe ResponderCoreAffinityPolicy
9292
}
9393
deriving (Generic, Show)
9494

cardano-config/src/Cardano/Configuration/File/Storage.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ newtype MaxReaders = MaxReaders Word64
5252
-- | Selector for the backend
5353
data LedgerDbBackendSelector f
5454
= V1LMDB
55-
(Override FlushFrequency)
55+
(Maybe FlushFrequency)
5656
(f (File "LMDB"))
57-
(Override MaxMapSize)
58-
(Override MaxReaders)
57+
(Maybe MaxMapSize)
58+
(Maybe MaxReaders)
5959
| V2InMemory
6060
| V2LSM (f (File "LSM"))
6161
deriving Generic
@@ -82,9 +82,9 @@ newtype QueryBatchSize = QueryBatchSize Word64
8282
-- | The Ledger DB configuration
8383
data LedgerDbConfiguration f
8484
= LedgerDbConfiguration
85-
{ numOfDiskSnapshots :: Override NumOfDiskSnapshots
86-
, snapshotInterval :: Override SnapshotInterval
87-
, queryBatchSize :: Override QueryBatchSize
85+
{ numOfDiskSnapshots :: Maybe NumOfDiskSnapshots
86+
, snapshotInterval :: Maybe SnapshotInterval
87+
, queryBatchSize :: Maybe QueryBatchSize
8888
, backendSelector :: f (LedgerDbBackendSelector f)
8989
}
9090
deriving Generic
@@ -132,12 +132,12 @@ class DefaultGiven given a where
132132
defGiven :: given -> a
133133

134134
instance DefaultGiven NodeDatabasePaths (File "LMDB") where
135-
defGiven (Unique fp) = fp `anchorRelativePath` def
136-
defGiven (Split _ fp) = fp `anchorRelativePath` def
135+
defGiven (SingleDB fp) = fp `anchorRelativePath` def
136+
defGiven (SplitDB _ fp) = fp `anchorRelativePath` def
137137

138138
instance DefaultGiven NodeDatabasePaths (File "LSM") where
139-
defGiven (Unique fp) = fp `anchorRelativePath` def
140-
defGiven (Split _ fp) = fp `anchorRelativePath` def
139+
defGiven (SingleDB fp) = fp `anchorRelativePath` def
140+
defGiven (SplitDB _ fp) = fp `anchorRelativePath` def
141141

142142
instance
143143
(Default (RelativeFile a), DefaultGiven b (File a)) =>

cardano-config/src/Cardano/Configuration/File/Testing.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ newtype MempoolCapacityBytes = MempoolCapacityBytes Word64
1717

1818
-- | The testing configuration
1919
data TestingConfiguration = TestingConfiguration
20-
{ pncMaybeMempoolCapacityOverride :: !(Override MempoolCapacityBytes)
20+
{ pncMaybeMempoolCapacityMaybe :: !(Maybe MempoolCapacityBytes)
2121
, pncExperimentalGenesis :: Maybe (EraGenesis ExperimentalCardanoEra)
2222
}
2323
deriving (Generic, Show)
@@ -26,7 +26,7 @@ instance FromJSON TestingConfiguration where
2626
parseJSON =
2727
withObject "Configuration" $ \v ->
2828
TestingConfiguration
29-
<$> v .:= "MempoolCapacityBytesOverride"
29+
<$> v .:= "MempoolCapacityBytesMaybe"
3030
<*> ( do
3131
enabled <- v .:? "ExperimentalHardForksEnabled" .!= False
3232
if enabled

0 commit comments

Comments
 (0)