Skip to content

Commit d0ea45e

Browse files
author
Robert 'Probie' Offner
committed
Rename TestEnableDevelopmentHardForkEras
TestEnableDevelopmentHardForkEras has been renamed to TestEnableDevelopmentProtVer. An error is thrown if TestEnableDevelopmentHardForkEras is used to avoid it silently being set to False. Closes #4043
1 parent 521b64a commit d0ea45e

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

cardano-node/src/Cardano/Node/Configuration/POM.hs

+22-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
5151
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (..))
5252
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))
5353

54+
-- Since we ignore unknown fields, if we've explictly removed or renamed
55+
-- a field we should error out so that a user isn't surprised when they
56+
-- upgrade.
57+
data RemovedField = RemovedField { rfField :: Key, rfErr :: String }
58+
deriving Show
59+
60+
failOnRemovedFields :: Aeson.Object -> [RemovedField] -> Aeson.Parser ()
61+
failOnRemovedFields obj = mapM_ $ \(RemovedField field err) -> do
62+
mVal :: Maybe Aeson.Value <- obj .:? field
63+
when (isJust mVal) $ fail err
64+
5465
data NetworkP2PMode = EnabledP2PMode | DisabledP2PMode
5566
deriving (Eq, Show, Generic)
5667

@@ -374,8 +385,16 @@ instance FromJSON PartialNodeConfiguration where
374385
}
375386

376387
parseHardForkProtocol v = do
377-
npcTestEnableDevelopmentHardForkEras
378-
<- v .:? "TestEnableDevelopmentHardForkEras"
388+
389+
failOnRemovedFields v
390+
[ RemovedField
391+
{ rfField = "TestEnableDevelopmentHardForkEras"
392+
, rfErr = "TestEnableDevelopmentHardForkEras has been renamed to TestEnableAdvertiseDevelopmentProtVer"
393+
}
394+
]
395+
396+
npcTestEnableAdvertiseDevelopmentProtVer
397+
<- v .:? "TestEnableAdvertiseDevelopmentProtVer"
379398
.!= False
380399

381400
npcTestShelleyHardForkAtEpoch <- v .:? "TestShelleyHardForkAtEpoch"
@@ -394,7 +413,7 @@ instance FromJSON PartialNodeConfiguration where
394413
npcTestBabbageHardForkAtVersion <- v .:? "TestBabbageHardForkAtVersion"
395414

396415
pure NodeHardForkProtocolConfiguration {
397-
npcTestEnableDevelopmentHardForkEras,
416+
npcTestEnableAdvertiseDevelopmentProtVer,
398417

399418
npcTestShelleyHardForkAtEpoch,
400419
npcTestShelleyHardForkAtVersion,

cardano-node/src/Cardano/Node/Protocol/Cardano.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
8585
npcAlonzoGenesisFileHash
8686
}
8787
NodeHardForkProtocolConfiguration {
88-
-- npcTestEnableDevelopmentHardForkEras,
89-
-- During testing of the Alonzo era, we conditionally declared that we
90-
-- knew about the Alonzo era. We do so only when a config option for
91-
-- testing development/unstable eras is used. This lets us include
92-
-- not-yet-ready eras in released node versions without mainnet nodes
93-
-- prematurely advertising that they could hard fork into the new era.
88+
-- npcTestEnableDevelopmentProtVer
89+
-- During testing of the Alonzo era, we conditionally declared that we
90+
-- knew about the Alonzo era. We do so only when a config option for
91+
-- testing development/unstable eras is used. This lets us include
92+
-- not-yet-ready eras in released node versions without mainnet nodes
93+
-- prematurely advertising that they could hard fork into the new era.
9494
npcTestShelleyHardForkAtEpoch,
9595
npcTestShelleyHardForkAtVersion,
9696
npcTestAllegraHardForkAtEpoch,

cardano-node/src/Cardano/Node/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ data NodeHardForkProtocolConfiguration =
187187
-- This flag should be set to true for nodes taking part in testnets for
188188
-- testing the new era.
189189
--
190-
npcTestEnableDevelopmentHardForkEras :: Bool
190+
npcTestEnableAdvertiseDevelopmentProtVer :: Bool
191191

192192
-- | For testing purposes we support specifying that the hard fork
193193
-- happens at an exact epoch number (ie the first epoch of the new era).

cardano-testnet/src/Testnet/Babbage.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ testnet testnetOptions H.Conf {..} = do
168168
. HM.insert "TestMaryHardForkAtEpoch" (toJSON @Int 0)
169169
. HM.insert "TestAlonzoHardForkAtEpoch" (toJSON @Int 0)
170170
. HM.insert "TestBabbageHardForkAtEpoch" (toJSON @Int 0)
171-
. HM.insert "TestEnableDevelopmentHardForkEras" (toJSON True)
171+
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (toJSON True)
172172
. flip HM.alter "setupScribes"
173173
( fmap
174174
. J.rewriteArrayElements

cardano-testnet/src/Testnet/Cardano.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ testnet testnetOptions H.Conf {..} = do
246246
. HM.insert "LastKnownBlockVersion-Minor" (J.toJSON @Int 0)
247247
. HM.insert "TraceBlockchainTime" (J.toJSON True)
248248
. HM.delete "GenesisFile"
249-
. HM.insert "TestEnableDevelopmentHardForkEras" (J.toJSON @Bool True)
249+
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (J.toJSON @Bool True)
250250
. HM.insert "EnableP2P" (J.toJSON @Bool (enableP2P testnetOptions))
251251
. flip HM.alter "setupScribes"
252252
( fmap

nix/workbench/profiles/node-services.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ let
112112
]
113113
//
114114
{
115-
TestEnableDevelopmentHardForkEras = true;
115+
TestEnableAdvertiseDevelopmentProtVer = true;
116116
TestEnableDevelopmentNetworkProtocols = true;
117117
TurnOnLogMetrics = true;
118118
};

0 commit comments

Comments
 (0)