Skip to content

Commit

Permalink
Remove allowOutsideForecastTTL hardfork switch
Browse files Browse the repository at this point in the history
since it was verified that removing it creates the same ledger state,
proving the switch unnecessary.
  • Loading branch information
teodanciu committed Nov 25, 2022
1 parent 4ca4db0 commit 9e86252
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 20 deletions.
11 changes: 3 additions & 8 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs
Expand Up @@ -76,7 +76,6 @@ import Cardano.Ledger.Rules.ValidationMode
runTest,
runTestOnSignal,
)
import Cardano.Ledger.Shelley.HardForks (allowOutsideForecastTTL)
import qualified Cardano.Ledger.Shelley.LedgerState as Shelley
import Cardano.Ledger.Shelley.Rules (ShelleyUtxoPredFailure, UtxoEnv)
import qualified Cardano.Ledger.Shelley.Rules as Shelley
Expand Down Expand Up @@ -341,22 +340,18 @@ validateOutsideForecast ::
AlonzoEraTxWits era,
EraTx era
) =>
PParams era ->
EpochInfo (Either a) ->
-- | Current slot number
SlotNo ->
SystemStart ->
Tx era ->
Test (AlonzoUtxoPredFailure era)
validateOutsideForecast pp ei slotNo sysSt tx =
validateOutsideForecast ei slotNo sysSt tx =
{- (_,i_f) := txvldt tx -}
case tx ^. bodyTxL . vldtTxBodyL of
ValidityInterval _ (SJust ifj)
| not (nullRedeemers (tx ^. witsTxL . rdmrsTxWitsL)) ->
let ei' =
if allowOutsideForecastTTL pp
then unsafeLinearExtendEpochInfo slotNo ei
else ei
let ei' = unsafeLinearExtendEpochInfo slotNo ei
in -- ◇ ∉ { txrdmrs tx, i_f } ⇒
failureUnless (isRight (epochInfoSlotToUTCTime ei' sysSt ifj)) $ OutsideForecast ifj
_ -> pure ()
Expand Down Expand Up @@ -497,7 +492,7 @@ utxoTransition = do
ei <- liftSTS $ asks epochInfo

{- epochInfoSlotToUTCTime epochInfo systemTime i_f ≠ ◇ -}
runTest $ validateOutsideForecast pp ei slot sysSt tx
runTest $ validateOutsideForecast ei slot sysSt tx

{- txins txb ≠ ∅ -}
runTestOnSignal $ Shelley.validateInputSetEmptyUTxO txBody
Expand Down
2 changes: 1 addition & 1 deletion eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs
Expand Up @@ -359,7 +359,7 @@ utxoTransition = do
ei <- liftSTS $ asks epochInfo

{- epochInfoSlotToUTCTime epochInfo systemTime i_f ≠ ◇ -}
runTest $ validateOutsideForecast pp ei slot sysSt tx
runTest $ validateOutsideForecast ei slot sysSt tx

{- txins txb ≠ ∅ -}
runTestOnSignal $ Shelley.validateInputSetEmptyUTxO txBody
Expand Down
11 changes: 0 additions & 11 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/HardForks.hs
Expand Up @@ -8,7 +8,6 @@ module Cardano.Ledger.Shelley.HardForks
validatePoolRewardAccountNetID,
missingScriptsSymmetricDifference,
forgoRewardPrefilter,
allowOutsideForecastTTL,
)
where

Expand Down Expand Up @@ -58,13 +57,3 @@ forgoRewardPrefilter ::
pp ->
Bool
forgoRewardPrefilter pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @6

-- | In versions 5 and 6, we allow the ttl field to lie outside the stability
-- window.
allowOutsideForecastTTL ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
allowOutsideForecastTTL pp =
let mv = pvMajor (getField @"_protocolVersion" pp)
in mv == natVersion @5 || mv == natVersion @6
73 changes: 73 additions & 0 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/HardForks.hs.orig
@@ -0,0 +1,73 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}

module Cardano.Ledger.Shelley.HardForks
( aggregatedRewards,
allowMIRTransfer,
validatePoolRewardAccountNetID,
missingScriptsSymmetricDifference,
forgoRewardPrefilter,
)
where

import Cardano.Ledger.BaseTypes (ProtVer (..), natVersion)
import GHC.Records

aggregatedRewards ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
aggregatedRewards pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @2

-- | Starting with protocol version 5, the MIR certs will also be
-- able to transfer funds between the reserves and the treasury.
-- Additionally, the semantics for the pervious functionality will
-- change a bit. Before version 5 redundancies in the instantaneous
-- reward mapping were handled by overriding. Now they are handled
-- by adding the values and allowing for negatives updates, provided
-- the sum for each key remains positive.
allowMIRTransfer ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
allowMIRTransfer pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @4

-- | Starting with protocol version 5, we will validate the network ID
-- for the reward account listed in stake pool registration certificates.
validatePoolRewardAccountNetID ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
validatePoolRewardAccountNetID pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @4

-- | Starting with protocol version 7, the UTXO rule predicate failure
-- MissingScriptWitnessesUTXOW will not be used for extraneous scripts
missingScriptsSymmetricDifference ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
missingScriptsSymmetricDifference pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @6

-- | Starting with protocol version 7, the reward calculation no longer
-- filters out unregistered stake addresses at the moment the calculation begins.
-- See the Shelley Ledger Errata 17.2.
forgoRewardPrefilter ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
<<<<<<< HEAD
forgoRewardPrefilter pp = pvMajor (getField @"_protocolVersion" pp) > natVersion @6

-- | In versions 5 and 6, we allow the ttl field to lie outside the stability
-- window.
allowOutsideForecastTTL ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
allowOutsideForecastTTL pp =
let mv = pvMajor (getField @"_protocolVersion" pp)
in mv == natVersion @5 || mv == natVersion @6
=======
forgoRewardPrefilter pp = pvMajor (getField @"_protocolVersion" pp) > 6
>>>>>>> 4981d58ed (Remove `allowOutsideForecastTTL` hardfork switch)

0 comments on commit 9e86252

Please sign in to comment.