Skip to content

Commit

Permalink
cardano-api: 8.47 -> 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Jul 10, 2024
1 parent ea35b1b commit 963fa03
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 45 deletions.
13 changes: 13 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ index-state:
, hackage.haskell.org 2024-07-09T19:07:04Z
, cardano-haskell-packages 2024-07-09T19:04:02Z

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: 516b4555c8c7b2faa821f05fdca9c9bb11a74d66
--sha256: sha256-4cPWwRAL815smViecuKZ2LAj/PSCI4ohdddFuJCiPxc=
subdir:
libs/cardano-ledger-core
eras/alonzo/impl
eras/conway/impl
eras/shelley/test-suite

allow-newer: cardano-ledger-core

packages:
cardano-api-classy
hydra-prelude
Expand Down
2 changes: 1 addition & 1 deletion cardano-api-classy/cardano-api-classy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library
-- dependencies on cardano-ledger* follow.
build-depends:
, base >=4.16
, cardano-api ^>=8.46
, cardano-api ^>=9.0
, cardano-ledger-alonzo
, cardano-ledger-conway
, cardano-ledger-core
2 changes: 1 addition & 1 deletion hydra-cardano-api/hydra-cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ library
, base >=4.16
, base16-bytestring
, bytestring
, cardano-api ^>=8.46
, cardano-api ^>=9.0
, cardano-api-classy
, cardano-binary
, cardano-crypto-class
Expand Down
6 changes: 6 additions & 0 deletions hydra-cardano-api/src/Hydra/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ pattern TxBodyContent ::
TxScriptValidity ->
Maybe (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era)) ->
Maybe (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era)) ->
Maybe (Featured ConwayEraOnwards Era Coin) ->
Maybe (Featured ConwayEraOnwards Era Coin) ->
TxBodyContent buidl
pattern TxBodyContent
{ txIns
Expand All @@ -425,6 +427,8 @@ pattern TxBodyContent
, txScriptValidity
, txProposalProcedures
, txVotingProcedures
, txCurrentTreasuryValue
, txTreasuryDonation
} <-
Cardano.Api.TxBodyContent
txIns
Expand All @@ -447,6 +451,8 @@ pattern TxBodyContent
txScriptValidity
txProposalProcedures
txVotingProcedures
txCurrentTreasuryValue
txTreasuryDonation
where
TxBodyContent = Cardano.Api.TxBodyContent

Expand Down
2 changes: 1 addition & 1 deletion hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ library
, ouroboros-consensus-cardano
, ouroboros-network-api ^>=0.7.1
, ouroboros-network-framework
, ouroboros-network-protocols ^>=0.8
, ouroboros-network-protocols ^>=0.9
, plutus-core >=1.21
, plutus-ledger-api >=1.21
, prometheus
Expand Down
4 changes: 3 additions & 1 deletion hydra-node/src/Hydra/Chain/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ buildTransaction networkId socket changeAddress utxoToSpend collateral outs = do
TxScriptValidityNone
Nothing
Nothing
Nothing
Nothing

-- | Submit a (signed) transaction to the node.
--
Expand Down Expand Up @@ -416,7 +418,7 @@ queryInShelleyBasedEraExpr sbe query =
-- | Throws at least 'QueryException' if query fails.
runQuery :: NetworkId -> SocketPath -> QueryPoint -> QueryInMode a -> IO a
runQuery networkId socket point query =
queryNodeLocalState (localNodeConnectInfo networkId socket) queryTarget query >>= \case
runExceptT (queryNodeLocalState (localNodeConnectInfo networkId socket) queryTarget query) >>= \case
Left err -> throwIO $ QueryAcquireException err
Right result -> pure result
where
Expand Down
11 changes: 6 additions & 5 deletions hydra-node/src/Hydra/Chain/Direct/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Cardano.Ledger.Alonzo.TxWits (
txscripts,
)
import Cardano.Ledger.Api (
BabbageEra,
TransactionScriptFailure,
bodyTxL,
collateralInputsTxBodyL,
Expand Down Expand Up @@ -420,12 +421,12 @@ estimateScriptsCost ::
Babbage.AlonzoTx LedgerEra ->
Either ErrCoverFee (Map (PlutusPurpose AsIx LedgerEra) ExUnits)
estimateScriptsCost pparams systemStart epochInfo utxo tx = do
case result of
Left translationError ->
Left $ ErrTranslationError translationError
Right units ->
Map.traverseWithKey (\ptr -> left $ ErrScriptExecutionFailed . (ptr,)) units
Map.traverseWithKey (\ptr -> left $ ErrScriptExecutionFailed . (ptr,)) result
where
result ::
Map
(AlonzoPlutusPurpose AsIx LedgerEra)
(Either (TransactionScriptFailure (BabbageEra StandardCrypto)) ExUnits)
result =
evalTxExUnits
pparams
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/src/Hydra/Ledger/Cardano/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ emptyTxBody =
TxScriptValidityNone
Nothing
Nothing
Nothing
Nothing

-- | Add new inputs to an ongoing builder.
addInputs :: TxIns BuildTx -> TxBodyContent BuildTx -> TxBodyContent BuildTx
Expand Down
40 changes: 26 additions & 14 deletions hydra-node/src/Hydra/Ledger/Cardano/Evaluate.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# HLINT ignore "Use <$>" #-}

-- | Simplified interface to phase-2 validation of transactions, eg. evaluation
-- of Plutus scripts.
--
Expand All @@ -17,10 +21,9 @@ import Cardano.Ledger.Alonzo.Plutus.Evaluate (collectPlutusScriptsWithContext)
import Cardano.Ledger.Alonzo.Scripts (CostModel, Prices (..), mkCostModel, mkCostModels, txscriptfee)
import Cardano.Ledger.Api (CoinPerByte (..), ppCoinsPerUTxOByteL, ppCostModelsL, ppMaxBlockExUnitsL, ppMaxTxExUnitsL, ppMaxValSizeL, ppMinFeeAL, ppMinFeeBL, ppPricesL, ppProtocolVersionL)
import Cardano.Ledger.BaseTypes (BoundedRational (boundRational), ProtVer (..), natVersion)
import Cardano.Ledger.Binary (getVersion)
import Cardano.Ledger.Coin (Coin (Coin))
import Cardano.Ledger.Core (PParams, ppMaxTxSizeL)
import Cardano.Ledger.Plutus (PlutusDatums (unPlutusDatums), PlutusLanguage (decodePlutusRunnable), PlutusRunnable (..), PlutusWithContext (..))
import Cardano.Ledger.Plutus (PlutusLanguage (decodePlutusRunnable, mkTermToEvaluate), PlutusWithContext (..))
import Cardano.Ledger.Plutus.Language (Language (PlutusV2))
import Cardano.Ledger.Val (Val ((<+>)), (<×>))
import Cardano.Slotting.EpochInfo (EpochInfo, fixedEpochInfo)
Expand Down Expand Up @@ -75,8 +78,6 @@ import Ouroboros.Consensus.HardFork.History (
mkInterpreter,
)
import PlutusCore qualified as PLC
import PlutusLedgerApi.Common (mkTermToEvaluate)
import PlutusLedgerApi.Common qualified as Plutus
import Test.QuickCheck (Property, choose, counterexample, property)
import Test.QuickCheck.Gen (chooseWord64)
import UntypedPlutusCore (UnrestrictedProgram (..))
Expand Down Expand Up @@ -112,14 +113,26 @@ evaluateTx' maxUnits tx utxo = do
| all isRight report -> checkBudget maxUnits report
| otherwise -> Right report
where
result ::
LedgerProtocolParameters UTxO.Era ->
Either
(TransactionValidityError UTxO.Era)
( Map
ScriptWitnessIndex
( Either
ScriptExecutionError
ExecutionUnits
)
)
result pparams' =
evaluateTransactionExecutionUnits
cardanoEra
systemStart
(LedgerEpochInfo epochInfo)
pparams'
(UTxO.toApi utxo)
(getTxBody tx)
(fmap . fmap . fmap) snd $
evaluateTransactionExecutionUnits
cardanoEra
systemStart
(LedgerEpochInfo epochInfo)
pparams'
(UTxO.toApi utxo)
(getTxBody tx)

-- | Check the budget used by provided 'EvaluationReport' does not exceed given
-- maximum 'ExecutionUnits'.
Expand Down Expand Up @@ -220,12 +233,11 @@ prepareTxScripts tx utxo = do

-- Fully applied UPLC programs which we could run using the cekMachine
programs <- forM results $ \(PlutusWithContext protocolVersion script _ arguments _exUnits _costModel) -> do
(PlutusRunnable x) <-
x <-
case script of
Right runnable -> pure runnable
Left serialised -> left show $ decodePlutusRunnable protocolVersion serialised
let majorProtocolVersion = Plutus.MajorProtocolVersion $ getVersion protocolVersion
appliedTerm <- left show $ mkTermToEvaluate Plutus.PlutusV2 majorProtocolVersion x (unPlutusDatums arguments)
appliedTerm <- left show $ mkTermToEvaluate protocolVersion x arguments
pure $ UPLC.Program () PLC.latestVersion appliedTerm

pure $ flat . UnrestrictedProgram <$> programs
Expand Down
4 changes: 1 addition & 3 deletions hydra-node/test/Hydra/API/HTTPServerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import Data.Aeson.Lens (key, nth)
import Hydra.API.HTTPServer (DraftCommitTxRequest (..), DraftCommitTxResponse (..), SubmitTxRequest (..), TransactionSubmitted, httpApp)
import Hydra.API.ServerSpec (dummyChainHandle)
import Hydra.Cardano.Api (
fromLedgerPParams,
serialiseToTextEnvelope,
shelleyBasedEra,
)
import Hydra.Chain (Chain (draftCommitTx), PostTxError (..))
import Hydra.Chain.Direct.Fixture (defaultPParams)
Expand Down Expand Up @@ -103,7 +101,7 @@ apiServerSpec = do
it "responds given parameters" $
get "/protocol-parameters"
`shouldRespondWith` 200
{ matchBody = matchJSON $ fromLedgerPParams shelleyBasedEra defaultPParams
{ matchBody = matchJSON defaultPParams
}

describe "GET /snapshot/utxo" $ do
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Ledger/CardanoSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ roundtripProtocolParameters pparams = do
(expected === actual)
& counterexample ("ledger: " <> show pparams)
where
expected = fromLedgerPParams shelleyBasedEra pparams
expected = pparams

roundtripTxId :: Tx -> Property
roundtripTxId tx@(Tx body _) =
Expand Down
6 changes: 3 additions & 3 deletions hydra-plutus-extras/src/Hydra/Plutus/Extras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import Cardano.Api.Shelley (PlutusScript (PlutusScriptSerialised))
import PlutusLedgerApi.Common (SerialisedScript)
import PlutusLedgerApi.V2 (ScriptHash (..))
import PlutusTx (BuiltinData, UnsafeFromData (..))
import PlutusTx.Prelude (check, toBuiltin)
import PlutusTx.Prelude (BuiltinUnit, check, toBuiltin)

-- * Vendored from plutus-ledger

-- | Signature of an untyped validator script.
type ValidatorType = BuiltinData -> BuiltinData -> BuiltinData -> ()
type ValidatorType = BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit

-- | Wrap a typed validator to get the basic `ValidatorType` signature which can
-- be passed to `PlutusTx.compile`.
Expand All @@ -42,7 +42,7 @@ wrapValidator f d r c =
{-# INLINEABLE wrapValidator #-}

-- | Signature of an untyped minting policy script.
type MintingPolicyType = BuiltinData -> BuiltinData -> ()
type MintingPolicyType = BuiltinData -> BuiltinData -> BuiltinUnit

-- | Wrap a typed minting policy to get the basic `MintingPolicyType` signature
-- which can be passed to `PlutusTx.compile`.
Expand Down
4 changes: 2 additions & 2 deletions hydra-plutus/scripts/mHead.plutus

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hydra-plutus/scripts/vCommit.plutus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "PlutusScriptV2",
"description": "hydra-vCommit-0.17.0-46-gf2ef4c745",
"cborHex": "59080a5908070100003232323322323322323232322225335332235300600522253232335007133002490103433031003233017225335001101522135002223253353335734002036034260280042600e00866e3c008028004d4c0040188888888888880204cc0092401034330320033016225335001101422135002223253353335734002034032260280042600e00866e3c008024d54cd4d4c0040188888888888880284c0512401035054380022100222220032350012200222533500110131335738004024646464a66a64666ae6800404003ccdc3a400000422440022a66a64666ae6800404003ccdc3a40040042244004260209201035054310035573c0046aae74004dd500119191919299a999ab9a00101000f1323233221233001003002323232325335333573400202c02a2646464646464646464646646666666466646664444444444442466666666666600201a01801601401201000e00c00a0080060046603c464646464a66a666ae680040a009c4cc8848cc00400c008c098d5d080118031aba1357440042605292103505431003370e90000011aab9e00235573a0026ea8004d5d08079aba100d3301e00135742018464646464a66a666ae6800409c0984c8c8c8cccc888848cccc00401401000c008c8c8c8c94cd4ccd5cd000817016899910919800801801180f1aba10023300501d357426ae880084c0bd240103505431003370e90000011aab9e00235573a0026ea8d5d080298049aba1003323232325335333573400205c05a22444006264a66a666ae680040bc0b84c84888c004010dd71aba10031325335333573400206005e264244460040086ae840104c0c524103505431003370e900200219b874800800ccdc3a40000046aae78008d55ce8009baa3574200466002eb8d5d09aba200222323232325335333573400205e05c2244002264a66a666ae680040c00bc4c8488c00800cc01cd5d080189818a4903505431003370e900000199b8748008008d55cf0011aab9d00137540026ae88004d5d10010981424903505431003370e90000011aab9e00235573a0026ea8004c004d5d080518009aba10093001300175a6ae8401cd5d08031aba10053301c75c6ae84010d5d08019980090009aba10022322300237560026048446666aae7c00480848c8cd4084cc8848cc00400c008dd71aab9d001300535573c00260086ae8800cd5d08010129aba1357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10010980ba4903505431003370e90000011aab9e00235573a0026ea8d5d080219191919299a999ab9a001016015132122223003005375c6ae840084c94cd4ccd5cd00080b80b099091111800802980a9aba10031325335333573400203002e26424444600400a600e6ae840104c94cd4ccd5cd00080c80c09909111180200299191919299a999ab9a00101d01c132122222223005008300c35742004264a66a666ae680040780744c848888888c01c020c034d5d0801899299a999ab9a00101f01e133221222222233006009008300e357420086eb8d5d09aba20041325335333573400204003e2664424444444660040120106eb8d5d08029bae357426ae880144c94cd4ccd5cd0008108100999109111111198008048041bae3574200c6eb4d5d09aba200613253353335734002044042224444444008264a66a666ae6800408c08844888888800c4c09124103505431003370e900600419b874802801ccdc3a401000c66e1d20060053370e900200219b874800800ccdc3a40000046aae78008d55ce8009baa3574200a26034920103505431003370e900300299b8748010010cdc3a400400666e1d200000235573c0046aae74004dd51aba135744008464646464a66a666ae680040580544c8488c00800cc018d5d0801099299a999ab9a001017016132333222122333001005004003375a6ae84010dd69aba1001375a6ae84d5d10009aba200313018490103505431003370e900100199b8748000008d55cf0011aab9d0013754002464646464a66a666ae680040540504c8488c00800cdd71aba10021325335333573400202c02a26424460020066eb8d5d08018980ba48103505431003370e900100199b8748000008d55cf0011aab9d001375400226022920103505431003370e90000011aab9e00235573a0026ea800440384c03524010350543500322323232325335333573400201c01a264666444246660020080060046eb8d5d080198039aba1001375c6ae84d5d10009aba20021300f49103505431003370e90000011aab9e00235573a0026ea8004c00c8c8c8c94cd4c8ccd5cd00080680619b87480000084cc8848cc00400c008c028d5d08009bae357426ae880044c035241035054310035573c0046aae74004dd5000980511299a80088041109a8011119299a999ab9a00100e00d132333573400201e01c66e1c008cdc0a400090010980380219b8f0024890b487964726148656164563100300922533500110072213500222325335333573400201a018264666ae68004038034cdc3801240042600e00866e3c00922010b4879647261486561645631002322300237580026012446666aae7c00480188cd4014c010d5d080118019aba200200a122002122122330010040032323232325335333573400200e00c26644246600200600464646464a66a666ae6800402c0284dd71aba10021300c49103505431003370e90000011aab9e00235573a0026ea8d5d08011bad357426ae880084c02124103505431003370e90000011aab9e00235573a0026ea80044880084880048c98cd5ce0008010900091918008009119801980100100081"
"description": "hydra-vCommit-0.17.0-47-gea35b1b12",
"cborHex": "5908095908060100003232323322323322323232322225335332235300600522253232335007133002490103433031003233017225335001101522135002223253353335734002036034260280042600e00866e3c008028004d4c0040188888888888880204cc0092401034330320033016225335001101422135002223253353335734002034032260280042600e00866e3c008024d54cd4d4c0040188888888888880284c0512401035054380022100222220032350012200222533500110131335738004024646464a66a64666ae6800404003ccdc3a400000422440022a66a64666ae6800404003ccdc3a40040042244004260209201035054310035573c0046aae74004dd500119191919299a999ab9a00101000f1323233221233001003002323232325335333573400202c02a2646464646464646464646646666666466646664444444444442466666666666600201a01801601401201000e00c00a0080060046603c464646464a66a666ae680040a009c4cc8848cc00400c008c098d5d080118031aba1357440042605292103505431003370e90000011aab9e00235573a0026ea8004d5d08079aba100d3301e00135742018464646464a66a666ae6800409c0984c8c8c8cccc888848cccc00401401000c008c8c8c8c94cd4ccd5cd000817016899910919800801801180f1aba10023300501d357426ae880084c0bd240103505431003370e90000011aab9e00235573a0026ea8d5d080298049aba1003323232325335333573400205c05a22444006264a66a666ae680040bc0b84c84888c004010dd71aba10031325335333573400206005e264244460040086ae840104c0c524103505431003370e900200219b874800800ccdc3a40000046aae78008d55ce8009baa3574200466002eb8d5d09aba200222323232325335333573400205e05c2244002264a66a666ae680040c00bc4c8488c00800cc01cd5d080189818a4903505431003370e900000199b8748008008d55cf0011aab9d00137540026ae88004d5d10010981424903505431003370e90000011aab9e00235573a0026ea8004c004d5d080518009aba10093001300175a6ae8401cd5d08031aba10053301c75c6ae84010d5d08019980090009aba10022322300237560026048446666aae7c00480848c8cd4084cc8848cc00400c008dd71aab9d001300535573c00260086ae8800cd5d08010129aba1357440026ae88004d5d10009aba2001357440026ae88004d5d10009aba2001357440026ae88004d5d10010980ba4903505431003370e90000011aab9e00235573a0026ea8d5d080219191919299a999ab9a001016015132122223003005375c6ae840084c94cd4ccd5cd00080b80b099091111800802980a9aba10031325335333573400203002e26424444600400a600e6ae840104c94cd4ccd5cd00080c80c09909111180200299191919299a999ab9a00101d01c132122222223005008300c35742004264a66a666ae680040780744c848888888c01c020c034d5d0801899299a999ab9a00101f01e133221222222233006009008300e357420086eb8d5d09aba20041325335333573400204003e2664424444444660040120106eb8d5d08029bae357426ae880144c94cd4ccd5cd0008108100999109111111198008048041bae3574200c6eb4d5d09aba200613253353335734002044042224444444008264a66a666ae6800408c08844888888800c4c09124103505431003370e900600419b874802801ccdc3a401000c66e1d20060053370e900200219b874800800ccdc3a40000046aae78008d55ce8009baa3574200a26034920103505431003370e900300299b8748010010cdc3a400400666e1d200000235573c0046aae74004dd51aba135744008464646464a66a666ae680040580544c8488c00800cc018d5d0801099299a999ab9a001017016132333222122333001005004003375a6ae84010dd69aba1001375a6ae84d5d10009aba200313018490103505431003370e900100199b8748000008d55cf0011aab9d0013754002464646464a66a666ae680040540504c8488c00800cdd71aba10021325335333573400202c02a26424460020066eb8d5d08018980ba48103505431003370e900100199b8748000008d55cf0011aab9d001375400226022920103505431003370e90000011aab9e00235573a0026ea80045261300d4910350543500322323232325335333573400201c01a264666444246660020080060046eb8d5d080198039aba1001375c6ae84d5d10009aba20021300f49103505431003370e90000011aab9e00235573a0026ea8004c00c8c8c8c94cd4c8ccd5cd00080680619b87480000084cc8848cc00400c008c028d5d08009bae357426ae880044c035241035054310035573c0046aae74004dd5000980511299a80088041109a8011119299a999ab9a00100e00d132333573400201e01c66e1c008cdc0a400090010980380219b8f0024890b487964726148656164563100300922533500110072213500222325335333573400201a018264666ae68004038034cdc3801240042600e00866e3c00922010b4879647261486561645631002322300237580026012446666aae7c00480188cd4014c010d5d080118019aba200200a122002122122330010040032323232325335333573400200e00c26644246600200600464646464a66a666ae6800402c0284dd71aba10021300c49103505431003370e90000011aab9e00235573a0026ea8d5d08011bad357426ae880084c02124103505431003370e90000011aab9e00235573a0026ea80044880084880048c98cd5ce0008010900091918008009180111980100100081"
}
4 changes: 2 additions & 2 deletions hydra-plutus/scripts/vHead.plutus

Large diffs are not rendered by default.

Loading

0 comments on commit 963fa03

Please sign in to comment.