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 May 12, 2021
1 parent 89a3ef1 commit 489c91b
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 @@ -220,10 +220,14 @@ instance FromJSON PartialNodeConfiguration where
(Just _, Just _) -> fail $ "Specify either ShelleyGenesisFile"
++ "or GenesisFile, but not both"
npcShelleyGenesisFileHash <- v .:? "ShelleyGenesisHash"
npcStubComputeDuration <- fromMaybe 0.1 <$> v .:? "StubComputeDuration"
npcStubComputePrecision <- fromMaybe 0.01 <$> v .:? "StubComputePrecision"

pure NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile
, npcShelleyGenesisFileHash
, npcStubComputeDuration
, npcStubComputePrecision
}

parseHardForkProtocol 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)
import qualified Data.Text as T
Expand All @@ -27,6 +28,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.Orphans ()
import Cardano.Api.Protocol.Types
Expand Down Expand Up @@ -75,7 +77,9 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
}
NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile,
npcShelleyGenesisFileHash
npcShelleyGenesisFileHash,
npcStubComputeDuration,
npcStubComputePrecision
}
NodeHardForkProtocolConfiguration {
npcTestShelleyHardForkAtEpoch,
Expand All @@ -86,6 +90,11 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration {
npcTestMaryHardForkAtVersion
}
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 @@ -268,6 +268,8 @@ data NodeShelleyProtocolConfiguration =
NodeShelleyProtocolConfiguration {
npcShelleyGenesisFile :: !GenesisFile
, npcShelleyGenesisFileHash :: !(Maybe GenesisHash)
, npcStubComputeDuration :: !Double
, npcStubComputePrecision :: !Double
}
deriving (Eq, Show)

Expand Down

0 comments on commit 489c91b

Please sign in to comment.