Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
[CDEC-509] Remove CoreConfiguration and update configuration.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhatch committed Sep 11, 2018
1 parent 42a9b8e commit 88e42a2
Show file tree
Hide file tree
Showing 7 changed files with 14,708 additions and 14,763 deletions.
16 changes: 6 additions & 10 deletions core/src/Pos/Core/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Pos.Core.Configuration
, configFtsSeed

, ConfigurationError (..)
, withCoreConfigurations
, configFromGenesisConfig
, mkConfig

, canonicalGenesisJson
Expand Down Expand Up @@ -157,20 +157,19 @@ prettyGenesisJson theGenesisData =
--
-- If the configuration gives a testnet genesis spec, then a start time must
-- be provided, probably sourced from command line arguments.
withCoreConfigurations
configFromGenesisConfig
:: (MonadThrow m, MonadIO m)
=> CoreConfiguration
-- ^ Update @'GenesisData'@ before passing its parts to @'given'@.
-> FilePath
=> FilePath
-- ^ Directory where 'configuration.yaml' is stored.
-> Maybe Timestamp
-- ^ Optional system start time.
-- It must be given when the genesis spec uses a testnet initializer.
-> Maybe Integer
-- ^ Optional seed which overrides one from testnet initializer if
-- provided.
-> GenesisConfiguration
-> m Config
withCoreConfigurations conf confDir mSystemStart mSeed = case ccGenesis conf of
configFromGenesisConfig confDir mSystemStart mSeed = \case
-- If a 'GenesisData' source file is given, we check its hash against the
-- given expected hash, parse it, and use the GenesisData to fill in all of
-- the obligations.
Expand Down Expand Up @@ -225,10 +224,7 @@ withCoreConfigurations conf confDir mSystemStart mSeed = case ccGenesis conf of

pure $ mkConfig theSystemStart theSpec

mkConfig
:: Timestamp
-> GenesisSpec
-> Config
mkConfig :: Timestamp -> GenesisSpec -> Config
mkConfig theSystemStart spec = Config
{ configProtocolMagic = pm
, configProtocolConstants = pc
Expand Down
19 changes: 1 addition & 18 deletions core/src/Pos/Core/Configuration/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
{-# LANGUAGE Rank2Types #-}

module Pos.Core.Configuration.Core
(
-- * The configuration structure
CoreConfiguration(..)
, GenesisConfiguration(..)
( GenesisConfiguration(..)
) where

import Prelude
Expand All @@ -15,7 +12,6 @@ import Data.Aeson (FromJSON, ToJSON, Value (..), genericToEncoding,
pairs, parseJSON, toEncoding, (.:))
import Data.Aeson.Encoding (pairStr)
import Data.Aeson.Options (defaultOptions)
import Data.Aeson.TH (deriveJSON)
import Data.Aeson.Types (typeMismatch)
import qualified Data.HashMap.Strict as HM
import Data.Monoid ((<>))
Expand Down Expand Up @@ -97,16 +93,3 @@ instance FromJSON GenesisConfiguration where
| otherwise = fail "Incorrect JSON encoding for GenesisConfiguration"

parseJSON invalid = typeMismatch "GenesisConfiguration" invalid

data CoreConfiguration = CoreConfiguration
{
-- | Specifies the genesis
ccGenesis :: !GenesisConfiguration

-- | Versioning for values in node's DB
, ccDbSerializeVersion :: !Word8

}
deriving (Show, Generic)

deriveJSON defaultOptions ''CoreConfiguration
16 changes: 3 additions & 13 deletions core/test/Test/Pos/Core/Dummy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Test.Pos.Core.Dummy
, dummyGenesisSecretKeysPoor
, dummyGenesisSecretsRich
, dummyGenesisSecretsPoor
, dummyCoreConfiguration
, dummyGenesisSpec
, dummyBlockVersionData
, dummyGenesisData
Expand All @@ -26,11 +25,9 @@ module Test.Pos.Core.Dummy

import Universum

import Pos.Core (BlockCount, Coeff (..), Config (..),
CoreConfiguration (..), EpochIndex (..),
GenesisConfiguration (..), GenesisHash (..),
ProtocolConstants (..), SharedSeed (..), SlotCount,
Timestamp, TxFeePolicy (..), TxSizeLinear (..),
import Pos.Core (BlockCount, Coeff (..), Config (..), EpochIndex (..),
GenesisHash (..), ProtocolConstants (..), SharedSeed (..),
SlotCount, Timestamp, TxFeePolicy (..), TxSizeLinear (..),
VssMaxTTL (..), VssMinTTL (..), kEpochSlots,
kSlotSecurityParam, mkConfig, pcBlkSecurityParam,
unsafeCoinPortionFromDouble)
Expand Down Expand Up @@ -94,13 +91,6 @@ dummyGenesisSecretKeysRich = gsSecretKeysRich dummyGeneratedSecrets
dummyGenesisSecretKeysPoor :: [SecretKey]
dummyGenesisSecretKeysPoor = gsSecretKeysPoor dummyGeneratedSecrets

dummyCoreConfiguration :: CoreConfiguration
dummyCoreConfiguration =
CoreConfiguration (GCSpec dummyGenesisSpec) dummyDbSerializeVersion

dummyDbSerializeVersion :: Word8
dummyDbSerializeVersion = 0

dummyGenesisSpec :: GenesisSpec
dummyGenesisSpec = UnsafeGenesisSpec
dummyGenesisAvvmBalances
Expand Down
14 changes: 2 additions & 12 deletions core/test/Test/Pos/Core/Gen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module Test.Pos.Core.Gen

-- Pos.Core.Configuration Generators
, genGenesisConfiguration
, genCoreConfiguration

-- Pos.Core.Delegation Generators
, genDlgPayload
Expand Down Expand Up @@ -137,8 +136,8 @@ import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..),
StakesMap, TxFeePolicy (..), TxSizeLinear (..),
coinPortionDenominator, makeAddress, maxCoinVal,
mkMultiKeyDistr)
import Pos.Core.Configuration (CoreConfiguration (..),
GenesisConfiguration (..), GenesisHash (..))
import Pos.Core.Configuration (GenesisConfiguration (..),
GenesisHash (..))
import Pos.Core.Delegation (DlgPayload (..), HeavyDlgIndex (..),
LightDlgIndices (..), ProxySKBlockInfo, ProxySKHeavy)
import Pos.Core.Genesis (FakeAvvmOptions (..),
Expand Down Expand Up @@ -337,12 +336,6 @@ genGenesisConfiguration pm =
, GCSpec <$> genGenesisSpec pm
]

genCoreConfiguration :: ProtocolMagic -> Gen CoreConfiguration
genCoreConfiguration pm =
CoreConfiguration
<$> genGenesisConfiguration pm
<*> genWord8

----------------------------------------------------------------------------
-- Pos.Core.Delegation Generators
----------------------------------------------------------------------------
Expand Down Expand Up @@ -776,9 +769,6 @@ genMicrosecond = fromMicroseconds <$> Gen.integral (Range.constant 0 1000000)
genWord32 :: Gen Word32
genWord32 = Gen.word32 Range.constantBounded

genWord8 :: Gen Word8
genWord8 = Gen.word8 Range.constantBounded

genWord16 :: Gen Word16
genWord16 = Gen.word16 Range.constantBounded

Expand Down
Loading

0 comments on commit 88e42a2

Please sign in to comment.