From 26e1b3015592fc43551bc7ce11d053bf961ffc62 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Fri, 3 Jun 2022 19:16:50 +0200 Subject: [PATCH] Update call sites of queryXXX functions in hydra-cluster Following the previous commit we need to specify now explicitly that we are interested in querying the latest point / tip. --- hydra-cluster/src/CardanoClient.hs | 20 ++++++++++---------- hydra-cluster/src/CardanoCluster.hs | 3 ++- hydra-cluster/test/Test/DirectChainSpec.hs | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hydra-cluster/src/CardanoClient.hs b/hydra-cluster/src/CardanoClient.hs index 5398f099f6e..cfa1a96f6c2 100644 --- a/hydra-cluster/src/CardanoClient.hs +++ b/hydra-cluster/src/CardanoClient.hs @@ -31,8 +31,8 @@ buildScriptAddress script networkId = let hashed = hashScript script in makeShelleyAddress networkId (PaymentCredentialByScript hashed) NoStakeAddress -queryStakePools :: NetworkId -> FilePath -> IO (Set PoolId) -queryStakePools networkId socket = +queryStakePools :: NetworkId -> FilePath -> QueryPoint -> IO (Set PoolId) +queryStakePools networkId socket queryPoint = let query = QueryInEra AlonzoEraInCardanoMode @@ -40,7 +40,7 @@ queryStakePools networkId socket = ShelleyBasedEraAlonzo QueryStakePools ) - in runQuery networkId socket query + in runQuery networkId socket queryPoint query >>= throwOnEraMismatch -- | Build a "raw" transaction from a bunch of inputs, outputs and fees. buildRaw :: [TxIn] -> [TxOut CtxTx] -> Lovelace -> Either TxBodyError TxBody @@ -74,11 +74,11 @@ build :: [TxOut CtxTx] -> IO (Either TxBodyErrorAutoBalance TxBody) build networkId socket changeAddress ins collateral outs = do - pparams <- queryProtocolParameters networkId socket - systemStart <- querySystemStart networkId socket - eraHistory <- queryEraHistory networkId socket - stakePools <- queryStakePools networkId socket - utxo <- queryUTxOByTxIn networkId socket (map fst ins) + pparams <- queryProtocolParameters networkId socket QueryTip + systemStart <- querySystemStart networkId socket QueryTip + eraHistory <- queryEraHistory networkId socket QueryTip + stakePools <- queryStakePools networkId socket QueryTip + utxo <- queryUTxOByTxIn networkId socket QueryTip (map fst ins) pure $ second balancedTxBody $ makeTransactionBodyAutoBalance @@ -186,7 +186,7 @@ waitForPayment networkId socket amount addr = go where go = do - utxo <- queryUTxO networkId socket [addr] + utxo <- queryUTxO networkId socket QueryTip [addr] let expectedPayment = selectPayment utxo if expectedPayment /= mempty then pure $ UTxO expectedPayment @@ -225,7 +225,7 @@ waitForTransaction networkId socket tx = where ins = Map.keys (UTxO.toMap $ utxoFromTx tx) go = do - utxo <- queryUTxOByTxIn networkId socket ins + utxo <- queryUTxOByTxIn networkId socket QueryTip ins if null utxo then go else pure utxo diff --git a/hydra-cluster/src/CardanoCluster.hs b/hydra-cluster/src/CardanoCluster.hs index 1fccfa279bb..b2c5c9aa80f 100644 --- a/hydra-cluster/src/CardanoCluster.hs +++ b/hydra-cluster/src/CardanoCluster.hs @@ -10,6 +10,7 @@ import qualified Cardano.Api.UTxO as UTxO import Cardano.Ledger.Keys (VKey (VKey)) import CardanoClient ( CardanoClientException, + QueryPoint (QueryTip), build, buildAddress, queryUTxO, @@ -168,7 +169,7 @@ seedFromFaucet networkId (RunningNode _ nodeSocket) receivingVerificationKey lov submit networkId nodeSocket (sign faucetSk body) findUTxO faucetVk = do - faucetUTxO <- queryUTxO networkId nodeSocket [buildAddress faucetVk networkId] + faucetUTxO <- queryUTxO networkId nodeSocket QueryTip [buildAddress faucetVk networkId] let foundUTxO = find (\(_i, o) -> txOutLovelace o >= lovelace) $ UTxO.pairs faucetUTxO case foundUTxO of Just o -> pure o diff --git a/hydra-cluster/test/Test/DirectChainSpec.hs b/hydra-cluster/test/Test/DirectChainSpec.hs index b2e2db0a075..26f3cb5e07b 100644 --- a/hydra-cluster/test/Test/DirectChainSpec.hs +++ b/hydra-cluster/test/Test/DirectChainSpec.hs @@ -8,6 +8,7 @@ import Hydra.Prelude import Test.Hydra.Prelude import CardanoClient ( + QueryPoint (QueryTip), buildAddress, queryTip, queryUTxO, @@ -112,7 +113,7 @@ spec = around showLogsOnFailure $ do let aliceAddress = buildAddress aliceCardanoVk defaultNetworkId -- Expect that alice got her committed value back - utxo <- queryUTxO defaultNetworkId nodeSocket [aliceAddress] + utxo <- queryUTxO defaultNetworkId nodeSocket QueryTip [aliceAddress] let aliceValues = txOutValue <$> toList utxo aliceValues `shouldContain` [lovelaceToValue aliceCommitment]