Skip to content

Commit

Permalink
CAD-2907 stub compute: calibrate at startup, with configurable targets
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire committed Jun 18, 2021
1 parent 711bb77 commit f0eb0d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cardano-node/src/Cardano/Node/Configuration/POM.hs
Expand Up @@ -237,10 +237,14 @@ instance FromJSON PartialNodeConfiguration where
(Just _, Just _) -> fail $ "Specify either ShelleyGenesisFile"
++ "or GenesisFile, but not both"
npcShelleyGenesisFileHash <- v .:? "ShelleyGenesisHash"
npcStubComputeDuration <- fromMaybe 0.05 <$> v .:? "StubComputeDuration"
npcStubComputePrecision <- fromMaybe 0.005 <$> v .:? "StubComputePrecision"

pure NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile
, npcShelleyGenesisFileHash
, npcStubComputeDuration
, npcStubComputePrecision
}

parseAlonzoProtocol v = do
Expand Down
11 changes: 10 additions & 1 deletion cardano-node/src/Cardano/Node/Protocol/Cardano.hs
Expand Up @@ -15,6 +15,7 @@ module Cardano.Node.Protocol.Cardano

import Prelude

import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (firstExceptT)

Expand All @@ -26,6 +27,7 @@ import qualified Ouroboros.Consensus.Cardano.CanHardFork as Consensus
import Ouroboros.Consensus.HardFork.Combinator.Condense ()

import Ouroboros.Consensus.Cardano.Condense ()
import Ouroboros.Consensus.Shelley.Ledger.Stub

import Cardano.Api
import Cardano.Api.Orphans ()
Expand Down Expand Up @@ -77,7 +79,9 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
}
NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile,
npcShelleyGenesisFileHash
npcShelleyGenesisFileHash,
npcStubComputeDuration,
npcStubComputePrecision
}
NodeAlonzoProtocolConfiguration {
npcAlonzoGenesisFile,
Expand All @@ -95,6 +99,11 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcTestAlonzoHardForkAtVersion
}
files = do
liftIO $
calibrateStubComputationArgForTime
npcStubComputeDuration
npcStubComputePrecision

byronGenesis <-
firstExceptT CardanoProtocolInstantiationErrorByron $
Byron.readGenesis npcByronGenesisFile
Expand Down
2 changes: 2 additions & 0 deletions cardano-node/src/Cardano/Node/Types.hs
Expand Up @@ -270,6 +270,8 @@ data NodeShelleyProtocolConfiguration =
NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile :: !GenesisFile
, npcShelleyGenesisFileHash :: !(Maybe GenesisHash)
, npcStubComputeDuration :: !Double
, npcStubComputePrecision :: !Double
}
deriving (Eq, Show)

Expand Down

0 comments on commit f0eb0d3

Please sign in to comment.