Skip to content
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

Use plutus-ledger-api 1.22.1 #4117

Merged
merged 1 commit into from
Feb 26, 2024
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
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2024-01-04T21:59:02Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2024-02-15T21:00:00Z
, cardano-haskell-packages 2024-02-26T13:00:00Z

packages:
eras/allegra/impl
Expand Down
2 changes: 1 addition & 1 deletion eras/alonzo/impl/cardano-ledger-alonzo.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ library
mtl,
microlens,
nothunks,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
set-algebra >=1.0,
small-steps >=1.0,
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ transTxOut txOut = do
address <- transAddr (txOut ^. addrTxOutL)
pure $ PV1.TxOut address (transValue val) (transDataHash <$> strictMaybeToMaybe dataHash)

-- | Translate all `Withdrawal`s from within a `TxBody`
transTxBodyId :: EraTxBody era => TxBody era -> PV1.TxId
transTxBodyId txBody = PV1.TxId (transSafeHash (hashAnnotated txBody))

Expand Down
2 changes: 1 addition & 1 deletion eras/alonzo/test-suite/cardano-ledger-alonzo-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ library
containers,
data-default-class,
microlens,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
QuickCheck,
random,
serialise,
Expand Down
Binary file modified eras/alonzo/test-suite/golden/translations.cbor
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ instance Cborg.Serialise PV1.TxInInfo
instance Cborg.Serialise PV1.TxInfo
instance Cborg.Serialise PV1.TxOut
instance Cborg.Serialise PV2.ScriptPurpose
instance Cborg.Serialise PV2.TxId
instance Cborg.Serialise PV2.TxOutRef
instance Cborg.Serialise PV2.TxInInfo
lehins marked this conversation as resolved.
Show resolved Hide resolved
instance Cborg.Serialise PV2.TxInfo
instance Cborg.Serialise PV3.Address
instance Cborg.Serialise PV3.BuiltinData
Expand Down
2 changes: 1 addition & 1 deletion eras/babbage/impl/cardano-ledger-babbage.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ library
deepseq,
microlens,
nothunks,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
set-algebra,
small-steps,
text,
Expand Down
Binary file modified eras/babbage/test-suite/golden/translations.cbor
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ expectOneInput i slang txInfo =
case slang of
SPlutusV1 -> False
SPlutusV2 -> PV2.txInfoInputs txInfo == [i]
SPlutusV3 -> PV3.txInfoInputs txInfo == [i]
SPlutusV3 -> False

expectOneOutput :: PV2.TxOut -> SLanguage l -> PlutusTxInfo l -> Bool
expectOneOutput o slang txInfo =
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ library
deepseq,
microlens,
nothunks,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
set-algebra,
small-steps,
text,
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/cddl-files/conway.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ potential_languages = 0 .. 255
costmdls =
{ ? 0 : [ 166* int ] ; Plutus v1, only 166 integers are used, but more are accepted (and ignored)
, ? 1 : [ 175* int ] ; Plutus v2, only 175 integers are used, but more are accepted (and ignored)
, ? 2 : [ 223* int ] ; Plutus v3, only 223 integers are used, but more are accepted (and ignored)
, ? 2 : [ 233* int ] ; Plutus v3, only 233 integers are used, but more are accepted (and ignored)
, ? 3 : [ int ] ; Any 8-bit unsigned number can be used as a key.
}

Expand Down
42 changes: 34 additions & 8 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Cardano.Ledger.Alonzo.Plutus.Context (
import Cardano.Ledger.Alonzo.Plutus.TxInfo (AlonzoContextError (..), TxOutSource (..))
import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as Alonzo
import Cardano.Ledger.Alonzo.Scripts (AlonzoPlutusPurpose (..), toAsItem)
import Cardano.Ledger.Babbage.TxInfo (BabbageContextError (..))
import Cardano.Ledger.Babbage.TxInfo (BabbageContextError (..), transTxOutV2)
import qualified Cardano.Ledger.Babbage.TxInfo as Babbage
import Cardano.Ledger.BaseTypes (
Inject (..),
Expand All @@ -49,6 +49,7 @@ import Cardano.Ledger.BaseTypes (
isSJust,
kindObject,
strictMaybe,
txIxToInt,
)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders (
Expand Down Expand Up @@ -98,12 +99,13 @@ import Cardano.Ledger.Plutus.TxInfo (
transEpochNo,
transKeyHash,
transRewardAccount,
transSafeHash,
transScriptHash,
transTxId,
transTxIn,
)
import qualified Cardano.Ledger.Plutus.TxInfo as TxInfo
import Cardano.Ledger.PoolParams
import Cardano.Ledger.TxIn (TxIn)
import Cardano.Ledger.SafeHash (hashAnnotated)
import Cardano.Ledger.TxIn (TxId (..), TxIn (..))
import Cardano.Ledger.UTxO (UTxO)
import Control.Arrow (ArrowChoice (..))
import Control.DeepSeq (NFData)
Expand Down Expand Up @@ -237,7 +239,22 @@ transTxInInfoV1 ::
transTxInInfoV1 utxo txIn = do
txOut <- left (inject . AlonzoContextError @era) $ Alonzo.transLookupTxOut utxo txIn
plutusTxOut <- transTxOutV1 (TxOutFromInput txIn) txOut
Right (PV1.TxInInfo (transTxIn txIn) plutusTxOut)
Right (PV1.TxInInfo (TxInfo.transTxIn txIn) plutusTxOut)

-- | Given a TxIn, look it up in the UTxO. If it exists, translate it to the V3 context
transTxInInfoV3 ::
forall era.
( Inject (BabbageContextError era) (ContextError era)
, Value era ~ MaryValue (EraCrypto era)
, BabbageEraTxOut era
) =>
UTxO era ->
TxIn (EraCrypto era) ->
Either (ContextError era) PV3.TxInInfo
transTxInInfoV3 utxo txIn = do
txOut <- left (inject . AlonzoContextError @era) $ Alonzo.transLookupTxOut utxo txIn
plutusTxOut <- transTxOutV2 (TxOutFromInput txIn) txOut
Right (PV3.TxInInfo (transTxIn txIn) plutusTxOut)

instance Crypto c => EraPlutusTxInfo 'PlutusV1 (ConwayEra c) where
toPlutusTxCert _ = transTxCertV1V2
Expand Down Expand Up @@ -317,8 +334,8 @@ instance Crypto c => EraPlutusTxInfo 'PlutusV3 (ConwayEra c) where

toPlutusTxInfo proxy pp epochInfo systemStart utxo tx = do
timeRange <- Alonzo.transValidityInterval pp epochInfo systemStart (txBody ^. vldtTxBodyL)
inputs <- mapM (Babbage.transTxInInfoV2 utxo) (Set.toList (txBody ^. inputsTxBodyL))
refInputs <- mapM (Babbage.transTxInInfoV2 utxo) (Set.toList (txBody ^. referenceInputsTxBodyL))
inputs <- mapM (transTxInInfoV3 utxo) (Set.toList (txBody ^. inputsTxBodyL))
refInputs <- mapM (transTxInInfoV3 utxo) (Set.toList (txBody ^. referenceInputsTxBodyL))
outputs <-
zipWithM
(Babbage.transTxOutV2 . TxOutFromOutput)
Expand All @@ -339,7 +356,7 @@ instance Crypto c => EraPlutusTxInfo 'PlutusV3 (ConwayEra c) where
, PV3.txInfoSignatories = Alonzo.transTxBodyReqSignerHashes txBody
, PV3.txInfoRedeemers = plutusRedeemers
, PV3.txInfoData = PV3.fromList $ Alonzo.transTxWitsDatums (tx ^. witsTxL)
, PV3.txInfoId = Alonzo.transTxBodyId txBody
, PV3.txInfoId = transTxBodyId txBody
, PV3.txInfoVotes = transVotingProcedures (txBody ^. votingProceduresTxBodyL)
, PV3.txInfoProposalProcedures =
map (transProposal proxy) $ toList (txBody ^. proposalProceduresTxBodyL)
Expand All @@ -356,6 +373,15 @@ instance Crypto c => EraPlutusTxInfo 'PlutusV3 (ConwayEra c) where
toPlutusScriptContext proxy txInfo scriptPurpose =
PV3.ScriptContext txInfo <$> toPlutusScriptPurpose proxy scriptPurpose

transTxId :: TxId c -> PV3.TxId
transTxId txId = PV3.TxId (transSafeHash (unTxId txId))

transTxBodyId :: EraTxBody era => TxBody era -> PV3.TxId
transTxBodyId txBody = PV3.TxId (transSafeHash (hashAnnotated txBody))

transTxIn :: TxIn c -> PV3.TxOutRef
transTxIn (TxIn txid txIx) = PV3.TxOutRef (transTxId txid) (toInteger (txIxToInt txIx))

-- | Translate all `Withdrawal`s from within a `TxBody`
transTxBodyWithdrawals :: EraTxBody era => TxBody era -> PV3.Map PV3.Credential PV3.Lovelace
transTxBodyWithdrawals txBody =
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/cardano-ledger-binary/cardano-ledger-binary.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ library
network,
nothunks,
primitive,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
recursion-schemes,
serialise,
tagged,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ decodeCostModels =
costModelParamsCount :: Language -> Int
costModelParamsCount PlutusV1 = 166
costModelParamsCount PlutusV2 = 175
costModelParamsCount PlutusV3 = 223
costModelParamsCount PlutusV3 = 233

-- | Prior to version 9, each 'CostModel' was expected to be serialized as
-- an array of integers of a specific length (depending on the version of Plutus).
Expand Down
2 changes: 1 addition & 1 deletion libs/cardano-ledger-test/cardano-ledger-test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ library
mtl,
nothunks,
hspec,
plutus-ledger-api ^>=1.21,
plutus-ledger-api ^>=1.22.1,
prettyprinter,
QuickCheck,
small-steps,
Expand Down
Loading