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 Aug 16, 2022
1 parent 47247f6 commit ce9fcf3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 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 = "TestEnableDecelopmentHardForkEras 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
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 @@ -188,7 +188,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

0 comments on commit ce9fcf3

Please sign in to comment.