Skip to content

Rename TestEnableDevelopmentHardForkEras and TestEnableDevelopmentNetworkProtocols #4341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Features

- Rename `TestEnableDevelopmentHardForkEras` to `ExperimentalHardForksEnabled` and
`TestEnableDevelopmentNetworkProtocols` to `ExperimentalProtocolsEnabled`
([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
74 changes: 46 additions & 28 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 @@ -104,7 +116,7 @@ data NodeConfiguration
--
-- This flag should be set to 'True' when testing the new protocol
-- versions.
, ncTestEnableDevelopmentNetworkProtocols :: !Bool
, ncExperimentalProtocolsEnabled :: !Bool

-- BlockFetch configuration
, ncMaxConcurrencyBulkSync :: !(Maybe MaxConcurrencyBulkSync)
Expand Down Expand Up @@ -160,7 +172,7 @@ data PartialNodeConfiguration
-- Node parameters, not protocol-specific:
, pncDiffusionMode :: !(Last DiffusionMode)
, pncSnapshotInterval :: !(Last SnapshotInterval)
, pncTestEnableDevelopmentNetworkProtocols :: !(Last Bool)
, pncExperimentalProtocolsEnabled :: !(Last Bool)

-- BlockFetch configuration
, pncMaxConcurrencyBulkSync :: !(Last MaxConcurrencyBulkSync)
Expand Down Expand Up @@ -211,8 +223,11 @@ instance FromJSON PartialNodeConfiguration where
<- Last . fmap getDiffusionMode <$> v .:? "DiffusionMode"
pncSnapshotInterval
<- Last . fmap RequestedSnapshotInterval <$> v .:? "SnapshotInterval"
pncTestEnableDevelopmentNetworkProtocols
<- Last <$> v .:? "TestEnableDevelopmentNetworkProtocols"
pncExperimentalProtocolsEnabled <- fmap Last $ do
failOnRemovedField v "TestEnableDevelopmentNetworkProtocols"
"TestEnableDevelopmentNetworkProtocols has been renamed to ExperimentalProtocolsEnabled"

v .:? "ExperimentalProtocolsEnabled"

-- Blockfetch parameters
pncMaxConcurrencyBulkSync <- Last <$> v .:? "MaxConcurrencyBulkSync"
Expand Down Expand Up @@ -276,7 +291,7 @@ instance FromJSON PartialNodeConfiguration where
, pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty pncSocketPath
, pncDiffusionMode
, pncSnapshotInterval
, pncTestEnableDevelopmentNetworkProtocols
, pncExperimentalProtocolsEnabled
, pncMaxConcurrencyBulkSync
, pncMaxConcurrencyDeadline
, pncLoggingSwitch = Last $ Just pncLoggingSwitch'
Expand Down Expand Up @@ -383,9 +398,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 @@ -405,27 +423,27 @@ instance FromJSON PartialNodeConfiguration where
npcTestConwayHardForkAtEpoch <- v .:? "TestConwayHardForkAtEpoch"
npcTestConwayHardForkAtVersion <- v .:? "TestConwayHardForkAtVersion"

pure NodeHardForkProtocolConfiguration {
npcTestEnableDevelopmentHardForkEras,
pure NodeHardForkProtocolConfiguration
{ npcExperimentalHardForksEnabled

npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
, npcTestShelleyHardForkAtEpoch
, npcTestShelleyHardForkAtVersion

npcTestAllegraHardForkAtEpoch,
npcTestAllegraHardForkAtVersion,
, npcTestAllegraHardForkAtEpoch
, npcTestAllegraHardForkAtVersion

npcTestMaryHardForkAtEpoch,
npcTestMaryHardForkAtVersion,
, npcTestMaryHardForkAtEpoch
, npcTestMaryHardForkAtVersion

npcTestAlonzoHardForkAtEpoch,
npcTestAlonzoHardForkAtVersion,
, npcTestAlonzoHardForkAtEpoch
, npcTestAlonzoHardForkAtVersion

npcTestBabbageHardForkAtEpoch,
npcTestBabbageHardForkAtVersion,
, npcTestBabbageHardForkAtEpoch
, npcTestBabbageHardForkAtVersion

npcTestConwayHardForkAtEpoch,
npcTestConwayHardForkAtVersion
}
, npcTestConwayHardForkAtEpoch
, npcTestConwayHardForkAtVersion
}

-- | Default configuration is mainnet
defaultPartialNodeConfiguration :: PartialNodeConfiguration
Expand All @@ -437,7 +455,7 @@ defaultPartialNodeConfiguration =
, pncSocketConfig = Last . Just $ SocketConfig mempty mempty mempty mempty
, pncDiffusionMode = Last $ Just InitiatorAndResponderDiffusionMode
, pncSnapshotInterval = Last $ Just DefaultSnapshotInterval
, pncTestEnableDevelopmentNetworkProtocols = Last $ Just False
, pncExperimentalProtocolsEnabled = Last $ Just False
, pncTopologyFile = Last . Just $ TopologyFile "configuration/cardano/mainnet-topology.json"
, pncProtocolFiles = mempty
, pncValidateDB = mempty
Expand Down Expand Up @@ -510,9 +528,9 @@ makeNodeConfiguration pnc = do
$ pncEnableP2P pnc

-- TODO: This is not mandatory
testEnableDevelopmentNetworkProtocols <-
lastToEither "Missing TestEnableDevelopmentNetworkProtocols" $
pncTestEnableDevelopmentNetworkProtocols pnc
experimentalProtocols <-
lastToEither "Missing ExperimentalProtocolsEnabled" $
pncExperimentalProtocolsEnabled pnc
return $ NodeConfiguration
{ ncConfigFile = configFile
, ncTopologyFile = topologyFile
Expand All @@ -530,7 +548,7 @@ makeNodeConfiguration pnc = do
, ncSocketConfig = socketConfig
, ncDiffusionMode = diffusionMode
, ncSnapshotInterval = snapshotInterval
, ncTestEnableDevelopmentNetworkProtocols = testEnableDevelopmentNetworkProtocols
, ncExperimentalProtocolsEnabled = experimentalProtocols
, ncMaxConcurrencyBulkSync = getLast $ pncMaxConcurrencyBulkSync pnc
, ncMaxConcurrencyDeadline = getLast $ pncMaxConcurrencyDeadline pnc
, ncLoggingSwitch = loggingSwitch
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ nodeRunParser = do
, pncDatabaseFile = DbFile <$> dbFp
, pncDiffusionMode = mempty
, pncSnapshotInterval = snapshotInterval
, pncTestEnableDevelopmentNetworkProtocols = mempty
, pncExperimentalProtocolsEnabled = mempty
, pncProtocolFiles = Last $ Just ProtocolFilepaths
{ byronCertFile
, byronKeyFile
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,
npcExperimentalHardForksEnabled,
-- 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 npcExperimentalHardForksEnabled
then ProtVer 9 0
else ProtVer 8 0,
Praos.conwayMaxTxCapacityOverrides =
Expand Down
38 changes: 21 additions & 17 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -429,22 +429,26 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
Nothing
#endif
void $
let diffusionArgumentsExtra =
mkP2PArguments nc
(readTVar localRootsVar)
(readTVar publicRootsVar)
(readTVar useLedgerVar)
in
Node.run
nodeArgs
StdRunNodeArgs
{ srnBfcMaxConcurrencyBulkSync = unMaxConcurrencyBulkSync <$> ncMaxConcurrencyBulkSync nc
, srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
, srnChainDbValidateOverride = ncValidateDB nc
, srnSnapshotInterval = ncSnapshotInterval nc
, srnDatabasePath = dbPath
, srnDiffusionArguments = diffusionArguments
, srnDiffusionArgumentsExtra = mkP2PArguments nc (readTVar localRootsVar)
(readTVar publicRootsVar)
(readTVar useLedgerVar)
, srnDiffusionTracers = diffusionTracers tracers
, srnDiffusionTracersExtra = diffusionTracersExtra tracers
, srnEnableInDevelopmentVersions = ncTestEnableDevelopmentNetworkProtocols nc
, srnTraceChainDB = chainDBTracer tracers
{ srnBfcMaxConcurrencyBulkSync = unMaxConcurrencyBulkSync <$> ncMaxConcurrencyBulkSync nc
, srnBfcMaxConcurrencyDeadline = unMaxConcurrencyDeadline <$> ncMaxConcurrencyDeadline nc
, srnChainDbValidateOverride = ncValidateDB nc
, srnSnapshotInterval = ncSnapshotInterval nc
, srnDatabasePath = dbPath
, srnDiffusionArguments = diffusionArguments
, srnDiffusionArgumentsExtra = diffusionArgumentsExtra
, srnDiffusionTracers = diffusionTracers tracers
, srnDiffusionTracersExtra = diffusionTracersExtra tracers
, srnEnableInDevelopmentVersions = ncExperimentalProtocolsEnabled nc
, srnTraceChainDB = chainDBTracer tracers
, srnMaybeMempoolCapacityOverride = ncMaybeMempoolCapacityOverride nc
}
DisabledP2PMode -> do
Expand Down Expand Up @@ -483,7 +487,7 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
, srnDiffusionArgumentsExtra = mkNonP2PArguments ipProducers dnsProducers
, srnDiffusionTracers = diffusionTracers tracers
, srnDiffusionTracersExtra = diffusionTracersExtra tracers
, srnEnableInDevelopmentVersions = ncTestEnableDevelopmentNetworkProtocols nc
, srnEnableInDevelopmentVersions = ncExperimentalProtocolsEnabled nc
, srnTraceChainDB = chainDBTracer tracers
, srnMaybeMempoolCapacityOverride = ncMaybeMempoolCapacityOverride nc
}
Expand All @@ -509,13 +513,13 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
$ supportedNodeToClientVersions (Proxy @blk)
(_, Nothing) -> Map.keys
$ supportedNodeToClientVersions (Proxy @blk)
when ( ncTestEnableDevelopmentNetworkProtocols nc
when ( ncExperimentalProtocolsEnabled nc
&& not (null developmentNtnVersions))
$ traceWith (startupTracer tracers)
(WarningDevelopmentNodeToNodeVersions
developmentNtnVersions)

when ( ncTestEnableDevelopmentNetworkProtocols nc
when ( ncExperimentalProtocolsEnabled nc
&& not (null developmentNtcVersions))
$ traceWith (startupTracer tracers)
(WarningDevelopmentNodeToClientVersions
Expand Down Expand Up @@ -552,7 +556,7 @@ handleSimpleNode runP p2pMode tracers nc onKernel = do
-> Map k v
-> Map k v
limitToLatestReleasedVersion prj =
if ncTestEnableDevelopmentNetworkProtocols nc then id
if ncExperimentalProtocolsEnabled nc then id
else
case prj $ latestReleasedNodeVersion (Proxy @blk) of
Nothing -> id
Expand Down
4 changes: 2 additions & 2 deletions cardano-node/src/Cardano/Node/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ data StartupTrace blk =
-- | Warn when 'EnableP2P' is set.
| P2PWarning

-- | Warn when 'TestEnableDevelopmentNetworkProtocols' is set and affects
-- | Warn when 'ExperimentalProtocolsEnabled' is set and affects
-- node-to-node protocol.
--
| WarningDevelopmentNodeToNodeVersions [NodeToNodeVersion]

-- | Warn when 'TestEnableDevelopmentNetworkProtocols' is set and affects
-- | Warn when 'ExperimentalProtocolsEnabled' is set and affects
-- node-to-client protocol.
--
| WarningDevelopmentNodeToClientVersions [NodeToClientVersion]
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
npcExperimentalHardForksEnabled :: 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
6 changes: 3 additions & 3 deletions cardano-node/test/Test/Cardano/Node/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ testPartialYamlConfig =
, pncShutdownConfig = Last Nothing
, pncDiffusionMode = Last Nothing
, pncSnapshotInterval = mempty
, pncTestEnableDevelopmentNetworkProtocols = Last Nothing
, pncExperimentalProtocolsEnabled = Last Nothing
, pncMaxConcurrencyBulkSync = Last Nothing
, pncMaxConcurrencyDeadline = Last Nothing
, pncLoggingSwitch = Last $ Just True
Expand Down Expand Up @@ -91,7 +91,7 @@ testPartialCliConfig =
, pncDatabaseFile = mempty
, pncDiffusionMode = mempty
, pncSnapshotInterval = Last . Just . RequestedSnapshotInterval $ secondsToDiffTime 100
, pncTestEnableDevelopmentNetworkProtocols = Last $ Just True
, pncExperimentalProtocolsEnabled = Last $ Just True
, pncProtocolFiles = Last . Just $ ProtocolFilepaths Nothing Nothing Nothing Nothing Nothing Nothing
, pncValidateDB = Last $ Just True
, pncProtocolConfig = mempty
Expand Down Expand Up @@ -130,7 +130,7 @@ eExpectedConfig = do
(GenesisFile "dummmy-genesis-file") Nothing
, ncDiffusionMode = InitiatorAndResponderDiffusionMode
, ncSnapshotInterval = RequestedSnapshotInterval $ secondsToDiffTime 100
, ncTestEnableDevelopmentNetworkProtocols = True
, ncExperimentalProtocolsEnabled = True
, ncMaxConcurrencyBulkSync = Nothing
, ncMaxConcurrencyDeadline = Nothing
, ncLoggingSwitch = True
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 configuration/chairman/byron-shelley/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ApplicationVersion: 1

##### Enable P2P Mode #####
EnableP2P: False
TestEnableDevelopmentNetworkProtocols: True
ExperimentalProtocolsEnabled: True

##### Logging configuration #####

Expand Down
2 changes: 1 addition & 1 deletion nix/nixos/cardano-node-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let
TargetNumberOfKnownPeers = cfg.targetNumberOfKnownPeers;
TargetNumberOfEstablishedPeers = cfg.targetNumberOfEstablishedPeers;
TargetNumberOfActivePeers = cfg.targetNumberOfActivePeers;
TestEnableDevelopmentNetworkProtocols = true;
ExperimentalProtocolsEnabled = true;
MaxConcurrencyBulkSync = 2;
})) cfg.extraNodeConfig;
baseInstanceConfig =
Expand Down
4 changes: 2 additions & 2 deletions nix/workbench/backend/nixops.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ let
minSeverity = "Debug";
TurnOnLogMetrics = true;

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

inherit TraceBlockFetchProtocol;

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

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

# TraceAcceptPolicy = false;
# TraceBlockFetchClient = true;
Expand Down
Loading