@@ -21,9 +21,11 @@ module Cardano.Node.Configuration.POM
21
21
)
22
22
where
23
23
24
+ import Control.Monad (when )
24
25
import Data.Aeson
25
26
import qualified Data.Aeson.Types as Aeson
26
27
import Data.Bifunctor (Bifunctor (.. ))
28
+ import Data.Maybe (isJust )
27
29
import Data.Monoid (Last (.. ))
28
30
import Data.Text (Text )
29
31
import qualified Data.Text as Text
@@ -50,6 +52,16 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
50
52
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (.. ))
51
53
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (.. ), DiffusionMode (.. ))
52
54
55
+ -- | Parse field that have been removed from the configuration file and
56
+ -- fail if they are present.
57
+ --
58
+ -- This is used to notify users that a field has been removed from the
59
+ -- configuration file.
60
+ failOnRemovedField :: Aeson. Object -> Key -> String -> Aeson. Parser ()
61
+ failOnRemovedField obj removedField errorMessage = do
62
+ mVal :: Maybe Aeson. Value <- obj .:? removedField
63
+ when (isJust mVal) $ fail errorMessage
64
+
53
65
data NetworkP2PMode = EnabledP2PMode | DisabledP2PMode
54
66
deriving (Eq , Show , Generic )
55
67
@@ -104,7 +116,7 @@ data NodeConfiguration
104
116
--
105
117
-- This flag should be set to 'True' when testing the new protocol
106
118
-- versions.
107
- , ncTestEnableDevelopmentNetworkProtocols :: ! Bool
119
+ , ncExperimentalProtocolsEnabled :: ! Bool
108
120
109
121
-- BlockFetch configuration
110
122
, ncMaxConcurrencyBulkSync :: ! (Maybe MaxConcurrencyBulkSync )
@@ -160,7 +172,7 @@ data PartialNodeConfiguration
160
172
-- Node parameters, not protocol-specific:
161
173
, pncDiffusionMode :: ! (Last DiffusionMode )
162
174
, pncSnapshotInterval :: ! (Last SnapshotInterval )
163
- , pncTestEnableDevelopmentNetworkProtocols :: ! (Last Bool )
175
+ , pncExperimentalProtocolsEnabled :: ! (Last Bool )
164
176
165
177
-- BlockFetch configuration
166
178
, pncMaxConcurrencyBulkSync :: ! (Last MaxConcurrencyBulkSync )
@@ -211,8 +223,11 @@ instance FromJSON PartialNodeConfiguration where
211
223
<- Last . fmap getDiffusionMode <$> v .:? " DiffusionMode"
212
224
pncSnapshotInterval
213
225
<- Last . fmap RequestedSnapshotInterval <$> v .:? " SnapshotInterval"
214
- pncTestEnableDevelopmentNetworkProtocols
215
- <- Last <$> v .:? " TestEnableDevelopmentNetworkProtocols"
226
+ pncExperimentalProtocolsEnabled <- fmap Last $ do
227
+ failOnRemovedField v " TestEnableDevelopmentNetworkProtocols"
228
+ " TestEnableDevelopmentNetworkProtocols has been renamed to ExperimentalProtocolsEnabled"
229
+
230
+ v .:? " ExperimentalProtocolsEnabled"
216
231
217
232
-- Blockfetch parameters
218
233
pncMaxConcurrencyBulkSync <- Last <$> v .:? " MaxConcurrencyBulkSync"
@@ -276,7 +291,7 @@ instance FromJSON PartialNodeConfiguration where
276
291
, pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
277
292
, pncDiffusionMode
278
293
, pncSnapshotInterval
279
- , pncTestEnableDevelopmentNetworkProtocols
294
+ , pncExperimentalProtocolsEnabled
280
295
, pncMaxConcurrencyBulkSync
281
296
, pncMaxConcurrencyDeadline
282
297
, pncLoggingSwitch = Last $ Just pncLoggingSwitch'
@@ -383,9 +398,12 @@ instance FromJSON PartialNodeConfiguration where
383
398
}
384
399
385
400
parseHardForkProtocol v = do
386
- npcTestEnableDevelopmentHardForkEras
387
- <- v .:? " TestEnableDevelopmentHardForkEras"
388
- .!= False
401
+
402
+ npcExperimentalHardForksEnabled <- do
403
+ failOnRemovedField v " TestEnableDevelopmentHardForkEras"
404
+ " TestEnableDevelopmentHardForkEras has been renamed to ExperimentalHardForksEnabled"
405
+
406
+ v .:? " ExperimentalHardForksEnabled" .!= False
389
407
390
408
npcTestShelleyHardForkAtEpoch <- v .:? " TestShelleyHardForkAtEpoch"
391
409
npcTestShelleyHardForkAtVersion <- v .:? " TestShelleyHardForkAtVersion"
@@ -405,27 +423,27 @@ instance FromJSON PartialNodeConfiguration where
405
423
npcTestConwayHardForkAtEpoch <- v .:? " TestConwayHardForkAtEpoch"
406
424
npcTestConwayHardForkAtVersion <- v .:? " TestConwayHardForkAtVersion"
407
425
408
- pure NodeHardForkProtocolConfiguration {
409
- npcTestEnableDevelopmentHardForkEras,
426
+ pure NodeHardForkProtocolConfiguration
427
+ { npcExperimentalHardForksEnabled
410
428
411
- npcTestShelleyHardForkAtEpoch,
412
- npcTestShelleyHardForkAtVersion,
429
+ , npcTestShelleyHardForkAtEpoch
430
+ , npcTestShelleyHardForkAtVersion
413
431
414
- npcTestAllegraHardForkAtEpoch,
415
- npcTestAllegraHardForkAtVersion,
432
+ , npcTestAllegraHardForkAtEpoch
433
+ , npcTestAllegraHardForkAtVersion
416
434
417
- npcTestMaryHardForkAtEpoch,
418
- npcTestMaryHardForkAtVersion,
435
+ , npcTestMaryHardForkAtEpoch
436
+ , npcTestMaryHardForkAtVersion
419
437
420
- npcTestAlonzoHardForkAtEpoch,
421
- npcTestAlonzoHardForkAtVersion,
438
+ , npcTestAlonzoHardForkAtEpoch
439
+ , npcTestAlonzoHardForkAtVersion
422
440
423
- npcTestBabbageHardForkAtEpoch,
424
- npcTestBabbageHardForkAtVersion,
441
+ , npcTestBabbageHardForkAtEpoch
442
+ , npcTestBabbageHardForkAtVersion
425
443
426
- npcTestConwayHardForkAtEpoch,
427
- npcTestConwayHardForkAtVersion
428
- }
444
+ , npcTestConwayHardForkAtEpoch
445
+ , npcTestConwayHardForkAtVersion
446
+ }
429
447
430
448
-- | Default configuration is mainnet
431
449
defaultPartialNodeConfiguration :: PartialNodeConfiguration
@@ -437,7 +455,7 @@ defaultPartialNodeConfiguration =
437
455
, pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty mempty
438
456
, pncDiffusionMode = Last $ Just InitiatorAndResponderDiffusionMode
439
457
, pncSnapshotInterval = Last $ Just DefaultSnapshotInterval
440
- , pncTestEnableDevelopmentNetworkProtocols = Last $ Just False
458
+ , pncExperimentalProtocolsEnabled = Last $ Just False
441
459
, pncTopologyFile = Last . Just $ TopologyFile " configuration/cardano/mainnet-topology.json"
442
460
, pncProtocolFiles = mempty
443
461
, pncValidateDB = mempty
@@ -510,9 +528,9 @@ makeNodeConfiguration pnc = do
510
528
$ pncEnableP2P pnc
511
529
512
530
-- TODO: This is not mandatory
513
- testEnableDevelopmentNetworkProtocols <-
514
- lastToEither " Missing TestEnableDevelopmentNetworkProtocols " $
515
- pncTestEnableDevelopmentNetworkProtocols pnc
531
+ experimentalProtocols <-
532
+ lastToEither " Missing ExperimentalProtocolsEnabled " $
533
+ pncExperimentalProtocolsEnabled pnc
516
534
return $ NodeConfiguration
517
535
{ ncConfigFile = configFile
518
536
, ncTopologyFile = topologyFile
@@ -530,7 +548,7 @@ makeNodeConfiguration pnc = do
530
548
, ncSocketConfig = socketConfig
531
549
, ncDiffusionMode = diffusionMode
532
550
, ncSnapshotInterval = snapshotInterval
533
- , ncTestEnableDevelopmentNetworkProtocols = testEnableDevelopmentNetworkProtocols
551
+ , ncExperimentalProtocolsEnabled = experimentalProtocols
534
552
, ncMaxConcurrencyBulkSync = getLast $ pncMaxConcurrencyBulkSync pnc
535
553
, ncMaxConcurrencyDeadline = getLast $ pncMaxConcurrencyDeadline pnc
536
554
, ncLoggingSwitch = loggingSwitch
0 commit comments