Skip to content
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

Update cardano-node after addition of the new BulkSync implementation #5942

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 18 additions & 6 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import Cardano.Tracing.OrphanInstances.Network ()
import Ouroboros.Consensus.Mempool (MempoolCapacityBytes (..),
MempoolCapacityBytesOverride (..))
import qualified Ouroboros.Consensus.Node as Consensus (NetworkP2PMode (..))
import Ouroboros.Consensus.Node.Genesis (GenesisConfig,
GenesisConfigFlags (..), defaultGenesisConfigFlags, mkGenesisConfig)
import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy (NumOfDiskSnapshots (..),
SnapshotInterval (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..), DiffusionMode (..))
Expand Down Expand Up @@ -163,8 +165,8 @@ data NodeConfiguration
-- Enable Peer Sharing
, ncPeerSharing :: PeerSharing

-- Enable Genesis syncing protocol
, ncEnableGenesis :: Bool
-- Genesis syncing protocol configuration
, ncGenesisConfig :: GenesisConfig
} deriving (Eq, Show)


Expand Down Expand Up @@ -230,7 +232,8 @@ data PartialNodeConfiguration
, pncPeerSharing :: !(Last PeerSharing)

-- Genesis syncing protocol
, pncEnableGenesis :: !(Last Bool)
, pncEnableGenesis :: !(Last Bool)
, pncGenesisConfigFlags :: !(Last GenesisConfigFlags)
} deriving (Eq, Generic, Show)

instance AdjustFilePaths PartialNodeConfiguration where
Expand Down Expand Up @@ -329,7 +332,8 @@ instance FromJSON PartialNodeConfiguration where

-- Genesis syncing protocol
-- DISABLED BY DEFAULT
pncEnableGenesis <- Last <$> v .:? "EnableGenesis" .!= Just False
pncEnableGenesis <- Last <$> v .:? "EnableGenesis" .!= Just False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two configuration values? If the genesis config plans aren't present then we know to not enable it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, what would you prefer instead? Something like

Genesis:
  Enable: True
  # optionally
  LowLevelOptions: 
    ....

?

pncGenesisConfigFlags <- Last <$> v .:? "LowLevelGenesisOptions"

pure PartialNodeConfiguration {
pncProtocolConfig
Expand Down Expand Up @@ -366,6 +370,7 @@ instance FromJSON PartialNodeConfiguration where
, pncEnableP2P
, pncPeerSharing
, pncEnableGenesis
, pncGenesisConfigFlags
}
where
parseMempoolCapacityBytesOverride v = parseNoOverride <|> parseOverride
Expand Down Expand Up @@ -543,6 +548,7 @@ defaultPartialNodeConfiguration =
, pncEnableP2P = Last (Just EnabledP2PMode)
, pncPeerSharing = Last (Just PeerSharingDisabled)
, pncEnableGenesis = Last (Just False)
, pncGenesisConfigFlags = Last (Just defaultGenesisConfigFlags)
}

lastOption :: Parser a -> Parser (Last a)
Expand Down Expand Up @@ -608,10 +614,16 @@ makeNodeConfiguration pnc = do
lastToEither "Missing PeerSharing"
$ pncPeerSharing pnc

ncEnableGenesis <-
enableGenesis <-
lastToEither "Missing EnableGenesis"
$ pncEnableGenesis pnc

mGenesisConfigFlags <- if enableGenesis
then fmap Just <$>
lastToEither "Missing GenesisConfigFlags"
$ pncGenesisConfigFlags pnc
else pure Nothing

-- TODO: This is not mandatory
experimentalProtocols <-
lastToEither "Missing ExperimentalProtocolsEnabled" $
Expand Down Expand Up @@ -659,7 +671,7 @@ makeNodeConfiguration pnc = do
EnabledP2PMode -> SomeNetworkP2PMode Consensus.EnabledP2PMode
DisabledP2PMode -> SomeNetworkP2PMode Consensus.DisabledP2PMode
, ncPeerSharing
, ncEnableGenesis
, ncGenesisConfig = mkGenesisConfig mGenesisConfigFlags
}

ncProtocol :: NodeConfiguration -> Protocol
Expand Down
13 changes: 13 additions & 0 deletions cardano-node/src/Cardano/Node/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Cardano.Node.Orphans () where

import Cardano.Api ()

import Ouroboros.Consensus.Node.Genesis (GenesisConfigFlags (..))
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..))
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))

Expand Down Expand Up @@ -38,3 +39,15 @@ instance FromJSON AcceptedConnectionsLimit where
<$> v .: "hardLimit"
<*> v .: "softLimit"
<*> v .: "delay"

instance FromJSON GenesisConfigFlags where
parseJSON = withObject "GenesisConfigFlags" $ \v ->
GenesisConfigFlags
<$> v .:? "EnableCSJ" .!= True
<*> v .:? "EnableLoEAndGDD" .!= True
<*> v .:? "EnableLoP" .!= True
<*> v .:? "BulkSyncGracePeriod"
<*> v .:? "BucketCapacity"
<*> v .:? "BucketRate"
<*> v .:? "CSJJumpSize"
<*> v .:? "GDDRateLimit"
1 change: 1 addition & 0 deletions cardano-node/src/Cardano/Node/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ nodeRunParser = do
, pncEnableP2P = mempty
, pncPeerSharing = mempty
, pncEnableGenesis = mempty
, pncGenesisConfigFlags = mempty
}

parseSocketPath :: Text -> Parser SocketPath
Expand Down
8 changes: 2 additions & 6 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
, rnEnableP2P = p2pMode
, rnPeerSharing = ncPeerSharing nc
, rnGetUseBootstrapPeers = readTVar useBootstrapVar
, rnGenesisConfig = if ncEnableGenesis nc
then Genesis.enableGenesisConfigDefault
else Genesis.disableGenesisConfig
, rnGenesisConfig = ncGenesisConfig nc
}
#ifdef UNIX
-- initial `SIGHUP` handler, which only rereads the topology file but
Expand Down Expand Up @@ -565,9 +563,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
, rnEnableP2P = p2pMode
, rnPeerSharing = ncPeerSharing nc
, rnGetUseBootstrapPeers = pure DontUseBootstrapPeers
, rnGenesisConfig = if ncEnableGenesis nc
then Genesis.enableGenesisConfigDefault
else Genesis.disableGenesisConfig
, rnGenesisConfig = ncGenesisConfig nc
}
#ifdef UNIX
-- initial `SIGHUP` handler; it only warns that neither updating of
Expand Down
13 changes: 13 additions & 0 deletions configuration/cardano/mainnet-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,16 @@ hasPrometheus:
# Examples:
# MempoolCapacityBytesOverride: 1000000 (1MB)
# MempoolCapacityBytesOverride: NoOverride (default)

# # Enable or disable the Genesis syncing algorithm
# # All values are set to their default.
# EnableGenesis: False
# LowLevelGenesisOptions:
# EnableCSJ: True
# EnableLoEAndGDD: True
# EnableLoP: True
# BulkSyncGracePeriod: 10 # seconds
# BucketCapacity: 100000 # tokens
# BucketRate: 500 # tokens per second
# CSJJumpSize: 4320 # slots. This value is 2*k
# GDDRateLimit: 1.0 # seconds
Loading