Skip to content

Commit

Permalink
Merge #2170
Browse files Browse the repository at this point in the history
2170: New testnet fork point config r=newhoggy a=newhoggy



Co-authored-by: John Ky <[email protected]>
  • Loading branch information
iohk-bors[bot] and newhoggy authored Dec 7, 2020
2 parents 196ba71 + a07891e commit a6dc965
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cardano-node-chairman/src/Testnet/ByronShelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#endif

module Testnet.ByronShelley
( TestnetOptions(..)
( ForkPoint(..)
, TestnetOptions(..)
, defaultTestnetOptions

, testnet
Expand All @@ -37,6 +38,7 @@ import GHC.Real
import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket (..))
import Hedgehog.Extras.Stock.Time
import System.FilePath.Posix ((</>))
import Text.Read
import Text.Show

import qualified Data.Aeson as J
Expand Down Expand Up @@ -70,11 +72,17 @@ import qualified Testnet.Conf as H
{- HLINT ignore "Redundant <&>" -}
{- HLINT ignore "Redundant flip" -}

data ForkPoint
= AtVersion Int
| AtEpoch Int
deriving (Show, Eq, Read)

data TestnetOptions = TestnetOptions
{ numBftNodes :: Int
, numPoolNodes :: Int
, activeSlotsCoeff :: Double
, epochLength :: Int
, forkPoint :: ForkPoint
} deriving (Eq, Show)

defaultTestnetOptions :: TestnetOptions
Expand All @@ -83,6 +91,7 @@ defaultTestnetOptions = TestnetOptions
, numPoolNodes = 1
, activeSlotsCoeff = 0.1
, epochLength = 1500
, forkPoint = AtVersion 1
}

ifaceAddress :: String
Expand Down Expand Up @@ -150,9 +159,9 @@ testnet testnetOptions H.Conf {..} = do
H.createDirectoryIfMissing logDir

-- Choose one of the following fork methods:
forkMethod <- H.noteShow
["TestShelleyHardForkAtVersion: 1"]
-- ["TestShelleyHardForkAtEpoch: 1"]
forkMethod <- H.noteShow $ case forkPoint testnetOptions of
AtVersion n -> ["TestShelleyHardForkAtVersion: " <> show @Int n]
AtEpoch n -> ["TestShelleyHardForkAtEpoch: " <> show @Int n]

H.readFile (base </> "configuration/chairman/byron-shelley/configuration.yaml")
<&> L.unlines . (<> forkMethod) . L.lines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Options.Applicative
import System.IO (IO)
import Testnet.ByronShelley
import Testnet.Run (runTestnet)
import Text.Read (readEither)
import Text.Show

import qualified Options.Applicative as OA
Expand Down Expand Up @@ -52,6 +53,13 @@ optsTestnet = TestnetOptions
<> OA.showDefault
<> OA.value (epochLength defaultTestnetOptions)
)
<*> OA.option (OA.eitherReader readEither)
( OA.long "fork-point"
<> OA.help "Fork Point. Valid values are: 'AtVersion <n>' and 'AtEpoch <n>'"
<> OA.metavar "FORKPOINT"
<> OA.showDefault
<> OA.value (forkPoint defaultTestnetOptions)
)

optsByronShelley :: Parser ByronShelleyOptions
optsByronShelley = ByronShelleyOptions
Expand Down

0 comments on commit a6dc965

Please sign in to comment.