Skip to content

Commit 09f2827

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e992771 + 3cbbace commit 09f2827

File tree

11 files changed

+238
-125
lines changed

11 files changed

+238
-125
lines changed

bench/cardano-topology/cardano-topology.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ license: Apache-2.0
1313
license-files: LICENSE
1414
NOTICE
1515
build-type: Simple
16-
extra-source-files: README.md
1716
data-files: data/bench-torus-52.json
1817
data/bench-torus-dense-52.json
1918
data/ci-test-nomadcwqa.json

cardano-testnet/cardano-testnet.cabal

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ library
3838
, cardano-cli ^>= 8.20.3.0
3939
, cardano-crypto-class
4040
, cardano-crypto-wrapper
41+
, cardano-git-rev
4142
, cardano-ledger-alonzo
43+
, cardano-ledger-binary
44+
, cardano-ledger-byron
45+
, cardano-ledger-conway
4246
, cardano-ledger-conway
4347
, cardano-ledger-core
4448
, cardano-ledger-core:testlib
45-
, cardano-git-rev
46-
, cardano-ledger-core
47-
, cardano-ledger-binary
48-
, cardano-ledger-byron
4949
, cardano-ledger-shelley
5050
, cardano-node
5151
, cardano-ping ^>= 0.2.0.10
@@ -183,6 +183,7 @@ test-suite cardano-testnet-test
183183
Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction
184184
Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitutionSPO
185185
Cardano.Testnet.Test.LedgerEvents.SanityCheck
186+
Cardano.Testnet.Test.LedgerEvents.TreasuryGrowth
186187

187188
Cardano.Testnet.Test.Node.Shutdown
188189
Cardano.Testnet.Test.SubmitApi.Babbage.Transaction
@@ -198,8 +199,10 @@ test-suite cardano-testnet-test
198199
, cardano-cli
199200
, cardano-crypto-class
200201
, cardano-ledger-conway
202+
, cardano-ledger-core
201203
, cardano-ledger-shelley
202204
, cardano-node
205+
, cardano-strict-containers ^>= 0.1
203206
, cardano-testnet
204207
, containers
205208
, directory

cardano-testnet/src/Testnet/Components/Configuration.hs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import Data.Bifunctor
3434
import qualified Data.ByteString.Lazy as LBS
3535
import qualified Data.List as List
3636
import Data.String
37-
import Data.Word (Word32)
3837
import GHC.Stack (HasCallStack)
3938
import qualified GHC.Stack as GHC
4039
import Lens.Micro
@@ -98,7 +97,7 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) era shelleyGenesis (TmpAbsolute
9897
genesisShelleyDirAbs = takeDirectory genesisShelleyFpAbs
9998
genesisShelleyDir <- H.createDirectoryIfMissing genesisShelleyDirAbs
10099
let testnetMagic = sgNetworkMagic shelleyGenesis
101-
numStakeDelegators = 3
100+
numStakeDelegators = 3 :: Int
102101
startTime = sgSystemStart shelleyGenesis
103102

104103
-- TODO: We need to read the genesis files into Haskell and modify them
@@ -115,6 +114,8 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) era shelleyGenesis (TmpAbsolute
115114
-- 50 second epochs
116115
-- Epoch length should be "10 * k / f" where "k = securityParam, f = activeSlotsCoeff"
117116
H.rewriteJsonFile @Value genesisShelleyFpAbs $ \o -> o
117+
-- TODO: remove rho and tau adjustment after https://github.com/IntersectMBO/cardano-api/pull/425 gets
118+
-- integrated with newer cardano-api into node
118119
& L.key "protocolParams" . L.key "rho" . L._Number .~ 0.1
119120
& L.key "protocolParams" . L.key "tau" . L._Number .~ 0.1
120121
& L.key "securityParam" . L._Integer .~ 5
@@ -130,11 +131,11 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) era shelleyGenesis (TmpAbsolute
130131
execCli_
131132
[ convertToEraString era, "genesis", "create-testnet-data"
132133
, "--spec-shelley", genesisShelleyFpAbs
133-
, "--testnet-magic", show @Word32 testnetMagic
134-
, "--pools", show @Int numPoolNodes
134+
, "--testnet-magic", show testnetMagic
135+
, "--pools", show numPoolNodes
135136
, "--total-supply", show @Int 2_000_000_000_000
136137
, "--delegated-supply", show @Int 1_000_000_000_000
137-
, "--stake-delegators", show @Int numStakeDelegators
138+
, "--stake-delegators", show numStakeDelegators
138139
, "--utxo-keys", show numSeededUTxOKeys
139140
, "--drep-keys", "3"
140141
, "--start-time", DTC.formatIso8601 startTime
@@ -152,7 +153,6 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) era shelleyGenesis (TmpAbsolute
152153
forM_ files $ \file -> do
153154
H.note file
154155

155-
156156
-- TODO: This conway and alonzo genesis creation should be ultimately moved to create-testnet-data
157157
alonzoConwayTestGenesisJsonTargetFile <- H.noteShow (genesisShelleyDir </> "genesis.alonzo.json")
158158
gen <- H.evalEither $ first prettyError defaultAlonzoGenesis
@@ -161,10 +161,16 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) era shelleyGenesis (TmpAbsolute
161161
conwayConwayTestGenesisJsonTargetFile <- H.noteShow (genesisShelleyDir </> "genesis.conway.json")
162162
H.evalIO $ LBS.writeFile conwayConwayTestGenesisJsonTargetFile $ Aeson.encode defaultConwayGenesis
163163

164-
H.renameFile (tempAbsPath' </> "byron-gen-command/genesis.json") (genesisByronDir </> "genesis.json")
165-
-- TODO: create-testnet-data outputs the new shelley genesis do genesis.json
164+
H.renameFile (tempAbsPath' </> "byron-gen-command" </> "genesis.json") (genesisByronDir </> "genesis.json")
165+
-- TODO: create-testnet-data outputs the new shelley genesis to genesis.json
166166
H.renameFile (tempAbsPath' </> "genesis.json") (genesisShelleyDir </> "genesis.shelley.json")
167167

168+
-- TODO: move this to create-testnet-data
169+
-- For some reason when setting "--total-supply 10E16" in create-testnet-data, we're getting negative
170+
-- treasury
171+
H.rewriteJsonFile @Value (genesisShelleyDir </> "genesis.shelley.json") $ \o -> o
172+
& L.key "maxLovelaceSupply" . L._Integer .~ 10_000_000_000_000_000
173+
168174
return genesisShelleyDir
169175

170176
ifaceAddress :: String

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule
1515
) where
1616

1717
import Cardano.Api
18+
import qualified Cardano.Api as Api
1819

19-
import Cardano.CLI.Types.Output (QueryTipLocalStateOutput (..))
2020
import Cardano.Node.Configuration.Topology
2121
import Cardano.Testnet
2222

@@ -32,7 +32,6 @@ import qualified Data.Map.Strict as Map
3232
import Data.Text (Text)
3333
import qualified Data.Text as Text
3434
import qualified Data.Time.Clock as DTC
35-
import GHC.Stack (callStack)
3635
import qualified GHC.Stack as GHC
3736
import System.FilePath ((</>))
3837
import qualified System.Info as SYS
@@ -49,6 +48,7 @@ import Testnet.Runtime
4948
import Hedgehog (Property, (===))
5049
import qualified Hedgehog as H
5150
import Hedgehog.Extras (threadDelay)
51+
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
5252
import qualified Hedgehog.Extras.Test.Base as H
5353
import qualified Hedgehog.Extras.Test.File as H
5454

@@ -193,6 +193,7 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch
193193
, "--tx-file", delegRegTestDelegatorTxFp
194194
]
195195

196+
-- TODO: Can be removed if checkStakeKeyRegistered uses foldEpochState
196197
threadDelay 15_000000
197198

198199
-------------------------------------------------------------------
@@ -253,74 +254,56 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch
253254
testPoolStdOutFp <- case eRuntime of
254255
Left e -> H.failMessage GHC.callStack $ "Failed to start node: " <> show e
255256
Right runtime -> return $ nodeStdout runtime
256-
threadDelay 5_000000
257257

258+
-- Wait for 2 epochs to pass
259+
void $ waitUntilEpoch (Api.File configurationFile)
260+
(Api.File $ IO.sprocketSystemName node1sprocket) (EpochNo 3)
258261

259-
tipDeadline <- H.noteShowM $ DTC.addUTCTime 210 <$> H.noteShowIO DTC.getCurrentTime
262+
currentLeaderShipScheduleFile <- H.noteTempFile work "current-schedule.log"
260263

261-
H.byDeadlineM 10 tipDeadline "Wait for two epochs" $ do
262-
void $ execCli' execConfig
263-
[ "query", "tip"
264-
, "--out-file", work </> "current-tip.json"
265-
]
266-
267-
tipJson <- H.leftFailM . H.readJsonFile $ work </> "current-tip.json"
268-
tip <- H.noteShowM $ H.jsonErrorFail $ J.fromJSON @QueryTipLocalStateOutput tipJson
269-
270-
currEpoch <- case mEpoch tip of
271-
Nothing -> H.failMessage callStack "cardano-cli query tip returned Nothing for EpochNo"
272-
Just currEpoch -> return currEpoch
273-
274-
H.note_ $ "Current Epoch: " <> show currEpoch
275-
H.assert $ currEpoch > 2
276-
277-
id do
278-
currentLeaderShipScheduleFile <- H.noteTempFile work "current-schedule.log"
279-
280-
leadershipScheduleDeadline <- H.noteShowM $ DTC.addUTCTime 180 <$> H.noteShowIO DTC.getCurrentTime
281-
282-
H.byDeadlineM 5 leadershipScheduleDeadline "Failed to query for leadership schedule" $ do
283-
void $ execCli' execConfig
284-
[ "query", "leadership-schedule"
285-
, "--genesis", shelleyGenesisFile tr
286-
, "--stake-pool-id", stakePoolIdNewSpo
287-
, "--vrf-signing-key-file", vrfSkey
288-
, "--out-file", currentLeaderShipScheduleFile
289-
, "--current"
290-
]
264+
void $ execCli' execConfig
265+
[ "query", "leadership-schedule"
266+
, "--genesis", shelleyGenesisFile tr
267+
, "--stake-pool-id", stakePoolIdNewSpo
268+
, "--vrf-signing-key-file", vrfSkey
269+
, "--out-file", currentLeaderShipScheduleFile
270+
, "--current"
271+
]
291272

292-
currentScheduleJson <- H.leftFailM $ H.readJsonFile currentLeaderShipScheduleFile
273+
currentScheduleJson <- H.leftFailM $ H.readJsonFile currentLeaderShipScheduleFile
293274

294-
expectedLeadershipSlotNumbers <- H.noteShowM $ fmap (fmap slotNumber) $ H.leftFail $ J.parseEither (J.parseJSON @[LeadershipSlot]) currentScheduleJson
275+
expectedLeadershipSlotNumbers <- H.noteShowM $ fmap (fmap slotNumber) $ H.leftFail $ J.parseEither (J.parseJSON @[LeadershipSlot]) currentScheduleJson
295276

296-
maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers
277+
maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers
297278

298-
H.assert $ not (L.null expectedLeadershipSlotNumbers)
279+
H.assert $ not (L.null expectedLeadershipSlotNumbers)
299280

300-
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime
281+
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime
301282

302283
-- We need enough time to pass such that the expected leadership slots generated by the
303284
-- leadership-schedule command have actually occurred.
304-
(leaderSlots, notLeaderSlots) <- H.byDeadlineM 10 leadershipDeadline "Wait for chain to surpass all expected leadership slots" $ do
305-
(someLeaderSlots, someNotLeaderSlots) <- getRelevantSlots testPoolStdOutFp (minimum expectedLeadershipSlotNumbers)
306-
if L.null someLeaderSlots
307-
then H.failure
308-
else do
309-
maxActualSlot <- H.noteShow $ maximum someLeaderSlots
310-
H.assert $ maxActualSlot >= maxSlotExpected
311-
pure (someLeaderSlots, someNotLeaderSlots)
312-
313-
H.noteShow_ expectedLeadershipSlotNumbers
314-
H.noteShow_ leaderSlots
315-
H.noteShow_ notLeaderSlots
285+
-- TODO: We can further improve this if parameterize foldEpochState's callback on
286+
-- the current slot and current block number.
287+
(leaderSlots, notLeaderSlots) <- H.byDeadlineM 10 leadershipDeadline "Wait for chain to surpass all expected leadership slots" $ do
288+
(someLeaderSlots, someNotLeaderSlots) <- getRelevantSlots testPoolStdOutFp (minimum expectedLeadershipSlotNumbers)
289+
if L.null someLeaderSlots
290+
then H.failure
291+
else do
292+
maxActualSlot <- H.noteShow $ maximum someLeaderSlots
293+
H.assert $ maxActualSlot >= maxSlotExpected
294+
pure (someLeaderSlots, someNotLeaderSlots)
295+
296+
H.noteShow_ expectedLeadershipSlotNumbers
297+
H.noteShow_ leaderSlots
298+
H.noteShow_ notLeaderSlots
316299

317300
-- Double check that we've seen all slots
318-
H.noteShow_ ("Slots not seen as TraceNodeIsLeader nor TraceNodeNotLeader" :: Text)
319-
([minimum expectedLeadershipSlotNumbers .. maxSlotExpected] \\ leaderSlots) \\ notLeaderSlots === []
301+
H.noteShow_ ("Slots not seen as TraceNodeIsLeader nor TraceNodeNotLeader" :: Text)
302+
([minimum expectedLeadershipSlotNumbers .. maxSlotExpected] \\ leaderSlots) \\ notLeaderSlots === []
320303

321304
-- As there are no BFT nodes, the next leadership schedule should match slots assigned exactly
322-
H.noteShow_ (expectedLeadershipSlotNumbers \\ leaderSlots)
323-
H.assert $ L.null (expectedLeadershipSlotNumbers \\ leaderSlots)
305+
H.noteShow_ (expectedLeadershipSlotNumbers \\ leaderSlots)
306+
H.assert $ L.null (expectedLeadershipSlotNumbers \\ leaderSlots)
324307
-- TODO: Re-enable --next leadership schedule test
325308
{-
326309

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ module Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot
1010
) where
1111

1212
import Cardano.Api
13+
import qualified Cardano.Api as Api
1314

14-
import Cardano.CLI.Types.Output (QueryTipLocalStateOutput (..))
1515
import Cardano.Testnet
1616

1717
import Prelude
1818

19+
import Control.Monad
1920
import qualified Data.Aeson as Aeson
2021
import qualified Data.Aeson.KeyMap as KM
21-
import qualified Data.Time.Clock as DTC
22-
import GHC.Stack (callStack)
2322
import qualified System.Info as SYS
2423

2524
import Testnet.Process.Cli (execCliStdoutToJson)
@@ -29,6 +28,7 @@ import Testnet.Runtime
2928

3029
import Hedgehog (Property, (===))
3130
import qualified Hedgehog as H
31+
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
3232
import qualified Hedgehog.Extras.Test.Base as H
3333

3434
hprop_stakeSnapshot :: Property
@@ -49,22 +49,15 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \
4949
TestnetRuntime
5050
{ testnetMagic
5151
, poolNodes
52+
, configurationFile
5253
} <- cardanoTestnetDefault options conf
5354

5455
poolNode1 <- H.headM poolNodes
5556
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
5657
execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic
57-
tipDeadline <- H.noteShowM $ DTC.addUTCTime 210 <$> H.noteShowIO DTC.getCurrentTime
5858

59-
H.byDeadlineM 10 tipDeadline "Wait for two epochs" $ do
60-
tip <- execCliStdoutToJson execConfig [ "query", "tip" ]
61-
62-
currEpoch <- case mEpoch tip of
63-
Nothing -> H.failMessage callStack "cardano-cli query tip returned Nothing for EpochNo"
64-
Just currEpoch -> return currEpoch
65-
66-
H.note_ $ "Current Epoch: " <> show currEpoch
67-
H.assert $ currEpoch > 2
59+
void $ waitUntilEpoch (Api.File configurationFile)
60+
(Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3)
6861

6962
json <- execCliStdoutToJson execConfig [ "query", "stake-snapshot", "--all-stake-pools" ]
7063

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ module Cardano.Testnet.Test.Cli.Conway.StakeSnapshot
99
( hprop_stakeSnapshot
1010
) where
1111

12-
import Cardano.Api
12+
import Cardano.Api as Api
1313

14-
import Cardano.CLI.Types.Output (QueryTipLocalStateOutput (..))
1514
import Cardano.Testnet
1615

1716
import Prelude
1817

18+
import Control.Monad
1919
import qualified Data.Aeson as Aeson
2020
import qualified Data.Aeson.KeyMap as KM
21-
import qualified Data.Time.Clock as DTC
22-
import GHC.Stack (callStack)
2321
import qualified System.Info as SYS
2422

2523
import Testnet.Process.Cli (execCliStdoutToJson)
@@ -29,6 +27,7 @@ import Testnet.Runtime
2927

3028
import Hedgehog (Property, (===))
3129
import qualified Hedgehog as H
30+
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
3231
import qualified Hedgehog.Extras.Test.Base as H
3332

3433
hprop_stakeSnapshot :: Property
@@ -48,23 +47,16 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "conway-stake-snapshot" $ \t
4847
TestnetRuntime
4948
{ testnetMagic
5049
, poolNodes
50+
, configurationFile
5151
} <- cardanoTestnetDefault options conf
5252

5353
poolNode1 <- H.headM poolNodes
5454
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
5555
execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic
5656

57-
tipDeadline <- H.noteShowM $ DTC.addUTCTime 210 <$> H.noteShowIO DTC.getCurrentTime
57+
void $ waitUntilEpoch (Api.File configurationFile)
58+
(Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3)
5859

59-
H.byDeadlineM 10 tipDeadline "Wait for two epochs" $ do
60-
tip <- execCliStdoutToJson execConfig [ "query", "tip" ]
61-
62-
currEpoch <- case mEpoch tip of
63-
Nothing -> H.failMessage callStack "cardano-cli query tip returned Nothing for EpochNo"
64-
Just currEpoch -> return currEpoch
65-
66-
H.note_ $ "Current Epoch: " <> show currEpoch
67-
H.assert $ currEpoch > 2
6860

6961
json <- execCliStdoutToJson execConfig [ "query", "stake-snapshot", "--all-stake-pools" ]
7062

0 commit comments

Comments
 (0)