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

cardano-api: 8.46 -> 8.47 #1499

Closed
wants to merge 2 commits into from
Closed
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 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 ^>=8.48
, 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 ^>=8.48
, 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
1 change: 1 addition & 0 deletions hydra-cluster/hydra-cluster.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ library
, async
, base >=4.7 && <5
, bytestring
, cardano-api
, cardano-slotting
, containers
, contra-tracer
Expand Down
5 changes: 3 additions & 2 deletions hydra-cluster/src/Hydra/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Hydra.Generator where
import Hydra.Cardano.Api
import Hydra.Prelude hiding (size)

import Cardano.Api.Ledger (PParams)
import Cardano.Api.UTxO qualified as UTxO
import CardanoClient (mkGenesisTx)
import Control.Monad (foldM)
Expand Down Expand Up @@ -72,8 +73,8 @@ data ClientDataset = ClientDataset
deriving stock (Show, Generic)
deriving anyclass (ToJSON, FromJSON)

defaultProtocolParameters :: ProtocolParameters
defaultProtocolParameters = fromLedgerPParams ShelleyBasedEraShelley def
defaultProtocolParameters :: PParams LedgerEra
defaultProtocolParameters = def

-- | Generate 'Dataset' which does not grow the per-client UTXO set over time.
-- The sequence of transactions generated consist only of simple payments from
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ library
, optparse-applicative
, ouroboros-consensus
, ouroboros-consensus-cardano
, ouroboros-network-api ^>=0.7.1
, ouroboros-network-api >=0.7.1
, ouroboros-network-framework
, ouroboros-network-protocols ^>=0.8
, ouroboros-network-protocols >=0.8
, plutus-core >=1.21
, plutus-ledger-api >=1.21
, prometheus
Expand Down
5 changes: 1 addition & 4 deletions hydra-node/src/Hydra/API/HTTPServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import Hydra.API.APIServerLog (APIServerLog (..), Method (..), PathInfo (..))
import Hydra.Cardano.Api (
LedgerEra,
Tx,
fromLedgerPParams,
shelleyBasedEra,
)
import Hydra.Chain (Chain (..), CommitBlueprintTx (..), IsChainState, PostTxError (..), draftCommitTx)
import Hydra.Chain.Direct.State ()
Expand Down Expand Up @@ -148,8 +146,7 @@ httpApp tracer directChain pparams getInitializingHeadId getConfirmedUTxO reques
>>= handleDraftCommitUtxo directChain getInitializingHeadId
>>= respond
("GET", ["protocol-parameters"]) ->
respond . responseLBS status200 [] . Aeson.encode $
fromLedgerPParams shelleyBasedEra pparams
respond . responseLBS status200 [] . Aeson.encode $ pparams
("POST", ["cardano-transaction"]) ->
consumeRequestBodyStrict request
>>= handleSubmitUserTx directChain
Expand Down
2 changes: 2 additions & 0 deletions 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
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
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
30 changes: 23 additions & 7 deletions hydra-test-utils/src/Test/Plutus/Validator.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

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

-- | A helper module mostly wrapping the Alonzo.Tools'
-- 'evaluateTransactionExecutionUnits' with a much simpler API (just a plutus
-- script).
Expand Down Expand Up @@ -56,6 +60,7 @@ import Hydra.Cardano.Api (
pattern TxInsCollateral,
pattern TxOut,
)
import Hydra.Cardano.Api.Prelude (ScriptExecutionError, ScriptWitnessIndex, TransactionValidityError)
import PlutusLedgerApi.Common (SerialisedScript)
import PlutusTx qualified as Plutus
import Prelude qualified
Expand All @@ -76,14 +81,25 @@ evaluateScriptExecutionUnits validatorScript redeemer =
Left e ->
Left ("unexpected failure: " <> show e)
where
result ::
Either
(TransactionValidityError UTxO.Era)
( Map
ScriptWitnessIndex
( Either
ScriptExecutionError
ExecutionUnits
)
)
result =
evaluateTransactionExecutionUnits
cardanoEra
systemStart
(LedgerEpochInfo epochInfo)
(LedgerProtocolParameters pparams)
(UTxO.toApi utxo)
body
(fmap . fmap . fmap) snd $
evaluateTransactionExecutionUnits
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this needed changing and the other calls to evaluateTransactionExecutionUnits not?

(fmap . fmap . fmap) snd $ could be anything and this is hard to read (judging from a github diff I'm looking at now). What is happening here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature changed and we discard the new information. https://github.com/IntersectMBO/cardano-api/pull/555/files

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, having logs sounds useful 😊

cardanoEra
systemStart
(LedgerEpochInfo epochInfo)
(LedgerProtocolParameters pparams)
(UTxO.toApi utxo)
body

(body, utxo) = transactionBodyFromScript validatorScript redeemer

Expand Down
Loading