-
Notifications
You must be signed in to change notification settings - Fork 720
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
Warn the protocol version is too low if we have ExperimentalHardForksEnabled
#5883
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
{-# LANGUAGE TypeApplications #-} | ||
|
||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
{-# LANGUAGE BangPatterns #-} | ||
|
||
module Cardano.Node.Protocol.Cardano | ||
( mkSomeConsensusProtocolCardano | ||
|
@@ -17,10 +18,12 @@ module Cardano.Node.Protocol.Cardano | |
|
||
import Cardano.Api | ||
import Cardano.Api.Byron as Byron | ||
import Cardano.Api.Ledger (ppProtocolVersionL) | ||
|
||
import qualified Cardano.Chain.Update as Update | ||
import qualified Cardano.Ledger.Api.Transition as Ledger | ||
import Cardano.Ledger.BaseTypes (natVersion) | ||
import Cardano.Ledger.BaseTypes (getVersion, natVersion) | ||
import Cardano.Ledger.Crypto (StandardCrypto) | ||
import qualified Cardano.Node.Protocol.Alonzo as Alonzo | ||
import qualified Cardano.Node.Protocol.Byron as Byron | ||
import qualified Cardano.Node.Protocol.Conway as Conway | ||
|
@@ -40,6 +43,8 @@ import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos | |
|
||
import Prelude | ||
|
||
import Control.Lens.Getter ((^.)) | ||
import Control.Monad (when) | ||
import Data.Maybe | ||
|
||
------------------------------------------------------------------------------ | ||
|
@@ -139,8 +144,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { | |
|
||
--TODO: all these protocol versions below are confusing and unnecessary. | ||
-- It could and should all be automated and these config entries eliminated. | ||
return $! | ||
SomeConsensusProtocol CardanoBlockType $ ProtocolInfoArgsCardano $ CardanoProtocolParams { | ||
let !cardanoProtocolParams = CardanoProtocolParams { | ||
paramsByron = | ||
Consensus.ProtocolParamsByron { | ||
byronGenesis = byronGenesis, | ||
|
@@ -314,11 +318,54 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { | |
, checkpoints = emptyCheckpointsMap | ||
} | ||
|
||
-- Check that the versions for the experimental hard forks are consistent | ||
warnAboutProtocolVersionsForExperimentalHardForks npcExperimentalHardForksEnabled | ||
cardanoProtocolParams shelleyGenesis | ||
|
||
return $! SomeConsensusProtocol CardanoBlockType $ | ||
ProtocolInfoArgsCardano cardanoProtocolParams | ||
|
||
---------------------------------------------------------------------- | ||
-- WARNING When adding new entries above, be aware that if there is an | ||
-- intra-era fork, then the numbering is not consecutive. | ||
---------------------------------------------------------------------- | ||
|
||
-- | Warn about the protocol versions for experimental hard forks | ||
warnAboutProtocolVersionsForExperimentalHardForks :: () | ||
=> Bool | ||
-> ProtocolParams (CardanoBlock StandardCrypto) | ||
-> ShelleyGenesis StandardCrypto | ||
-> ExceptT CardanoProtocolInstantiationError IO () | ||
warnAboutProtocolVersionsForExperimentalHardForks npcExperimentalHardForksEnabled | ||
CardanoProtocolParams | ||
{ hardForkTriggers = CardanoHardForkTriggers' | ||
{ triggerHardForkShelley = thfShelley, triggerHardForkAllegra = thfAllegra | ||
, triggerHardForkMary = thfMary, triggerHardForkAlonzo = thfAlonzo | ||
, triggerHardForkBabbage = thfBabbage, triggerHardForkConway = thfConway | ||
} | ||
} shelleyGenesis = | ||
when npcExperimentalHardForksEnabled (do | ||
let shelleyProtocolVersion = sgProtocolParams shelleyGenesis ^. ppProtocolVersionL | ||
checkHardForkVersion "Shelley" thfShelley shelleyProtocolVersion | ||
checkHardForkVersion "Allegra" thfAllegra shelleyProtocolVersion | ||
checkHardForkVersion "Mary" thfMary shelleyProtocolVersion | ||
checkHardForkVersion "Alonzo" thfAlonzo shelleyProtocolVersion | ||
checkHardForkVersion "Babbage" thfBabbage shelleyProtocolVersion | ||
checkHardForkVersion "Conway" thfConway shelleyProtocolVersion) | ||
where | ||
checkHardForkVersion :: () | ||
=> String | ||
-> Consensus.TriggerHardFork | ||
-> ProtVer | ||
-> ExceptT CardanoProtocolInstantiationError IO () | ||
checkHardForkVersion era (Consensus.TriggerHardForkAtVersion hfMajor) (ProtVer actualMajorVer _) = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the problem in the slack thread was hard forking to Conway at epoch 0. So we're actually (at this point) not interested in
See if you can use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Jimbo4350 I am comparing the Eras with the protocol version. I am using the numbers already hardcoded in the function, and those can be overriden, apparently. So having a mapping wouldn't work? But I don't understand how the epochs fit on this. How do we link the epochs to versions? I may be completely wrong. |
||
let actualMajor = getVersion actualMajorVer in | ||
when (hfMajor < actualMajor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't that result in printing the warning for each previous era? |
||
(liftIO $ putStrLn $ "Warning: experimental hard fork version " ++ show hfMajor ++ | ||
" for " ++ era ++ " is less than the actual protocol version " ++ show actualMajor ++ | ||
" specified for Shelley on its genesis file.") | ||
checkHardForkVersion _ _ _ = return () -- No need to check for epoch-based hard forks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make the |
||
|
||
------------------------------------------------------------------------------ | ||
-- Errors | ||
-- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should go with the other
LANGUAGE
pragma