Skip to content

Commit

Permalink
Add support for 'TestEnableUnstableEras' node config entry
Browse files Browse the repository at this point in the history
And use it for the Mary -> Alonzo hard fork.

During development and integration of new eras we wish to be able to
test the hard fork transition into the new era, but we do not wish to
generally have the node advertise that it understands the new era.

Avoiding advertising new development eras until they are ready makes it
practical to include new not-yet-ready eras into the main release
version of the node without the danger that operators on the mainnet
will prematurely advertise that their nodes are capable of crossing the
next hard fork.

This flag should be set to true for nodes in testnets where the testnet
purpose is to test the new era. It should always remain at the default
of false for nodes on mainnet.
  • Loading branch information
dcoutts committed May 12, 2021
1 parent 7e7f48e commit a8ad59d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ instance FromJSON PartialNodeConfiguration where
}

parseHardForkProtocol v = do
npcTestEnableUnstableEras <- v .:? "TestEnableUnstableEras" .!= False

npcTestShelleyHardForkAtEpoch <- v .:? "TestShelleyHardForkAtEpoch"
npcTestShelleyHardForkAtVersion <- v .:? "TestShelleyHardForkAtVersion"

Expand All @@ -240,6 +242,8 @@ instance FromJSON PartialNodeConfiguration where
npcTestAlonzoHardForkAtVersion <- v .:? "TestAlonzoHardForkAtVersion"

pure NodeHardForkProtocolConfiguration {
npcTestEnableUnstableEras,

npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,

Expand Down
14 changes: 10 additions & 4 deletions cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcShelleyGenesisFileHash
}
NodeHardForkProtocolConfiguration {
npcTestEnableUnstableEras,
npcTestShelleyHardForkAtEpoch,
npcTestShelleyHardForkAtVersion,
npcTestAllegraHardForkAtEpoch,
Expand Down Expand Up @@ -171,12 +172,17 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
-- version that this node will declare that it understands, when it
-- is in the Mary era. Since Mary is currently the last known
-- protocol version then this is also the Mary protocol version.
--
-- During testing of the Alonzo era, we conditionally declare that we
-- know about the Alonzo era. We do so only when a config option for
-- testing development/unstable eras is used. This lets us include
-- not-yet-ready eras in released node versions without mainnet nodes
-- prematurely advertising that they could hard fork into the new era.
maryProtVer =
ProtVer 4 0
if npcTestEnableUnstableEras
then ProtVer 5 0 -- Advertise we can support Alonzo
else ProtVer 4 0 -- Otherwise only advertise we know about Mary.
}
-- TODO: TestEnableDevelopmentHardForkEras :: Bool. This bool
-- will tell use whether or not to change the 'maryProtVer' field
-- from version 4 to version 5 so that we can fork to version 5
Consensus.ProtocolParamsAlonzo {
-- This is /not/ the Alonzo protocol version. It is the protocol
-- version that this node will declare that it understands, when it
Expand Down
18 changes: 16 additions & 2 deletions cardano-node/src/Cardano/Node/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,28 @@ data NodeByronProtocolConfiguration =
data NodeHardForkProtocolConfiguration =
NodeHardForkProtocolConfiguration {

-- | During development and integration of new eras we wish to be able
-- to test the hard fork transition into the new era, but we do not wish
-- to generally have the node advertise that it understands the new era.
-- Avoiding advertising new development eras until they are ready makes
-- it practical to include new not-yet-ready eras into the main release
-- version of the node without the danger that operators on the mainnet
-- will prematurely advertise that their nodes are capable of crossing
-- the next hard fork.
--
-- This flag should be set to true for nodes in testnets where the
-- testnet purpose is to test the new era. It should /always/ remain at
-- the default of false for nodes on mainnet.
--
npcTestEnableUnstableEras :: 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).
--
-- Obviously if this is used, all the nodes in the test cluster must be
-- configured the same, or they will disagree.
--
npcTestShelleyHardForkAtEpoch :: Maybe EpochNo
, npcTestShelleyHardForkAtEpoch :: Maybe EpochNo

-- | For testing purposes we support specifying that the hard fork
-- happens at a given major protocol version. For example this can be
Expand Down Expand Up @@ -371,7 +386,6 @@ data NodeHardForkProtocolConfiguration =
-- configured the same, or they will disagree.
--
, npcTestAlonzoHardForkAtVersion :: Maybe Word
-- TODO: npcTestEnableDevelopmentHardForkEras :: Bool
}
deriving (Eq, Show)

Expand Down

0 comments on commit a8ad59d

Please sign in to comment.