Skip to content

Commit ea879a3

Browse files
authored
cardano-testnet: Avoid rewrite of sgMaxLovelaceSupply (IntersectMBO#5746)
* Details * Avoid needing rewrite of maxLovelaceSupply
1 parent 0e241db commit ea879a3

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) era shell
146146
, "--spec-conway", inputGenesisConwayFp
147147
, "--testnet-magic", show testnetMagic
148148
, "--pools", show numPoolNodes
149-
, "--total-supply", show @Int 2_000_000_000_000
150-
, "--delegated-supply", show @Int 1_000_000_000_000
149+
, "--total-supply", show @Int 2_000_000_000_000 -- 2 trillions
150+
, "--delegated-supply", show @Int 1_000_000_000_000 -- 1 trillion
151151
, "--stake-delegators", show numStakeDelegators
152152
, "--utxo-keys", show numSeededUTxOKeys
153153
, "--drep-keys", show numDelReps
@@ -166,12 +166,6 @@ createSPOGenesisAndFiles (NumPools numPoolNodes) (NumDReps numDelReps) era shell
166166

167167
H.renameFile (tempAbsPath </> "byron-gen-command" </> "genesis.json") (genesisByronDir </> "genesis.json")
168168

169-
-- For some reason when setting "--total-supply 10E16" in create-testnet-data, we're getting negative
170-
-- treasury. TODO: This was supposed to be fixed by https://github.com/IntersectMBO/cardano-cli/pull/644,
171-
-- but no, it's still there.
172-
H.rewriteJsonFile @Value (tempAbsPath </> defaultGenesisFilepath ShelleyEra) $ \o -> o
173-
& L.key "maxLovelaceSupply" . L._Integer .~ 10_000_000_000_000_000
174-
175169
return genesisShelleyDir
176170
where
177171
genesisInputFilepath e = "genesis-input." <> anyEraToString (AnyCardanoEra e) <> ".json"

cardano-testnet/src/Testnet/Defaults.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ defaultShelleyGenesis startTime testnetOptions = do
434434
{ cardanoTestnetMagic = testnetMagic
435435
, cardanoSlotLength = slotLength
436436
, cardanoEpochLength = epochLength
437-
, cardanoMaxSupply = maxLovelaceLovelaceSupply
437+
, cardanoMaxSupply = sgMaxLovelaceSupply
438438
, cardanoActiveSlotsCoeff
439439
, cardanoNodeEra
440440
} = testnetOptions
@@ -449,7 +449,7 @@ defaultShelleyGenesis startTime testnetOptions = do
449449
Api.shelleyGenesisDefaults
450450
{ Api.sgActiveSlotsCoeff = unsafeBoundedRational activeSlotsCoeff
451451
, Api.sgEpochLength = EpochSize $ fromIntegral epochLength
452-
, Api.sgMaxLovelaceSupply = maxLovelaceLovelaceSupply
452+
, Api.sgMaxLovelaceSupply
453453
, Api.sgNetworkMagic = fromIntegral testnetMagic
454454
, Api.sgProtocolParams = protocolParamsWithPVer
455455
-- using default from shelley genesis k = 2160

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE TypeApplications #-}
44

55
{-# OPTIONS_GHC -Wno-unused-local-binds -Wno-unused-matches #-}
6+
{-# LANGUAGE NumericUnderscores #-}
67

78
module Testnet.Start.Byron
89
( createByronGenesis
@@ -34,7 +35,7 @@ byronDefaultGenesisOptions = ByronGenesisOptions
3435
-- TODO: createByronGenesis should have a check that errors
3536
-- if totalBalance can be evenly split between numBftNodes
3637
-- with no remainder. Having a remainder results in rounding errors.
37-
, byronTotalBalance = 8000000000000001
38+
, byronTotalBalance = 8_000_000_001 -- 8 billions. Should be smaller than 'cardanoMaxSupply' in Testnet.Start.Types
3839
}
3940

4041
-- TODO: We should not abuse the byron testnet options for genesis creation.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ cardanoTestnet
333333
forM_ (zip [1..] portNumbers) $ \(i, portNumber) -> do
334334
let iStr = printf "%03d" (i - 1)
335335
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegate-keys." <> iStr <> ".key") (tmpAbsPath </> poolKeyDir i </> "byron-delegate.key")
336-
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </>"byron-delegation.cert")
336+
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </> "byron-delegation.cert")
337337
H.writeFile (tmpAbsPath </> poolKeyDir i </> "port") (show portNumber)
338338

339339
-- Make topology files

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ data CardanoTestnetOptions = CardanoTestnetOptions
4343
, cardanoSlotLength :: Double -- ^ Slot length, in seconds
4444
, cardanoTestnetMagic :: Int
4545
, cardanoActiveSlotsCoeff :: Double
46-
, cardanoMaxSupply :: Word64 -- ^ The amount of ADA you are starting your testnet with
46+
, cardanoMaxSupply :: Word64 -- ^ The amount of ADA you are starting your testnet with (forwarded to shelley genesis)
4747
, cardanoEnableP2P :: Bool
4848
, cardanoNodeLoggingFormat :: NodeLoggingFormat
4949
, cardanoNumDReps :: Int -- ^ The number of DReps to generate at creation
@@ -57,7 +57,7 @@ cardanoDefaultTestnetOptions = CardanoTestnetOptions
5757
, cardanoSlotLength = 0.1
5858
, cardanoTestnetMagic = 42
5959
, cardanoActiveSlotsCoeff = 0.05
60-
, cardanoMaxSupply = 10_020_000_000
60+
, cardanoMaxSupply = 100_020_000_000 -- 100 billions. This amount should be bigger than the 'byronTotalBalance' in Testnet.Start.Byron
6161
, cardanoEnableP2P = False
6262
, cardanoNodeLoggingFormat = NodeLoggingFormatAsJson
6363
, cardanoNumDReps = 3

0 commit comments

Comments
 (0)