@@ -51,6 +51,17 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
51
51
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (.. ))
52
52
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (.. ), DiffusionMode (.. ))
53
53
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
+
54
65
data NetworkP2PMode = EnabledP2PMode | DisabledP2PMode
55
66
deriving (Eq , Show , Generic )
56
67
@@ -374,8 +385,16 @@ instance FromJSON PartialNodeConfiguration where
374
385
}
375
386
376
387
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"
379
398
.!= False
380
399
381
400
npcTestShelleyHardForkAtEpoch <- v .:? " TestShelleyHardForkAtEpoch"
@@ -394,7 +413,7 @@ instance FromJSON PartialNodeConfiguration where
394
413
npcTestBabbageHardForkAtVersion <- v .:? " TestBabbageHardForkAtVersion"
395
414
396
415
pure NodeHardForkProtocolConfiguration {
397
- npcTestEnableDevelopmentHardForkEras ,
416
+ npcTestEnableAdvertiseDevelopmentProtVer ,
398
417
399
418
npcTestShelleyHardForkAtEpoch,
400
419
npcTestShelleyHardForkAtVersion,
0 commit comments