Skip to content

Commit d7abccd

Browse files
authored
Merge pull request #5960 from IntersectMBO/smelc/honor-cardano-testnet-max-supply-value
cardano-testnet: honor --max-supply value, by passing it to --create-testnet-data under the hood
2 parents fecf2bf + fc9fb2b commit d7abccd

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

cardano-testnet/src/Parsers/Cardano.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{-# LANGUAGE NumericUnderscores #-}
2-
31
module Parsers.Cardano
42
( cmdCardano
53
) where
@@ -134,6 +132,6 @@ pMaxLovelaceSupply =
134132
<> help "Max lovelace supply that your testnet starts with."
135133
<> metavar "WORD64"
136134
<> showDefault
137-
<> value 10_020_000_000
135+
<> value (cardanoMaxSupply cardanoDefaultTestnetOptions)
138136
)
139137

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE GADTs #-}
22
{-# LANGUAGE NamedFieldPuns #-}
3-
{-# LANGUAGE NumericUnderscores #-}
43
{-# LANGUAGE OverloadedStrings #-}
54
{-# LANGUAGE ScopedTypeVariables #-}
65
{-# LANGUAGE TypeApplications #-}
@@ -52,6 +51,7 @@ import qualified Data.List as List
5251
import Data.String
5352
import Data.Text (Text)
5453
import qualified Data.Text as Text
54+
import Data.Word (Word64)
5555
import GHC.Stack (HasCallStack)
5656
import qualified GHC.Stack as GHC
5757
import Lens.Micro
@@ -132,13 +132,14 @@ createSPOGenesisAndFiles
132132
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
133133
=> NumPools -- ^ The number of pools to make
134134
-> NumDReps -- ^ The number of pools to make
135+
-> Word64 -- ^ The maximum supply
135136
-> AnyShelleyBasedEra -- ^ The era to use
136137
-> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use.
137138
-> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module.
138139
-> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'.
139140
-> TmpAbsolutePath
140141
-> m FilePath -- ^ Shelley genesis directory
141-
createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) sbe shelleyGenesis
142+
createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) maxSupply sbe shelleyGenesis
142143
alonzoGenesis conwayGenesis (TmpAbsolutePath tempAbsPath) = GHC.withFrozenCallStack $ do
143144
let inputGenesisShelleyFp = tempAbsPath </> genesisInputFilepath ShelleyEra
144145
inputGenesisAlonzoFp = tempAbsPath </> genesisInputFilepath AlonzoEra
@@ -181,8 +182,8 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) sbe shell
181182
, "--spec-conway", inputGenesisConwayFp
182183
, "--testnet-magic", show testnetMagic
183184
, "--pools", show numPoolNodes
184-
, "--total-supply", show @Int 2_000_000_000_000 -- 2 trillions
185-
, "--delegated-supply", show @Int 1_000_000_000_000 -- 1 trillion
185+
, "--total-supply", show maxSupply
186+
, "--delegated-supply", show (maxSupply `div` 2) -- Required until https://github.com/IntersectMBO/cardano-cli/pull/874 is integrated
186187
, "--stake-delegators", show numStakeDelegators
187188
, "--utxo-keys", show numSeededUTxOKeys
188189
, "--drep-keys", show numDelReps

cardano-testnet/src/Testnet/Start/Cardano.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ cardanoTestnet
192192
numPoolNodes = length $ cardanoNodes testnetOptions
193193
nPools = numPools testnetOptions
194194
nDReps = numDReps testnetOptions
195+
maxSupply = cardanoMaxSupply testnetOptions
195196
asbe = cardanoNodeEra testnetOptions
196197
AnyShelleyBasedEra sbe <- pure asbe
197198

@@ -237,7 +238,7 @@ cardanoTestnet
237238

238239
configurationFile <- H.noteShow . File $ tmpAbsPath </> "configuration.yaml"
239240

240-
_ <- createSPOGenesisAndFiles nPools nDReps asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
241+
_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
241242

242243
-- TODO: This should come from the configuration!
243244
let poolKeyDir :: Int -> FilePath

cardano-testnet/src/Testnet/Start/Types.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ data CardanoTestnetOptions = CardanoTestnetOptions
4444
, cardanoSlotLength :: Double -- ^ Slot length, in seconds
4545
, cardanoTestnetMagic :: Int
4646
, cardanoActiveSlotsCoeff :: Double
47-
, cardanoMaxSupply :: Word64 -- ^ The amount of ADA you are starting your testnet with (forwarded to shelley genesis)
47+
, cardanoMaxSupply :: Word64 -- ^ The amount of Lovelace you are starting your testnet with (forwarded to shelley genesis)
4848
, cardanoEnableP2P :: Bool
4949
, cardanoNodeLoggingFormat :: NodeLoggingFormat
5050
, cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation
@@ -59,7 +59,7 @@ cardanoDefaultTestnetOptions = CardanoTestnetOptions
5959
, cardanoSlotLength = 0.1
6060
, cardanoTestnetMagic = 42
6161
, cardanoActiveSlotsCoeff = 0.05
62-
, cardanoMaxSupply = 100_020_000_000 -- 100 billions. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron
62+
, cardanoMaxSupply = 100_000_020_000_000 -- 100 000 billions Lovelace, so 100 millions ADA. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron
6363
, cardanoEnableP2P = False
6464
, cardanoNodeLoggingFormat = NodeLoggingFormatAsJson
6565
, cardanoNumDReps = 3

cardano-testnet/test/cardano-testnet-golden/files/golden/help/cardano.cli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Available options:
3535
Active slots co-efficient (default: 5.0e-2)
3636
--max-lovelace-supply WORD64
3737
Max lovelace supply that your testnet starts with.
38-
(default: 10020000000)
38+
(default: 100000020000000)
3939
--enable-p2p BOOL Enable P2P (default: False)
4040
--nodeLoggingFormat LOGGING_FORMAT
4141
Node logging format (json|text)

cardano-testnet/test/cardano-testnet-test/files/golden/queries/drepStateOut.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"anchor": null,
88
"deposit": 1000000,
99
"expiry": 1002,
10-
"stake": 300000000000
10+
"stake": 15000003000000
1111
}
1212
],
1313
[
@@ -18,7 +18,7 @@
1818
"anchor": null,
1919
"deposit": 1000000,
2020
"expiry": 1002,
21-
"stake": 300000000000
21+
"stake": 15000003000000
2222
}
2323
],
2424
[
@@ -29,7 +29,7 @@
2929
"anchor": null,
3030
"deposit": 1000000,
3131
"expiry": 1002,
32-
"stake": 300000000000
32+
"stake": 15000003000000
3333
}
3434
]
3535
]

cardano-testnet/test/cardano-testnet-test/files/golden/tx.failed.response.json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"error": [
77
{
88
"contents": {
9-
"contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 300000000000) (MultiAsset (fromList []))))",
9+
"contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 15000003000000) (MultiAsset (fromList []))))",
1010
"tag": "UtxoFailure"
1111
},
1212
"tag": "UtxowFailure"

0 commit comments

Comments
 (0)