Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Era.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Cardano.Ledger.Alonzo.Era (
AlonzoUTXOW,
AlonzoBBODY,
AlonzoLEDGER,
hardforkConwayTranslateUpperBoundForPlutusScripts,

) where

import Cardano.Ledger.BaseTypes (ProtVer (pvMajor), natVersion)
Expand Down Expand Up @@ -96,5 +96,4 @@ type instance EraRule "UPEC" AlonzoEra = ShelleyUPEC AlonzoEra

-- | Starting with protocol version 9, we translate the upper bound of validity
-- interval correctly for Plutus scripts.
hardforkConwayTranslateUpperBoundForPlutusScripts :: ProtVer -> Bool
hardforkConwayTranslateUpperBoundForPlutusScripts pv = pvMajor pv > natVersion @8

18 changes: 4 additions & 14 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Cardano.Ledger.Alonzo.Plutus.TxInfo (

import Cardano.Crypto.Hash.Class (hashToBytes)
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.Era (AlonzoEra, hardforkConwayTranslateUpperBoundForPlutusScripts)
import Cardano.Ledger.Alonzo.Era (AlonzoEra)
import Cardano.Ledger.Alonzo.Plutus.Context
import Cardano.Ledger.Alonzo.Scripts (AlonzoPlutusPurpose (..), PlutusScript (..), toAsItem)
import Cardano.Ledger.Alonzo.TxWits (unTxDatsL)
Expand Down Expand Up @@ -219,30 +219,20 @@ transValidityInterval ::
forall proxy era a.
Inject (AlonzoContextError era) a =>
proxy era ->
ProtVer ->
EpochInfo (Either Text) ->
SystemStart ->
ValidityInterval ->
Either a PV1.POSIXTimeRange
transValidityInterval _ protVer epochInfo systemStart = \case
transValidityInterval epochInfo systemStart = \case
ValidityInterval SNothing SNothing -> pure PV1.always
ValidityInterval (SJust i) SNothing -> PV1.from <$> transSlotToPOSIXTime i
ValidityInterval SNothing (SJust i) -> do
t <- transSlotToPOSIXTime i
pure $
if hardforkConwayTranslateUpperBoundForPlutusScripts protVer
then
PV1.Interval
(PV1.LowerBound PV1.NegInf True)
(PV1.strictUpperBound t)
else PV1.to t
pure $ PV1.to t
ValidityInterval (SJust i) (SJust j) -> do
t1 <- transSlotToPOSIXTime i
t2 <- transSlotToPOSIXTime j
pure $
PV1.Interval
(PV1.lowerBound t1)
(PV1.strictUpperBound t2)
pure $ PV1.Interval (PV1.lowerBound t1) (PV1.strictUpperBound t2)
where
transSlotToPOSIXTime =
left (inject . TimeTranslationPastHorizon @era)
Expand Down
8 changes: 5 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Cardano.Ledger.Conway.TxInfo (
ConwayEraPlutusTxInfo (..),
transTxBodyWithdrawals,
transTxCert,
-- Era-specific translation for Plutus validity interval
transValidityInterval,
transDRepCred,
transColdCommitteeCred,
transHotCommitteeCred,
Expand Down Expand Up @@ -396,7 +398,7 @@ instance EraPlutusTxInfo 'PlutusV1 ConwayEra where
toPlutusTxInfo proxy LedgerTxInfo {ltiProtVer, ltiEpochInfo, ltiSystemStart, ltiUTxO, ltiTx} = do
guardConwayFeaturesForPlutusV1V2 ltiTx
timeRange <-
Alonzo.transValidityInterval ltiTx ltiProtVer ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
transValidityInterval ltiTx ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
inputs <- mapM (transTxInInfoV1 ltiUTxO) (Set.toList (txBody ^. inputsTxBodyL))
mapM_ (transTxInInfoV1 ltiUTxO) (Set.toList (txBody ^. referenceInputsTxBodyL))
outputs <-
Expand Down Expand Up @@ -431,7 +433,7 @@ instance EraPlutusTxInfo 'PlutusV2 ConwayEra where
toPlutusTxInfo proxy LedgerTxInfo {ltiProtVer, ltiEpochInfo, ltiSystemStart, ltiUTxO, ltiTx} = do
guardConwayFeaturesForPlutusV1V2 ltiTx
timeRange <-
Alonzo.transValidityInterval ltiTx ltiProtVer ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
transValidityInterval ltiTx ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
inputs <- mapM (Babbage.transTxInInfoV2 ltiUTxO) (Set.toList (txBody ^. inputsTxBodyL))
refInputs <- mapM (Babbage.transTxInInfoV2 ltiUTxO) (Set.toList (txBody ^. referenceInputsTxBodyL))
outputs <-
Expand Down Expand Up @@ -468,7 +470,7 @@ instance EraPlutusTxInfo 'PlutusV3 ConwayEra where

toPlutusTxInfo proxy LedgerTxInfo {ltiProtVer, ltiEpochInfo, ltiSystemStart, ltiUTxO, ltiTx} = do
timeRange <-
Alonzo.transValidityInterval ltiTx ltiProtVer ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
transValidityInterval ltiTx ltiEpochInfo ltiSystemStart (txBody ^. vldtTxBodyL)
let
txInputs = txBody ^. inputsTxBodyL
refInputs = txBody ^. referenceInputsTxBodyL
Expand Down