Skip to content

Commit 51c08bc

Browse files
committed
Add Testnet.Genesis module and implement defaultByronGenesisJsonValue
1 parent 63a0c54 commit 51c08bc

File tree

4 files changed

+47
-47
lines changed

4 files changed

+47
-47
lines changed

cardano-testnet/cardano-testnet.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ library
8080
Testnet.Babbage
8181
Testnet.Cardano
8282
Testnet.Conf
83+
Testnet.Genesis
8384
Testnet.Run
8485
Testnet.Shelley
8586
Testnet.Utils

cardano-testnet/src/Testnet/Babbage.hs

+3-23
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import qualified Hedgehog.Extras.Test.File as H
3232
import qualified System.Info as OS
3333

3434
import qualified Testnet.Conf as H
35+
import Testnet.Genesis
3536
import qualified Testnet.Util.Assert as H
3637
import Testnet.Util.Process (execCli_)
3738
import Testnet.Util.Runtime (Delegator (..), NodeLoggingFormat (..), PaymentKeyPair (..),
@@ -67,29 +68,8 @@ babbageTestnet :: BabbageTestnetOptions -> H.Conf -> H.Integration TestnetRuntim
6768
babbageTestnet testnetOptions H.Conf {..} = do
6869
H.createDirectoryIfMissing (tempAbsPath </> "logs")
6970

70-
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json") . encode $ object
71-
[ "heavyDelThd" .= ("300000000000" :: String)
72-
, "maxBlockSize" .= ("2000000" :: String)
73-
, "maxTxSize" .= ("4096" :: String)
74-
, "maxHeaderSize" .= ("2000000" :: String)
75-
, "maxProposalSize" .= ("700" :: String)
76-
, "mpcThd" .= ("20000000000000" :: String)
77-
, "scriptVersion" .= (0 :: Int)
78-
, "slotDuration" .= show @Int (babbageSlotDuration testnetOptions)
79-
, "unlockStakeEpoch" .= ("18446744073709551615" :: String)
80-
, "updateImplicit" .= ("10000" :: String)
81-
, "updateProposalThd" .= ("100000000000000" :: String)
82-
, "updateVoteThd" .= ("1000000000000" :: String)
83-
, "softforkRule" .= object
84-
[ "initThd" .= ("900000000000000" :: String)
85-
, "minThd" .= ("600000000000000" :: String)
86-
, "thdDecrement" .= ("50000000000000" :: String)
87-
]
88-
, "txFeePolicy" .= object
89-
[ "multiplier" .= ("43946000000" :: String)
90-
, "summand" .= ("155381000000000" :: String)
91-
]
92-
]
71+
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json")
72+
. encode $ defaultByronGenesisJsonValue
9373

9474
void $ H.note OS.os
9575
currentTime <- H.noteShowIO DTC.getCurrentTime

cardano-testnet/src/Testnet/Cardano.hs

+3-24
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import Prelude
2626
import Control.Monad
2727
import Control.Monad.IO.Class (MonadIO, liftIO)
2828
import Control.Monad.Trans.Except
29-
import Data.Aeson ((.=))
3029
import qualified Data.Aeson as J
3130
import qualified Data.ByteString as BS
3231
import Data.ByteString.Lazy (ByteString)
@@ -65,6 +64,7 @@ import qualified Hedgehog.Extras.Test.File as H
6564
import qualified Hedgehog.Extras.Test.Network as H
6665

6766
import qualified Testnet.Conf as H
67+
import Testnet.Genesis
6868
import qualified Testnet.Util.Assert as H
6969
import qualified Testnet.Util.Process as H
7070
import Testnet.Util.Process (execCli_)
@@ -280,29 +280,8 @@ cardanoTestnet testnetOptions H.Conf {..} = do
280280

281281
H.writeFile (tempAbsPath </> node </> "port") (show port)
282282

283-
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json") . J.encode $ J.object
284-
[ "heavyDelThd" .= J.toJSON @String "300000000000"
285-
, "maxBlockSize" .= J.toJSON @String "2000000"
286-
, "maxTxSize" .= J.toJSON @String "4096"
287-
, "maxHeaderSize" .= J.toJSON @String "2000000"
288-
, "maxProposalSize" .= J.toJSON @String "700"
289-
, "mpcThd" .= J.toJSON @String "20000000000000"
290-
, "scriptVersion" .= J.toJSON @Int 0
291-
, "slotDuration" .= J.toJSON @String "1000"
292-
, "softforkRule" .= J.object
293-
[ "initThd" .= J.toJSON @String "900000000000000"
294-
, "minThd" .= J.toJSON @String "600000000000000"
295-
, "thdDecrement" .= J.toJSON @String "50000000000000"
296-
]
297-
, "txFeePolicy" .= J.object
298-
[ "multiplier" .= J.toJSON @String "43946000000"
299-
, "summand" .= J.toJSON @String "155381000000000"
300-
]
301-
, "unlockStakeEpoch" .= J.toJSON @String "18446744073709551615"
302-
, "updateImplicit" .= J.toJSON @String "10000"
303-
, "updateProposalThd" .= J.toJSON @String "100000000000000"
304-
, "updateVoteThd" .= J.toJSON @String "1000000000000"
305-
]
283+
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json")
284+
. J.encode $ defaultByronGenesisJsonValue
306285

307286
-- stuff
308287
execCli_
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
{-# LANGUAGE TypeApplications #-}
3+
4+
-- | All Byron and Shelley Genesis related functionality
5+
module Testnet.Genesis
6+
( defaultByronGenesisJsonValue
7+
) where
8+
9+
import Prelude
10+
11+
import Data.Aeson
12+
13+
-- | We need a Byron genesis in order to be able to hardfork to the later Shelley based eras.
14+
-- The values here don't matter as the testnet conditions are ultimately determined
15+
-- by the Shelley genesis.
16+
defaultByronGenesisJsonValue :: Value
17+
defaultByronGenesisJsonValue =
18+
object
19+
[ "heavyDelThd" .= toJSON @String "300000000000"
20+
, "maxBlockSize" .= toJSON @String "2000000"
21+
, "maxTxSize" .= toJSON @String "4096"
22+
, "maxHeaderSize" .= toJSON @String "2000000"
23+
, "maxProposalSize" .= toJSON @String "700"
24+
, "mpcThd" .= toJSON @String "20000000000000"
25+
, "scriptVersion" .= toJSON @Int 0
26+
, "slotDuration" .= toJSON @String "1000"
27+
, "softforkRule" .= object
28+
[ "initThd" .= toJSON @String "900000000000000"
29+
, "minThd" .= toJSON @String "600000000000000"
30+
, "thdDecrement" .= toJSON @String "50000000000000"
31+
]
32+
, "txFeePolicy" .= object
33+
[ "multiplier" .= toJSON @String "43946000000"
34+
, "summand" .= toJSON @String "155381000000000"
35+
]
36+
, "unlockStakeEpoch" .= toJSON @String "18446744073709551615"
37+
, "updateImplicit" .= toJSON @String "10000"
38+
, "updateProposalThd" .= toJSON @String "100000000000000"
39+
, "updateVoteThd" .= toJSON @String "1000000000000"
40+
]

0 commit comments

Comments
 (0)