Skip to content

Commit

Permalink
Merge pull request #5960 from IntersectMBO/smelc/honor-cardano-testne…
Browse files Browse the repository at this point in the history
…t-max-supply-value

cardano-testnet: honor --max-supply value, by passing it to --create-testnet-data under the hood
  • Loading branch information
smelc committed Aug 29, 2024
2 parents fecf2bf + fc9fb2b commit d7abccd
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 1 addition & 3 deletions cardano-testnet/src/Parsers/Cardano.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE NumericUnderscores #-}

module Parsers.Cardano
( cmdCardano
) where
Expand Down Expand Up @@ -134,6 +132,6 @@ pMaxLovelaceSupply =
<> help "Max lovelace supply that your testnet starts with."
<> metavar "WORD64"
<> showDefault
<> value 10_020_000_000
<> value (cardanoMaxSupply cardanoDefaultTestnetOptions)
)

9 changes: 5 additions & 4 deletions cardano-testnet/src/Testnet/Components/Configuration.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
Expand Down Expand Up @@ -52,6 +51,7 @@ import qualified Data.List as List
import Data.String
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Word (Word64)
import GHC.Stack (HasCallStack)
import qualified GHC.Stack as GHC
import Lens.Micro
Expand Down Expand Up @@ -132,13 +132,14 @@ createSPOGenesisAndFiles
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
=> NumPools -- ^ The number of pools to make
-> NumDReps -- ^ The number of pools to make
-> Word64 -- ^ The maximum supply
-> AnyShelleyBasedEra -- ^ The era to use
-> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use.
-> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module.
-> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'.
-> TmpAbsolutePath
-> m FilePath -- ^ Shelley genesis directory
createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) sbe shelleyGenesis
createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) maxSupply sbe shelleyGenesis
alonzoGenesis conwayGenesis (TmpAbsolutePath tempAbsPath) = GHC.withFrozenCallStack $ do
let inputGenesisShelleyFp = tempAbsPath </> genesisInputFilepath ShelleyEra
inputGenesisAlonzoFp = tempAbsPath </> genesisInputFilepath AlonzoEra
Expand Down Expand Up @@ -181,8 +182,8 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) sbe shell
, "--spec-conway", inputGenesisConwayFp
, "--testnet-magic", show testnetMagic
, "--pools", show numPoolNodes
, "--total-supply", show @Int 2_000_000_000_000 -- 2 trillions
, "--delegated-supply", show @Int 1_000_000_000_000 -- 1 trillion
, "--total-supply", show maxSupply
, "--delegated-supply", show (maxSupply `div` 2) -- Required until https://github.com/IntersectMBO/cardano-cli/pull/874 is integrated
, "--stake-delegators", show numStakeDelegators
, "--utxo-keys", show numSeededUTxOKeys
, "--drep-keys", show numDelReps
Expand Down
3 changes: 2 additions & 1 deletion cardano-testnet/src/Testnet/Start/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ cardanoTestnet
numPoolNodes = length $ cardanoNodes testnetOptions
nPools = numPools testnetOptions
nDReps = numDReps testnetOptions
maxSupply = cardanoMaxSupply testnetOptions
asbe = cardanoNodeEra testnetOptions
AnyShelleyBasedEra sbe <- pure asbe

Expand Down Expand Up @@ -237,7 +238,7 @@ cardanoTestnet

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

_ <- createSPOGenesisAndFiles nPools nDReps asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)

-- TODO: This should come from the configuration!
let poolKeyDir :: Int -> FilePath
Expand Down
4 changes: 2 additions & 2 deletions cardano-testnet/src/Testnet/Start/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data CardanoTestnetOptions = CardanoTestnetOptions
, cardanoSlotLength :: Double -- ^ Slot length, in seconds
, cardanoTestnetMagic :: Int
, cardanoActiveSlotsCoeff :: Double
, cardanoMaxSupply :: Word64 -- ^ The amount of ADA you are starting your testnet with (forwarded to shelley genesis)
, cardanoMaxSupply :: Word64 -- ^ The amount of Lovelace you are starting your testnet with (forwarded to shelley genesis)
, cardanoEnableP2P :: Bool
, cardanoNodeLoggingFormat :: NodeLoggingFormat
, cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation
Expand All @@ -59,7 +59,7 @@ cardanoDefaultTestnetOptions = CardanoTestnetOptions
, cardanoSlotLength = 0.1
, cardanoTestnetMagic = 42
, cardanoActiveSlotsCoeff = 0.05
, cardanoMaxSupply = 100_020_000_000 -- 100 billions. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron
, 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
, cardanoEnableP2P = False
, cardanoNodeLoggingFormat = NodeLoggingFormatAsJson
, cardanoNumDReps = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Available options:
Active slots co-efficient (default: 5.0e-2)
--max-lovelace-supply WORD64
Max lovelace supply that your testnet starts with.
(default: 10020000000)
(default: 100000020000000)
--enable-p2p BOOL Enable P2P (default: False)
--nodeLoggingFormat LOGGING_FORMAT
Node logging format (json|text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"anchor": null,
"deposit": 1000000,
"expiry": 1002,
"stake": 300000000000
"stake": 15000003000000
}
],
[
Expand All @@ -18,7 +18,7 @@
"anchor": null,
"deposit": 1000000,
"expiry": 1002,
"stake": 300000000000
"stake": 15000003000000
}
],
[
Expand All @@ -29,7 +29,7 @@
"anchor": null,
"deposit": 1000000,
"expiry": 1002,
"stake": 300000000000
"stake": 15000003000000
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"error": [
{
"contents": {
"contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 300000000000) (MultiAsset (fromList []))))",
"contents": "AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 0) (MultiAsset (fromList []))) (MaryValue (Coin 15000003000000) (MultiAsset (fromList []))))",
"tag": "UtxoFailure"
},
"tag": "UtxowFailure"
Expand Down

0 comments on commit d7abccd

Please sign in to comment.