Skip to content

Commit 1e3563c

Browse files
Robert 'Probie' Offnernewhoggy
Robert 'Probie' Offner
authored andcommitted
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 3888d54 commit 1e3563c

File tree

10 files changed

+36
-13
lines changed

10 files changed

+36
-13
lines changed

Diff for: cardano-api/ChangeLog.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features
66

7+
- Rename TestEnableDevelopmentHardForkEras to TestEnableAdvertiseDevelopmentProtVer ([PR 4341](https://github.com/input-output-hk/cardano-node/pull/4341))
8+
79
- Append, not prepend change output when balancing a transaction ([PR 4343](https://github.com/input-output-hk/cardano-node/pull/4343))
810

911
- Expose convenience functions `executeQueryCardanoMode`, `determineEra`, `constructBalancedTx` and `queryStateForBalancedTx` ([PR 4446](https://github.com/input-output-hk/cardano-node/pull/4446))

Diff for: cardano-node/src/Cardano/Node/Configuration/POM.hs

+24-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ module Cardano.Node.Configuration.POM
2121
)
2222
where
2323

24+
import Control.Monad (when)
2425
import Data.Aeson
2526
import qualified Data.Aeson.Types as Aeson
2627
import Data.Bifunctor (Bifunctor (..))
28+
import Data.Maybe (isJust)
2729
import Data.Monoid (Last (..))
2830
import Data.Text (Text)
2931
import qualified Data.Text as Text
@@ -50,6 +52,17 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
5052
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (..))
5153
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))
5254

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

@@ -383,8 +396,16 @@ instance FromJSON PartialNodeConfiguration where
383396
}
384397

385398
parseHardForkProtocol v = do
386-
npcTestEnableDevelopmentHardForkEras
387-
<- v .:? "TestEnableDevelopmentHardForkEras"
399+
400+
failOnRemovedFields v
401+
[ RemovedField
402+
{ rfField = "TestEnableDevelopmentHardForkEras"
403+
, rfErr = "TestEnableDevelopmentHardForkEras has been renamed to TestEnableAdvertiseDevelopmentProtVer"
404+
}
405+
]
406+
407+
npcTestEnableAdvertiseDevelopmentProtVer
408+
<- v .:? "TestEnableAdvertiseDevelopmentProtVer"
388409
.!= False
389410

390411
npcTestShelleyHardForkAtEpoch <- v .:? "TestShelleyHardForkAtEpoch"
@@ -406,7 +427,7 @@ instance FromJSON PartialNodeConfiguration where
406427
npcTestConwayHardForkAtVersion <- v .:? "TestConwayHardForkAtVersion"
407428

408429
pure NodeHardForkProtocolConfiguration {
409-
npcTestEnableDevelopmentHardForkEras,
430+
npcTestEnableAdvertiseDevelopmentProtVer,
410431

411432
npcTestShelleyHardForkAtEpoch,
412433
npcTestShelleyHardForkAtVersion,

Diff for: cardano-node/src/Cardano/Node/Protocol/Cardano.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
9090
npcConwayGenesisFileHash
9191
}
9292
NodeHardForkProtocolConfiguration {
93-
npcTestEnableDevelopmentHardForkEras,
93+
npcTestEnableAdvertiseDevelopmentProtVer,
9494
-- During testing of the Alonzo era, we conditionally declared that we
9595
-- knew about the Alonzo era. We do so only when a config option for
9696
-- testing development/unstable eras is used. This lets us include
@@ -234,7 +234,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
234234
-- is in the Babbage era. Since Babbage is currently the last known
235235
-- protocol version then this is also the Babbage protocol version.
236236
Praos.conwayProtVer =
237-
if npcTestEnableDevelopmentHardForkEras
237+
if npcTestEnableAdvertiseDevelopmentProtVer
238238
then ProtVer 9 0
239239
else ProtVer 8 0,
240240
Praos.conwayMaxTxCapacityOverrides =

Diff for: cardano-node/src/Cardano/Node/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ data NodeHardForkProtocolConfiguration =
198198
-- This flag should be set to true for nodes taking part in testnets for
199199
-- testing the new era.
200200
--
201-
npcTestEnableDevelopmentHardForkEras :: Bool
201+
npcTestEnableAdvertiseDevelopmentProtVer :: Bool
202202

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

Diff for: cardano-testnet/src/Testnet/Babbage.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ babbageTestnet testnetOptions H.Conf {..} = do
9797
. HM.insert "TestMaryHardForkAtEpoch" (toJSON @Int 0)
9898
. HM.insert "TestAlonzoHardForkAtEpoch" (toJSON @Int 0)
9999
. HM.insert "TestBabbageHardForkAtEpoch" (toJSON @Int 0)
100-
. HM.insert "TestEnableDevelopmentHardForkEras" (toJSON True)
100+
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (toJSON True)
101101
. flip HM.alter "setupScribes"
102102
( fmap
103103
. J.rewriteArrayElements

Diff for: cardano-testnet/src/Testnet/Cardano.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ cardanoTestnet testnetOptions H.Conf {..} = do
256256
. HM.insert "LastKnownBlockVersion-Minor" (J.toJSON @Int 0)
257257
. HM.insert "TraceBlockchainTime" (J.toJSON True)
258258
. HM.delete "GenesisFile"
259-
. HM.insert "TestEnableDevelopmentHardForkEras" (J.toJSON @Bool True)
259+
. HM.insert "TestEnableAdvertiseDevelopmentProtVer" (J.toJSON @Bool True)
260260
. HM.insert "EnableP2P" (J.toJSON @Bool (cardanoEnableP2P testnetOptions))
261261
. flip HM.alter "setupScribes"
262262
( fmap

Diff for: nix/workbench/backend/nixops.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let
6868
minSeverity = "Debug";
6969
TurnOnLogMetrics = true;
7070

71-
TestEnableDevelopmentHardForkEras = true;
71+
TestEnableAdvertiseDevelopmentProtVer = true;
7272
TestEnableDevelopmentNetworkProtocols = true;
7373

7474
inherit TraceBlockFetchProtocol;

Diff for: nix/workbench/backend/nixops/role-explorer.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ in {
8787
# "LastKnownBlockVersion-Major"
8888
# "LastKnownBlockVersion-Minor"
8989
# "LastKnownBlockVersion-Alt"
90-
# "TestEnableDevelopmentHardForkEras"
90+
# "TestEnableAdvertiseDevelopmentProtVer"
9191
# "TestEnableDevelopmentNetworkProtocols"
9292
# "TestShelleyHardForkAtEpoch"
9393
# "TestAllegraHardForkAtEpoch"
@@ -147,7 +147,7 @@ in {
147147
# minSeverity = "Debug";
148148
# TracingVerbosity = "NormalVerbosity";
149149

150-
# TestEnableDevelopmentHardForkEras = true;
150+
# TestEnableAdvertiseDevelopmentProtVer = true;
151151
# TestEnableDevelopmentNetworkProtocols = true;
152152

153153
# TraceAcceptPolicy = false;

Diff for: nix/workbench/service/nodes.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ let
166166
]
167167
//
168168
{
169-
TestEnableDevelopmentHardForkEras = true;
169+
TestEnableAdvertiseDevelopmentProtVer = true;
170170
TestEnableDevelopmentNetworkProtocols = true;
171171
TurnOnLogMetrics = true;
172172
SnapshotFrequency = 1100;

Diff for: scripts/byron-to-alonzo/mkfiles.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ if [ "$1" = "alonzo" ]; then
663663
echo "TestAllegraHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
664664
echo "TestMaryHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
665665
echo "TestAlonzoHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
666-
echo "TestEnableDevelopmentHardForkEras: True" >> ${ROOT}/configuration.yaml
666+
echo "TestEnableAdvertiseDevelopmentProtVer: True" >> ${ROOT}/configuration.yaml
667667
echo "TestEnableDevelopmentNetworkProtocols: True" >> ${ROOT}/configuration.yaml
668668

669669
$SED -i ${ROOT}/configuration.yaml \

0 commit comments

Comments
 (0)