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 Mar 22, 2023
1 parent 3888d54 commit 1e3563c
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 13 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 TestEnableAdvertiseDevelopmentProtVer ([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
27 changes: 24 additions & 3 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,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 @@ -383,8 +396,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 @@ -406,7 +427,7 @@ instance FromJSON PartialNodeConfiguration where
npcTestConwayHardForkAtVersion <- v .:? "TestConwayHardForkAtVersion"

pure NodeHardForkProtocolConfiguration {
npcTestEnableDevelopmentHardForkEras,
npcTestEnableAdvertiseDevelopmentProtVer,

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,
npcTestEnableAdvertiseDevelopmentProtVer,
-- 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 npcTestEnableAdvertiseDevelopmentProtVer
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
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 @@ -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 "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 @@ -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 "TestEnableAdvertiseDevelopmentProtVer" (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;
TestEnableAdvertiseDevelopmentProtVer = 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"
# "TestEnableAdvertiseDevelopmentProtVer"
# "TestEnableDevelopmentNetworkProtocols"
# "TestShelleyHardForkAtEpoch"
# "TestAllegraHardForkAtEpoch"
Expand Down Expand Up @@ -147,7 +147,7 @@ in {
# minSeverity = "Debug";
# TracingVerbosity = "NormalVerbosity";

# TestEnableDevelopmentHardForkEras = true;
# TestEnableAdvertiseDevelopmentProtVer = 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;
TestEnableAdvertiseDevelopmentProtVer = 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 "TestEnableAdvertiseDevelopmentProtVer: True" >> ${ROOT}/configuration.yaml
echo "TestEnableDevelopmentNetworkProtocols: True" >> ${ROOT}/configuration.yaml

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

0 comments on commit 1e3563c

Please sign in to comment.