Skip to content

Small Byron genesis refactor in cardano-testnet #4818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ library
Testnet.Babbage
Testnet.Cardano
Testnet.Conf
Testnet.Genesis
Testnet.Run
Testnet.Shelley
Testnet.Utils
Expand Down
26 changes: 3 additions & 23 deletions cardano-testnet/src/Testnet/Babbage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import qualified Hedgehog.Extras.Test.File as H
import qualified System.Info as OS

import qualified Testnet.Conf as H
import Testnet.Genesis
import qualified Testnet.Util.Assert as H
import Testnet.Util.Process (execCli_)
import Testnet.Util.Runtime (Delegator (..), NodeLoggingFormat (..), PaymentKeyPair (..),
Expand Down Expand Up @@ -67,29 +68,8 @@ babbageTestnet :: BabbageTestnetOptions -> H.Conf -> H.Integration TestnetRuntim
babbageTestnet testnetOptions H.Conf {..} = do
H.createDirectoryIfMissing (tempAbsPath </> "logs")

H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json") . encode $ object
[ "heavyDelThd" .= ("300000000000" :: String)
, "maxBlockSize" .= ("2000000" :: String)
, "maxTxSize" .= ("4096" :: String)
, "maxHeaderSize" .= ("2000000" :: String)
, "maxProposalSize" .= ("700" :: String)
, "mpcThd" .= ("20000000000000" :: String)
, "scriptVersion" .= (0 :: Int)
, "slotDuration" .= show @Int (babbageSlotDuration testnetOptions)
, "unlockStakeEpoch" .= ("18446744073709551615" :: String)
, "updateImplicit" .= ("10000" :: String)
, "updateProposalThd" .= ("100000000000000" :: String)
, "updateVoteThd" .= ("1000000000000" :: String)
, "softforkRule" .= object
[ "initThd" .= ("900000000000000" :: String)
, "minThd" .= ("600000000000000" :: String)
, "thdDecrement" .= ("50000000000000" :: String)
]
, "txFeePolicy" .= object
[ "multiplier" .= ("43946000000" :: String)
, "summand" .= ("155381000000000" :: String)
]
]
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json")
. encode $ defaultByronGenesisJsonValue

void $ H.note OS.os
currentTime <- H.noteShowIO DTC.getCurrentTime
Expand Down
27 changes: 3 additions & 24 deletions cardano-testnet/src/Testnet/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Prelude
import Control.Monad
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Trans.Except
import Data.Aeson ((.=))
import qualified Data.Aeson as J
import qualified Data.ByteString as BS
import Data.ByteString.Lazy (ByteString)
Expand Down Expand Up @@ -65,6 +64,7 @@ import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Network as H

import qualified Testnet.Conf as H
import Testnet.Genesis
import qualified Testnet.Util.Assert as H
import qualified Testnet.Util.Process as H
import Testnet.Util.Process (execCli_)
Expand Down Expand Up @@ -280,29 +280,8 @@ cardanoTestnet testnetOptions H.Conf {..} = do

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

H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json") . J.encode $ J.object
[ "heavyDelThd" .= J.toJSON @String "300000000000"
, "maxBlockSize" .= J.toJSON @String "2000000"
, "maxTxSize" .= J.toJSON @String "4096"
, "maxHeaderSize" .= J.toJSON @String "2000000"
, "maxProposalSize" .= J.toJSON @String "700"
, "mpcThd" .= J.toJSON @String "20000000000000"
, "scriptVersion" .= J.toJSON @Int 0
, "slotDuration" .= J.toJSON @String "1000"
, "softforkRule" .= J.object
[ "initThd" .= J.toJSON @String "900000000000000"
, "minThd" .= J.toJSON @String "600000000000000"
, "thdDecrement" .= J.toJSON @String "50000000000000"
]
, "txFeePolicy" .= J.object
[ "multiplier" .= J.toJSON @String "43946000000"
, "summand" .= J.toJSON @String "155381000000000"
]
, "unlockStakeEpoch" .= J.toJSON @String "18446744073709551615"
, "updateImplicit" .= J.toJSON @String "10000"
, "updateProposalThd" .= J.toJSON @String "100000000000000"
, "updateVoteThd" .= J.toJSON @String "1000000000000"
]
H.lbsWriteFile (tempAbsPath </> "byron.genesis.spec.json")
. J.encode $ defaultByronGenesisJsonValue

-- stuff
execCli_
Expand Down
40 changes: 40 additions & 0 deletions cardano-testnet/src/Testnet/Genesis.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

-- | All Byron and Shelley Genesis related functionality
module Testnet.Genesis
( defaultByronGenesisJsonValue
) where

import Prelude

import Data.Aeson

-- | We need a Byron genesis in order to be able to hardfork to the later Shelley based eras.
-- The values here don't matter as the testnet conditions are ultimately determined
-- by the Shelley genesis.
defaultByronGenesisJsonValue :: Value
defaultByronGenesisJsonValue =
object
[ "heavyDelThd" .= toJSON @String "300000000000"
, "maxBlockSize" .= toJSON @String "2000000"
, "maxTxSize" .= toJSON @String "4096"
, "maxHeaderSize" .= toJSON @String "2000000"
, "maxProposalSize" .= toJSON @String "700"
, "mpcThd" .= toJSON @String "20000000000000"
, "scriptVersion" .= toJSON @Int 0
, "slotDuration" .= toJSON @String "1000"
, "softforkRule" .= object
[ "initThd" .= toJSON @String "900000000000000"
, "minThd" .= toJSON @String "600000000000000"
, "thdDecrement" .= toJSON @String "50000000000000"
]
, "txFeePolicy" .= object
[ "multiplier" .= toJSON @String "43946000000"
, "summand" .= toJSON @String "155381000000000"
]
, "unlockStakeEpoch" .= toJSON @String "18446744073709551615"
, "updateImplicit" .= toJSON @String "10000"
, "updateProposalThd" .= toJSON @String "100000000000000"
, "updateVoteThd" .= toJSON @String "1000000000000"
]