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 authored and newhoggy committed Apr 11, 2023
1 parent be1dd96 commit f0a45c4
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features

- Rename TestEnableDevelopmentHardForkEras to ExperimentalHardForksEnabled ([PR 4341](https://github.com/input-output-hk/cardano-node/pull/4341))

- Append, not prepend change output when balancing a transaction ([PR 4343](https://github.com/input-output-hk/cardano-node/pull/4343))

- Expose convenience functions `executeQueryCardanoMode`, `determineEra`, `constructBalancedTx` and `queryStateForBalancedTx` ([PR 4446](https://github.com/input-output-hk/cardano-node/pull/4446))
Expand Down
23 changes: 19 additions & 4 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ module Cardano.Node.Configuration.POM
)
where

import Control.Monad (when)
import Data.Aeson
import qualified Data.Aeson.Types as Aeson
import Data.Bifunctor (Bifunctor (..))
import Data.Maybe (isJust)
import Data.Monoid (Last (..))
import Data.Text (Text)
import qualified Data.Text as Text
Expand All @@ -50,6 +52,16 @@ import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (SnapshotInterval (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))

-- | Parse field that have been removed from the configuration file and
-- fail if they are present.
--
-- This is used to notify users that a field has been removed from the
-- configuration file.
failOnRemovedField :: Aeson.Object -> Key -> String -> Aeson.Parser ()
failOnRemovedField obj removedField errorMessage = do
mVal :: Maybe Aeson.Value <- obj .:? removedField
when (isJust mVal) $ fail errorMessage

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

Expand Down Expand Up @@ -383,9 +395,12 @@ instance FromJSON PartialNodeConfiguration where
}

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

npcExperimentalHardForksEnabled <- do
failOnRemovedField v "TestEnableDevelopmentHardForkEras"
"TestEnableDevelopmentHardForkEras has been renamed to ExperimentalHardForksEnabled"

v .:? "ExperimentalHardForksEnabled" .!= False

npcTestShelleyHardForkAtEpoch <- v .:? "TestShelleyHardForkAtEpoch"
npcTestShelleyHardForkAtVersion <- v .:? "TestShelleyHardForkAtVersion"
Expand All @@ -406,7 +421,7 @@ instance FromJSON PartialNodeConfiguration where
npcTestConwayHardForkAtVersion <- v .:? "TestConwayHardForkAtVersion"

pure NodeHardForkProtocolConfiguration {
npcTestEnableDevelopmentHardForkEras,
npcExperimentalHardForksEnabled,

npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
Expand Down
4 changes: 2 additions & 2 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcConwayGenesisFileHash
}
NodeHardForkProtocolConfiguration {
npcTestEnableDevelopmentHardForkEras,
npcExperimentalHardForks,
-- 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
Expand Down Expand Up @@ -234,7 +234,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
-- is in the Babbage era. Since Babbage is currently the last known
-- protocol version then this is also the Babbage protocol version.
Praos.conwayProtVer =
if npcTestEnableDevelopmentHardForkEras
if npcExperimentalHardForks
then ProtVer 9 0
else ProtVer 8 0,
Praos.conwayMaxTxCapacityOverrides =
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 @@ -198,7 +198,7 @@ data NodeHardForkProtocolConfiguration =
-- This flag should be set to true for nodes taking part in testnets for
-- testing the new era.
--
npcTestEnableDevelopmentHardForkEras :: Bool
npcExperimentalHardForks :: 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 @@ -97,7 +97,7 @@ babbageTestnet 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 "ExperimentalHardForksEnabled" (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 @@ -256,7 +256,7 @@ cardanoTestnet 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 "ExperimentalHardForksEnabled" (J.toJSON @Bool True)
. HM.insert "EnableP2P" (J.toJSON @Bool (cardanoEnableP2P testnetOptions))
. flip HM.alter "setupScribes"
( fmap
Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/backend/nixops.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let
minSeverity = "Debug";
TurnOnLogMetrics = true;

TestEnableDevelopmentHardForkEras = true;
ExperimentalHardForksEnabled = true;
TestEnableDevelopmentNetworkProtocols = true;

inherit TraceBlockFetchProtocol;
Expand Down
4 changes: 2 additions & 2 deletions nix/workbench/backend/nixops/role-explorer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ in {
# "LastKnownBlockVersion-Major"
# "LastKnownBlockVersion-Minor"
# "LastKnownBlockVersion-Alt"
# "TestEnableDevelopmentHardForkEras"
# "ExperimentalHardForksEnabled"
# "TestEnableDevelopmentNetworkProtocols"
# "TestShelleyHardForkAtEpoch"
# "TestAllegraHardForkAtEpoch"
Expand Down Expand Up @@ -147,7 +147,7 @@ in {
# minSeverity = "Debug";
# TracingVerbosity = "NormalVerbosity";

# TestEnableDevelopmentHardForkEras = true;
# ExperimentalHardForksEnabled = true;
# TestEnableDevelopmentNetworkProtocols = true;

# TraceAcceptPolicy = false;
Expand Down
2 changes: 1 addition & 1 deletion nix/workbench/service/nodes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ let
]
//
{
TestEnableDevelopmentHardForkEras = true;
ExperimentalHardForksEnabled = true;
TestEnableDevelopmentNetworkProtocols = true;
TurnOnLogMetrics = true;
SnapshotFrequency = 1100;
Expand Down
2 changes: 1 addition & 1 deletion scripts/byron-to-alonzo/mkfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ if [ "$1" = "alonzo" ]; then
echo "TestAllegraHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
echo "TestMaryHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
echo "TestAlonzoHardForkAtEpoch: 0" >> ${ROOT}/configuration.yaml
echo "TestEnableDevelopmentHardForkEras: True" >> ${ROOT}/configuration.yaml
echo "ExperimentalHardForksEnabled: True" >> ${ROOT}/configuration.yaml
echo "TestEnableDevelopmentNetworkProtocols: True" >> ${ROOT}/configuration.yaml

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

0 comments on commit f0a45c4

Please sign in to comment.