Skip to content
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 bench/plutus-scripts-bench/plutus-scripts-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ library
-- IOG dependencies
--------------------------
build-depends:
, cardano-api ^>=11.0
, cardano-api ^>=11.2
, plutus-ledger-api ^>=1.63
, plutus-tx ^>=1.63
, plutus-tx-plugin ^>=1.63
Expand Down
2 changes: 1 addition & 1 deletion bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ library
, attoparsec-aeson
, base16-bytestring
, bytestring
, cardano-api ^>= 11.0
, cardano-api ^>= 11.2
, cardano-binary
, cardano-cli ^>= 11.0
, cardano-crypto-class
Expand Down
17 changes: 17 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,20 @@ allow-newer:
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-api
tag: fb5e86c8f12f8fe94c0ab46fbaf40b9ceec0306c
--sha256: sha256-PLACEHOLDER
subdir:
cardano-api
cardano-rpc

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-cli
tag: db5a030114ea7de8db9b8c7b322b242a75678008
--sha256: sha256-PLACEHOLDER
subdir:
cardano-cli

2 changes: 1 addition & 1 deletion cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ library
, async
, base16-bytestring
, bytestring
, cardano-api ^>= 11.0
, cardano-api ^>= 11.2
, cardano-data
, cardano-crypto-class ^>=2.3
, cardano-crypto-wrapper
Expand Down
1 change: 1 addition & 0 deletions cardano-node/src/Cardano/Node/Protocol/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Cardano.Node.Protocol.Shelley

import Cardano.Api hiding (FileError)
import qualified Cardano.Api as Api
import Cardano.Api.Experimental.Certificate (OperationalCertificate (..), getHotKey)

import qualified Cardano.Crypto.Hash.Class as Crypto
import Cardano.Ledger.BaseTypes (ProtVer (..), natVersion)
Expand Down
2 changes: 1 addition & 1 deletion cardano-submit-api/cardano-submit-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ library
, aeson
, async
, bytestring
, cardano-api ^>= 11.0
, cardano-api ^>= 11.2
, cardano-binary
, cardano-cli ^>= 11.0
, cardano-crypto-class ^>=2.3
Expand Down
2 changes: 1 addition & 1 deletion cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library
, annotated-exception
, ansi-terminal
, bytestring
, cardano-api ^>= 11.0
, cardano-api ^>= 11.2
, cardano-cli:{cardano-cli, cardano-cli-test-lib} ^>= 11.0
, cardano-crypto-class ^>=2.3
, cardano-crypto-wrapper
Expand Down
1 change: 1 addition & 0 deletions cardano-testnet/src/Testnet/Process/Cli/SPO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Testnet.Process.Cli.SPO
) where

import Cardano.Api hiding (cardanoEra)
import Cardano.Api.Experimental.Certificate (PoolId)
import qualified Cardano.Api.Ledger as L

import qualified Cardano.Ledger.Shelley.LedgerState as L
Expand Down
1 change: 1 addition & 0 deletions cardano-testnet/src/Testnet/Property/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Testnet.Property.Assert


import Cardano.Api hiding (Value)
import Cardano.Api.Experimental.Certificate (PoolId)

import Prelude hiding (lines)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,7 @@ hprop_ledger_events_propose_new_constitution = integrationRetryWorkspace 2 "prop
length (filter ((== L.Abstain) . snd) votes) === 2
length votes === fromIntegral numVotes

-- We check that constitution was successfully ratified
void . H.leftFailM . H.evalIO . runExceptT $
foldEpochState
configurationFile
socketPath
FullValidation
(EpochNo 10)
()
(\epochState _ _ -> foldBlocksCheckConstitutionWasRatified constitutionHash constitutionScriptHash epochState)

-- Query proposals via CLI before ratification - the proposal may be removed after ratification
proposalsJSON :: Aeson.Value <- execCliStdoutToJson execConfig
[ eraName, "query", "proposals", "--governance-action-tx-id", prettyShow txId
, "--governance-action-index", "0"
Expand Down Expand Up @@ -338,6 +329,16 @@ hprop_ledger_events_propose_new_constitution = integrationRetryWorkspace 2 "prop
proposalsStakePoolVotes <- H.evalMaybe $ proposal ^? Aeson.key "stakePoolVotes" . Aeson._Object
proposalsStakePoolVotes === mempty

-- We check that constitution was successfully ratified
void . H.leftFailM . H.evalIO . runExceptT $
foldEpochState
configurationFile
socketPath
FullValidation
(EpochNo 10)
()
(\epochState _ _ -> foldBlocksCheckConstitutionWasRatified constitutionHash constitutionScriptHash epochState)

foldBlocksCheckConstitutionWasRatified
:: String -- submitted constitution hash
-> String -- submitted guard rail script hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ import Cardano.Testnet
import Prelude

import Control.Exception
import Control.Monad
import qualified Data.ByteString.Short as SBS
import Data.Default.Class
import qualified Data.Map.Strict as M
import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)
import Data.Word (Word64)
import GHC.Exts (toList)
import Lens.Micro

import Testnet.Components.Query
import Testnet.Process.Run
import Testnet.Property.Util (integrationRetryWorkspace)
import Testnet.Start.Types
import Testnet.Types (nodeConnectionInfo)

import Hedgehog
import qualified Hedgehog as H
Expand All @@ -56,7 +61,7 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
creationOptions = def{creationEra = AnyShelleyBasedEra sbe}
runtimeOptions = def{runtimeEnableRpc = RpcEnabled}

TestnetRuntime
tr@TestnetRuntime
{ testnetMagic
, configurationFile
, testnetNodes = node0@TestnetNode{nodeSprocket} : _
Expand All @@ -79,6 +84,20 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
ChainTipAtGenesis -> H.failure -- impossible
ChainTip (SlotNo slot) (HeaderHash hash) (BlockNo blockNo) -> pure (slot, SBS.fromShort hash, blockNo)

-----------------------------------
-- Compute expected tip timestamp
-----------------------------------
connectionInfo <- nodeConnectionInfo tr 0
(systemStart, eraHistory) <-
(H.leftFail <=< H.leftFailM) . H.evalIO $
executeLocalStateQueryExpr connectionInfo VolatileTip $ do
ss <- querySystemStart
eh <- queryEraHistory
pure $ (,) <$> ss <*> eh
expectedTimestampMs :: Word64 <- H.leftFail $ do
utcTime <- slotToUTCTime systemStart eraHistory (SlotNo slot)
pure . round $ utcTimeToPOSIXSeconds utcTime * 1000

--------------
-- RPC queries
--------------
Expand All @@ -89,7 +108,10 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf U5c.QueryService "readParams")) req

utxos' <- do
let req = Rpc.defMessage
let req = Rpc.defMessage & U5c.keys .~
[ def & U5c.hash .~ serialiseToRawBytes tid & U5c.index .~ fromIntegral tix
| (TxIn tid (TxIx tix), _) <- toList utxos
]
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf U5c.QueryService "readUtxos")) req
pure (pparams', utxos')

Expand All @@ -99,17 +121,18 @@ hprop_rpc_query_pparams = integrationRetryWorkspace 2 "rpc-query-pparams" $ \tem
pparamsResponse ^. U5c.ledgerTip . U5c.slot === slot
pparamsResponse ^. U5c.ledgerTip . U5c.hash === blockHash
pparamsResponse ^. U5c.ledgerTip . U5c.height === blockNo
pparamsResponse ^. U5c.ledgerTip . U5c.timestamp === 0 -- not possible to implement at this moment
H.assertWithinTolerance (pparamsResponse ^. U5c.ledgerTip . U5c.timestamp) expectedTimestampMs 1000

-- https://docs.cardano.org/about-cardano/explore-more/parameter-guide
let chainParams = pparamsResponse ^. U5c.values . U5c.cardano
babbageEraOnwardsConstraints (convert ceo) $ do
pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to L.fromCompact . to L.unCoin
===^ chainParams ^. U5c.coinsPerUtxoByte . to utxoRpcBigIntToInteger
pparams ^. L.ppMaxTxSizeL === chainParams ^. U5c.maxTxSize . to fromIntegral
pparams ^. L.ppTxFeeFixedL ===^ chainParams ^. U5c.minFeeCoefficient . to (fmap L.Coin . utxoRpcBigIntToInteger)
pparams ^. L.ppTxFeePerByteL . to L.unCoinPerByte . to L.fromCompact . to L.unCoin
pparams ^. L.ppTxFeeFixedL . to L.unCoin
===^ chainParams ^. U5c.minFeeConstant . to utxoRpcBigIntToInteger
pparams ^. L.ppTxFeePerByteL . to L.unCoinPerByte . to L.fromCompact . to L.unCoin
===^ chainParams ^. U5c.minFeeCoefficient . to utxoRpcBigIntToInteger
pparams ^. L.ppMaxBBSizeL === chainParams ^. U5c.maxBlockBodySize . to fromIntegral
pparams ^. L.ppMaxBHSizeL === chainParams ^. U5c.maxBlockHeaderSize . to fromIntegral
pparams ^. L.ppKeyDepositL ===^ chainParams ^. U5c.stakeKeyDeposit . to (fmap L.Coin . utxoRpcBigIntToInteger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import qualified Cardano.Api.Ledger as L

import Cardano.Rpc.Client (Proto)
import qualified Cardano.Rpc.Client as Rpc
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as U5c hiding (cardano, items, tx)
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as U5c hiding (cardano)
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as UtxoRpc
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as U5c
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as UtxoRpc
Expand Down Expand Up @@ -90,8 +90,8 @@ hprop_rpc_transaction = integrationRetryWorkspace 2 "rpc-tx" $ \tempAbsBasePath'
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readParams")) req

utxos' <- do
let req = def -- & # U5c.keys .~ [T.encodeUtf8 addrTxt0]
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readUtxos")) req
let req = def & U5c.predicate .~ mkAddrPredicate addr0
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "searchUtxos")) req
pure (pparams', utxos')

pparams <- H.leftFail $ utxoRpcPParamsToProtocolParams (convert ceo) $ pparamsResponse ^. U5c.values . U5c.cardano
Expand Down Expand Up @@ -131,21 +131,28 @@ hprop_rpc_transaction = integrationRetryWorkspace 2 "rpc-tx" $ \tempAbsBasePath'
H.note_ "Ensure that submitTx returns the same transaction ID as the locally computed signed transaction ID"
txId' === submittedTxId

-- TODO use searchUtxos when available
H.note_ $ "Ensure that there are 2 UTXOs in the address " <> show addrTxt1
utxosForAddress <- retryUntilM epochStateView (WaitForBlocks 10)
(do utxos <- H.evalIO $
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readUtxos")) def
flip filterM (utxos ^. U5c.items) $ \utxo -> do
utxoAddress <- deserialiseAddressBs addrInEra $ utxo ^. U5c.cardano . U5c.address
pure $ addr1 == utxoAddress
(do let req = def & U5c.predicate .~ mkAddrPredicate addr1
utxos <- H.evalIO $
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "searchUtxos")) req
pure $ utxos ^. U5c.items
)
(\xs -> length xs == 2)

let outputsAmounts = map (^. U5c.cardano . U5c.coin) utxosForAddress
H.note_ $ "Ensure that the output sent is one of the utxos for the address " <> show addrTxt1
H.assertWith outputsAmounts $ elem (inject amount)

mkAddrPredicate :: SerialiseAsRawBytes addr => addr -> Proto UtxoRpc.UtxoPredicate
mkAddrPredicate addr =
def
& U5c.match
.~ ( def
& U5c.cardano
.~ (def & U5c.address .~ (def & U5c.exactAddress .~ serialiseToRawBytes addr))
)

txoRefToTxIn :: (HasCallStack, MonadTest m) => Proto UtxoRpc.TxoRef -> m TxIn
txoRefToTxIn r = withFrozenCallStack $ do
txId' <- H.leftFail $ deserialiseFromRawBytes AsTxId $ r ^. U5c.hash
Expand Down
Loading