Skip to content

Commit

Permalink
YAML version of mainnet config
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 5, 2021
1 parent 22a2ddc commit ec6ad20
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 52 deletions.
4 changes: 3 additions & 1 deletion cardano-cli/cardano-cli.cabal
Expand Up @@ -167,7 +167,8 @@ test-suite cardano-cli-test
main-is: cardano-cli-test.hs
type: exitcode-stdio-1.0

build-depends: bech32 >= 1.1.0
build-depends: aeson
, bech32 >= 1.1.0
, bytestring
, base16-bytestring
, cardano-api
Expand All @@ -184,6 +185,7 @@ test-suite cardano-cli-test
, parsec
, text
, transformers
, yaml

other-modules: Test.Config.Mainnet
Test.Cli.FilePermissions
Expand Down
26 changes: 22 additions & 4 deletions cardano-cli/test/Test/Config/Mainnet.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Test.Config.Mainnet
( tests
Expand All @@ -12,28 +13,45 @@ import Data.Bool (Bool(..))
import Data.Either (Either(..))
import Data.Function
import Data.Maybe
import Hedgehog (Property)
import Hedgehog (Property, (===))
import System.FilePath ((</>))
import System.IO (IO)
import Text.Show

import qualified Data.Aeson as J
import qualified Data.Text as T
import qualified Data.Yaml as Y
import qualified GHC.Stack as GHC
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified System.Directory as IO

hprop_configMainnet :: Property
hprop_configMainnet = H.propertyOnce $ do
hprop_configMainnetHash :: Property
hprop_configMainnetHash = H.propertyOnce $ do
projectBase <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase
result <- H.evalIO $ runExceptT $ initialLedgerState $ projectBase </> "configuration/cardano/mainnet-config.json"
case result of
Right (_, _) -> return ()
Left e -> H.failWithCustom GHC.callStack Nothing (T.unpack (renderInitialLedgerStateError e))

hprop_configMainnetYaml :: Property
hprop_configMainnetYaml = H.propertyOnce $ do
projectBase <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase
yamlResult <- H.evalIO . Y.decodeFileEither $ projectBase </> "configuration/cardano/mainnet-config.yaml"
yaml :: J.Value <- case yamlResult of
Right v -> return v
Left e -> H.failWithCustom GHC.callStack Nothing (Y.prettyPrintParseException e)
jsonResult <- H.evalIO . J.eitherDecodeFileStrict $ projectBase </> "configuration/cardano/mainnet-config.json"
json :: J.Value <- case jsonResult of
Right v -> return v
Left e -> H.failWithCustom GHC.callStack Nothing (show e)
yaml === json

tests :: IO Bool
tests =
H.checkSequential
$ H.Group "Test.Config.Mainnet"
[ ("hprop_configMainnet", hprop_configMainnet)
[ ("hprop_configMainnetHash", hprop_configMainnetHash)
, ("hprop_configMainnetYaml", hprop_configMainnetYaml)
]
98 changes: 51 additions & 47 deletions configuration/cardano/mainnet-config.yaml
@@ -1,51 +1,36 @@
##########################################################
############### Mainnet #########
############### Cardano Byron Node Configuration #########
##########################################################

################################################################################
# Mainnet Cardano Node Configuration

##### Locations #####

GenesisFile: genesis.json
SocketPath: db/node.socket

##### Blockfetch Protocol

# The maximum number of used peers during bulk sync.
MaxConcurrencyBulkSync: 1
# The maximum number of used peers when fetching newly forged blocks.
MaxConcurrencyDeadline: 2

#TODO: These parameters cannot yet be used in the config file, only on the CLI:
#DatabasePath: db/
#Topology: configuration/mainnet-topology.json
#Port 7776
AlonzoGenesisFile: mainnet-alonzo-genesis.json
AlonzoGenesisHash: 7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874
ByronGenesisFile: mainnet-byron-genesis.json
ByronGenesisHash: 5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb
ShelleyGenesisFile: mainnet-shelley-genesis.json
ShelleyGenesisHash: 1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81

##### Core protocol parameters #####

# This is the instance of the Ouroboros family that we are running.
# "RealPBFT" is the real (permissive) OBFT protocol, which is what we use on
# mainnet in Byron era.
Protocol: RealPBFT
Protocol: Cardano

# The mainnet does not include the network magic into addresses. Testnets do.
RequiresNetworkMagic: RequiresNoMagic


##### Update system parameters #####

# This protocol version number gets used by block producing nodes as part
# of the system for agreeing on and synchronising protocol updates.
LastKnownBlockVersion-Major: 0
LastKnownBlockVersion-Minor: 2
LastKnownBlockVersion-Major: 3
LastKnownBlockVersion-Minor: 0
LastKnownBlockVersion-Alt: 0
MaxKnownMajorProtocolVersion: 2

# In the Byron era some software versions are also published on the chain.
# We do this only for Byron compatibility now.
ApplicationName: cardano-sl
ApplicationVersion: 1


##### Logging configuration #####

# Enable or disable logging overall
Expand Down Expand Up @@ -78,7 +63,7 @@ defaultBackends:
# EKG is a simple metrics monitoring system. Uncomment the following to enable
# this backend and listen on the given local port and point your web browser to
# http://localhost:12788/
# hasEKG: 12788
hasEKG: 12788

# The Prometheus monitoring system exports EKG metrics. Uncomment the following
# to listen on the given port. Output is provided on
Expand Down Expand Up @@ -116,27 +101,22 @@ defaultBackends:
# The scribe output format can be ScText or ScJson. Log rotation settings can
# be specified in the defaults below or overidden on a per-scribe basis here.
setupScribes:
- scKind: FileSK
scName: "logs/mainnet.log"
scFormat: ScText

- scKind: StdoutSK
scName: stdout
scFormat: ScText
scRotation: null

# For the Katip logging backend this specifies the default scribes that trace
# output is sent to if it is not configured to be sent to other scribes.
defaultScribes:
- - FileSK
- "logs/mainnet.log"
- - StdoutSK
- stdout

# The default file rotation settings for katip scribes, unless overridden
# in the setupScribes above for specific scribes.
rotation:
rpLogLimitBytes: 5000000
rpKeepFilesNum: 3
rpKeepFilesNum: 10
rpMaxAgeHours: 24


Expand All @@ -146,6 +126,8 @@ rotation:
# settings. This provides fairly coarse grained control, but it is relatively
# efficient at filtering out unwanted trace output.

TraceAcceptPolicy: True

# Trace BlockFetch client.
TraceBlockFetchClient: False

Expand All @@ -162,7 +144,7 @@ TraceBlockFetchProtocolSerialised: False
TraceBlockFetchServer: False

# Trace BlockchainTime.
TraceBlockchainTime: False
# TraceBlockchainTime: False

# Verbose tracer of ChainDB
TraceChainDb: True
Expand All @@ -179,12 +161,16 @@ TraceChainSyncHeaderServer: False
# Trace ChainSync protocol messages.
TraceChainSyncProtocol: False

TraceConnectionManager: True

# Trace DNS Resolver messages.
TraceDNSResolver: True

# Trace DNS Subscription messages.
TraceDNSSubscription: True

TraceDiffusionInitialization: True

# Trace error policy resolution.
TraceErrorPolicy: True

Expand All @@ -200,6 +186,21 @@ TraceHandshake: False
# Trace IP Subscription messages.
TraceIpSubscription: True

TraceLedgerPeers: True

TraceLocalRootPeers: True

TraceInboundGovernor: True

TracePeerSelection: True

TracePeerSelectionActions: True

TracePublicRootPeers: True

TraceServer: True


# Trace local ChainSync protocol messages.
TraceLocalChainSyncProtocol: False

Expand Down Expand Up @@ -245,15 +246,18 @@ options:
cardano.node.metrics:
- EKGViewBK

# redirects traced values to a specific scribe which is identified by its
# type and its name, separated by "::":
mapScribes:
cardano.node.resources:
- EKGViewBK

# # redirects traced values to a specific scribe which is identified by its
# # type and its name, separated by "::":
# mapScribes:
# cardano.node.metrics:
# - "FileSK::logs/mainnet.log"
mapSubtrace:
cardano.node.metrics:
- "FileSK::logs/mainnet.log"

# apply a filter on message severity on messages in a specific named context.
# this filter is applied additionally to the global 'minSeverity' and thus
# needs to be at least as high.
mapSeverity:
cardano.node.ChainDB: Notice
cardano.node.DnsSubscription: Debug
subtrace: Neutral

hasPrometheus:
- 127.0.0.1
- 12798

0 comments on commit ec6ad20

Please sign in to comment.