Skip to content

Commit

Permalink
Rename TestEnableDevelopmentHardForkEras
Browse files Browse the repository at this point in the history
TestEnableDevelopmentHardForkEras has been renamed to
TestEnableDevelopmentProtVer. An error is thrown if
TestEnableDevelopmentHardForkEras is used to avoid it silently being set
to False.

Closes #4043
  • Loading branch information
Robert 'Probie' Offner committed Oct 31, 2022
1 parent 521b64a commit d0ea45e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
25 changes: 22 additions & 3 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))

-- Since we ignore unknown fields, if we've explictly removed or renamed
-- a field we should error out so that a user isn't surprised when they
-- upgrade.
data RemovedField = RemovedField { rfField :: Key, rfErr :: String }
deriving Show

failOnRemovedFields :: Aeson.Object -> [RemovedField] -> Aeson.Parser ()
failOnRemovedFields obj = mapM_ $ \(RemovedField field err) -> do
mVal :: Maybe Aeson.Value <- obj .:? field
when (isJust mVal) $ fail err

data NetworkP2PMode = EnabledP2PMode | DisabledP2PMode
deriving (Eq, Show, Generic)

Expand Down Expand Up @@ -374,8 +385,16 @@ instance FromJSON PartialNodeConfiguration where
}

parseHardForkProtocol v = do
npcTestEnableDevelopmentHardForkEras
<- v .:? "TestEnableDevelopmentHardForkEras"

failOnRemovedFields v
[ RemovedField
{ rfField = "TestEnableDevelopmentHardForkEras"
, rfErr = "TestEnableDevelopmentHardForkEras has been renamed to TestEnableAdvertiseDevelopmentProtVer"
}
]

npcTestEnableAdvertiseDevelopmentProtVer
<- v .:? "TestEnableAdvertiseDevelopmentProtVer"
.!= False

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

pure NodeHardForkProtocolConfiguration {
npcTestEnableDevelopmentHardForkEras,
npcTestEnableAdvertiseDevelopmentProtVer,

npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
Expand Down
12 changes: 6 additions & 6 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcAlonzoGenesisFileHash
}
NodeHardForkProtocolConfiguration {
-- npcTestEnableDevelopmentHardForkEras,
-- During testing of the Alonzo era, we conditionally declared that we
-- knew about the Alonzo era. We do so only when a config option for
-- testing development/unstable eras is used. This lets us include
-- not-yet-ready eras in released node versions without mainnet nodes
-- prematurely advertising that they could hard fork into the new era.
-- npcTestEnableDevelopmentProtVer
-- During testing of the Alonzo era, we conditionally declared that we
-- knew about the Alonzo era. We do so only when a config option for
-- testing development/unstable eras is used. This lets us include
-- not-yet-ready eras in released node versions without mainnet nodes
-- prematurely advertising that they could hard fork into the new era.
npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
npcTestAllegraHardForkAtEpoch,
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ data NodeHardForkProtocolConfiguration =
-- This flag should be set to true for nodes taking part in testnets for
-- testing the new era.
--
npcTestEnableDevelopmentHardForkEras :: Bool
npcTestEnableAdvertiseDevelopmentProtVer :: Bool

-- | For testing purposes we support specifying that the hard fork
-- happens at an exact epoch number (ie the first epoch of the new era).
Expand Down
2 changes: 1 addition & 1 deletion cardano-testnet/src/Testnet/Babbage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ testnet testnetOptions H.Conf {..} = do
. HM.insert "TestMaryHardForkAtEpoch" (toJSON @Int 0)
. HM.insert "TestAlonzoHardForkAtEpoch" (toJSON @Int 0)
. HM.insert "TestBabbageHardForkAtEpoch" (toJSON @Int 0)
. HM.insert "TestEnableDevelopmentHardForkEras" (toJSON True)
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (toJSON True)
. flip HM.alter "setupScribes"
( fmap
. J.rewriteArrayElements
Expand Down
2 changes: 1 addition & 1 deletion cardano-testnet/src/Testnet/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ testnet testnetOptions H.Conf {..} = do
. HM.insert "LastKnownBlockVersion-Minor" (J.toJSON @Int 0)
. HM.insert "TraceBlockchainTime" (J.toJSON True)
. HM.delete "GenesisFile"
. HM.insert "TestEnableDevelopmentHardForkEras" (J.toJSON @Bool True)
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (J.toJSON @Bool True)
. HM.insert "EnableP2P" (J.toJSON @Bool (enableP2P testnetOptions))
. flip HM.alter "setupScribes"
( fmap
Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/profiles/node-services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let
]
//
{
TestEnableDevelopmentHardForkEras = true;
TestEnableAdvertiseDevelopmentProtVer = true;
TestEnableDevelopmentNetworkProtocols = true;
TurnOnLogMetrics = true;
};
Expand Down

0 comments on commit d0ea45e

Please sign in to comment.