Skip to content

Commit

Permalink
cardano-api: 8.48 -> 9.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Jul 11, 2024
1 parent ef2abfa commit 277b8b6
Show file tree
Hide file tree
Showing 7 changed files with 11,869 additions and 15,095 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.48
, 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.48
, cardano-api ^>=9.0
, cardano-api-classy
, cardano-binary
, cardano-crypto-class
Expand Down
26,894 changes: 11,821 additions & 15,073 deletions hydra-node/golden/ReasonablySized (TimedServerOutput (Tx BabbageEra)).json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Chain/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,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
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

0 comments on commit 277b8b6

Please sign in to comment.