Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 1 addition & 8 deletions node/src/ChainwebNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,7 @@ node conf logger = do
rocksDbDir <- getRocksDbDir conf
pactDbDir <- getPactDbDir conf
dbBackupsDir <- getBackupsDir conf
withRocksDb' <-
if _configReadOnlyReplay cwConf
then
withReadOnlyRocksDb <$ logFunctionText logger Info "Opening RocksDB in read-only mode"
else
return withRocksDb
withRocksDb' rocksDbDir modernDefaultOptions $ \rocksDb -> do
withRocksDb rocksDbDir modernDefaultOptions $ \rocksDb -> do
logFunctionText logger Info $ "opened rocksdb in directory " <> sshow rocksDbDir
logFunctionText logger Debug $ "backup config: " <> sshow (_configBackup cwConf)
withChainweb cwConf logger rocksDb pactDbDir dbBackupsDir $ \case
Expand Down Expand Up @@ -370,7 +364,6 @@ baseBackend
let !txFailureHandler =
if isJust (_cutInitialCutFile (_configCuts chainwebCfg))
|| isJust (_cutInitialBlockHeightLimit (_configCuts chainwebCfg))
|| _configReadOnlyReplay chainwebCfg
then [dropLogHandler (Proxy :: Proxy PactTxFailureLog)]
else []

Expand Down
125 changes: 36 additions & 89 deletions src/Chainweb/Chainweb.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
{ _cutDbParamsLogLevel = Info
, _cutDbParamsTelemetryLevel = Info
, _cutDbParamsInitialHeightLimit = _cutInitialBlockHeightLimit cutConf
, _cutDbParamsReadOnly = _configReadOnlyReplay conf
, _cutDbParamsReadOnly = False
, _cutDbParamsInitialCutFile = _cutInitialCutFile cutConf
}
where
Expand Down Expand Up @@ -388,94 +388,41 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
putPeerThrottler <- mkPutPeerThrottler $ _throttlingPeerRate throt
mempoolThrottler <- mkMempoolThrottler $ _throttlingMempoolRate throt
logg Debug "initialized throttlers"

-- synchronize pact dbs with latest cut before we start the server
-- and clients and begin mining.
--
-- This is a consistency check that validates the blocks in the
-- current cut. If it fails an exception is raised. Also, if it
-- takes long (for example, when doing a reset to a prior block
-- height) we want this to happen before we go online.
--
let
-- pactSyncChains =
-- case _configSyncPactChains conf of
-- Just syncChains
-- | _configReadOnlyReplay conf
-- -> HM.filterWithKey (\k _ -> elem k syncChains) cs
-- _ -> cs

if _configReadOnlyReplay conf
then do
-- FIXME implement replay in payload provider
error "Chainweb.Chainweb.withChainwebInternal: pact replay is not supported"
-- logFunctionJson logger Info PactReplayInProgress
-- -- note that we don't use the "initial cut" from cutdb because its height depends on initialBlockHeightLimit.
-- highestCut <-
-- unsafeMkCut v <$> readHighestCutHeaders v (logFunctionText logger) webchain (cutHashesTable rocksDb)
-- lowerBoundCut <-
-- tryLimitCut webchain (fromMaybe 0 $ _cutInitialBlockHeightLimit $ _configCuts conf) highestCut
-- upperBoundCut <- forM (_cutFastForwardBlockHeightLimit $ _configCuts conf) $ \upperBound ->
-- tryLimitCut webchain upperBound highestCut
-- let
-- replayOneChain :: (ChainResources logger, (BlockHeader, Maybe BlockHeader)) -> IO ()
-- replayOneChain (cr, (l, u)) = do
-- let chainPact = _chainResPact cr
-- let logCr = logFunctionText
-- $ addLabel ("component", "pact")
-- $ addLabel ("sub-component", "init")
-- $ _chainResLogger cr
-- void $ _pactReadOnlyReplay chainPact l u
-- logCr Info "pact db synchronized"
-- let bounds =
-- HM.intersectionWith (,)
-- pactSyncChains
-- (HM.mapWithKey
-- (\cid bh ->
-- (bh, (HM.! cid) . _cutMap <$> upperBoundCut))
-- (_cutMap lowerBoundCut)
-- )
-- mapConcurrently_ replayOneChain bounds
-- logg Info "finished fast forward replay"
-- logFunctionJson logger Info PactReplaySuccessful
-- inner $ Replayed lowerBoundCut upperBoundCut
else do
logg Debug "start initializing miner resources"
logFunctionJson logger Info InitializingMinerResources

withMiningCoordination mLogger mConf mCutDb $ \mc ->

-- Miner resources are used by the test-miner when in-node
-- mining is configured or by the mempool noop-miner (which
-- keeps the mempool updated) in production setups.
--
withMinerResources mLogger (_miningInNode mConf) cs mCutDb mc $ \m -> do
logFunctionJson logger Info ChainwebStarted
logg Debug "finished initializing miner resources"
let !haddr = _peerConfigAddr $ _p2pConfigPeer $ _configP2p conf
inner $ StartedChainweb Chainweb
{ _chainwebHostAddress = haddr
, _chainwebChains = cs
, _chainwebCutResources = cutResources
, _chainwebMiner = m
, _chainwebCoordinator = mc
, _chainwebLogger = logger
, _chainwebPeer = peerRes
, _chainwebManager = mgr
-- , _chainwebPactData = pactData
, _chainwebThrottler = throttler
, _chainwebPutPeerThrottler = putPeerThrottler
, _chainwebMempoolThrottler = mempoolThrottler
, _chainwebConfig = conf
, _chainwebServiceSocket = serviceSock
, _chainwebBackup = BackupEnv
{ _backupRocksDb = rocksDb
, _backupDir = backupDir
, _backupPactDbDir = defaultPactDbDir
, _backupChainIds = cids
, _backupLogger = backupLogger
}
}
logg Debug "start initializing miner resources"
logFunctionJson logger Info InitializingMinerResources

withMiningCoordination mLogger mConf mCutDb $ \mc ->

-- Miner resources are used by the test-miner when in-node
-- mining is configured or by the mempool noop-miner (which
-- keeps the mempool updated) in production setups.
--
withMinerResources mLogger (_miningInNode mConf) cs mCutDb mc $ \m -> do
logFunctionJson logger Info ChainwebStarted
logg Debug "finished initializing miner resources"
let !haddr = _peerConfigAddr $ _p2pConfigPeer $ _configP2p conf
inner $ StartedChainweb Chainweb
{ _chainwebHostAddress = haddr
, _chainwebChains = cs
, _chainwebCutResources = cutResources
, _chainwebMiner = m
, _chainwebCoordinator = mc
, _chainwebLogger = logger
, _chainwebPeer = peerRes
, _chainwebManager = mgr
, _chainwebThrottler = throttler
, _chainwebPutPeerThrottler = putPeerThrottler
, _chainwebMempoolThrottler = mempoolThrottler
, _chainwebConfig = conf
, _chainwebServiceSocket = serviceSock
, _chainwebBackup = BackupEnv
{ _backupRocksDb = rocksDb
, _backupDir = backupDir
, _backupPactDbDir = defaultPactDbDir
, _backupChainIds = cids
, _backupLogger = backupLogger
}
}

-- synchronizePactDb :: HM.HashMap ChainId (ChainResources logger) -> Cut -> IO ()
-- synchronizePactDb cs targetCut = do
Expand Down
25 changes: 0 additions & 25 deletions src/Chainweb/Chainweb/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ module Chainweb.Chainweb.Configuration
, configReorgLimit
, configBackup
, configServiceApi
, configReadOnlyReplay
, configSyncChains
, configPayloadProviders
, defaultChainwebConfiguration
, pChainwebConfiguration
Expand Down Expand Up @@ -553,16 +551,6 @@ data ChainwebConfiguration = ChainwebConfiguration
, _configPayloadProviders :: PayloadProviderConfig
, _configPrune :: !PruneConfig

-- The following properties are deprecated: history replay should not be
-- part of normal operation mode. It should probably use a completely
-- separate configuration.

, _configReadOnlyReplay :: !Bool
-- ^ do a read-only replay using the cut db params for the block heights
, _configSyncChains :: !(Maybe [ChainId])
-- ^ the only chains to be synchronized on startup to the latest cut.
-- if unset, all chains will be synchronized.

} deriving (Show, Eq, Generic)

makeLenses ''ChainwebConfiguration
Expand Down Expand Up @@ -608,9 +596,7 @@ defaultChainwebConfiguration v = ChainwebConfiguration
, _configThrottling = defaultThrottlingConfig
, _configReorgLimit = defaultReorgLimit
, _configServiceApi = defaultServiceApiConfig
, _configReadOnlyReplay = False
, _configPrune = defaultPruneConfig
, _configSyncChains = Nothing
, _configBackup = defaultBackupConfig
, _configPayloadProviders = defaultPayloadProviderConfig
}
Expand All @@ -624,8 +610,6 @@ instance ToJSON ChainwebConfiguration where
, "throttling" .= _configThrottling o
, "reorgLimit" .= _configReorgLimit o
, "serviceApi" .= _configServiceApi o
, "readOnlyReplay" .= _configReadOnlyReplay o
, "syncChains" .= _configSyncChains o
, "backup" .= _configBackup o
, "payloadProviders" .= _configPayloadProviders o
, "pruning" .= _configPrune o
Expand All @@ -644,8 +628,6 @@ instance FromJSON (ChainwebConfiguration -> ChainwebConfiguration) where
<*< configThrottling %.: "throttling" % o
<*< configReorgLimit ..: "reorgLimit" % o
<*< configServiceApi %.: "serviceApi" % o
<*< configReadOnlyReplay ..: "readOnlyReplay" % o
<*< configSyncChains ..: "syncChains" % o
<*< configBackup %.: "backup" % o
<*< configPayloadProviders %.: "payloadProviders" % o
<*< configPrune %.: "pruning" % o
Expand All @@ -662,13 +644,6 @@ pChainwebConfiguration = id
<*< parserOptionGroup "Cut Processing" (configCuts %:: pCutConfig)
<*< parserOptionGroup "Service API" (configServiceApi %:: pServiceApiConfig)
<*< parserOptionGroup "Mining Coordination" (configMining %:: pMiningConfig)
<*< configReadOnlyReplay .:: boolOption_
% long "read-only-replay"
<> help "Replay the block history non-destructively"
<*< configSyncChains .:: fmap Just % jsonOption
% long "sync-chains"
<> help "The only Pact databases to synchronize. If empty or unset, all chains will be synchronized."
<> metavar "JSON list of chain ids"
<*< parserOptionGroup "Backup" (configBackup %:: pBackupConfig)

-- FIXME support payload providers
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.