Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 7122976

Browse files
committed
Delete some now-unused replay options from cw-node
Change-Id: Id000000068eb15bd1ff51bc3590ac087c73da495
1 parent e05488d commit 7122976

File tree

3 files changed

+37
-122
lines changed

3 files changed

+37
-122
lines changed

node/src/ChainwebNode.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,7 @@ node conf logger = do
319319
rocksDbDir <- getRocksDbDir conf
320320
pactDbDir <- getPactDbDir conf
321321
dbBackupsDir <- getBackupsDir conf
322-
withRocksDb' <-
323-
if _configReadOnlyReplay cwConf
324-
then
325-
withReadOnlyRocksDb <$ logFunctionText logger Info "Opening RocksDB in read-only mode"
326-
else
327-
return withRocksDb
328-
withRocksDb' rocksDbDir modernDefaultOptions $ \rocksDb -> do
322+
withRocksDb rocksDbDir modernDefaultOptions $ \rocksDb -> do
329323
logFunctionText logger Info $ "opened rocksdb in directory " <> sshow rocksDbDir
330324
logFunctionText logger Debug $ "backup config: " <> sshow (_configBackup cwConf)
331325
withChainweb cwConf logger rocksDb pactDbDir dbBackupsDir $ \case
@@ -370,7 +364,6 @@ withNodeLogger logCfg chainwebCfg v f = runManaged $ do
370364
let !txFailureHandler =
371365
if isJust (_cutInitialCutFile (_configCuts chainwebCfg))
372366
|| isJust (_cutInitialBlockHeightLimit (_configCuts chainwebCfg))
373-
|| _configReadOnlyReplay chainwebCfg
374367
then [dropLogHandler (Proxy :: Proxy PactTxFailureLog)]
375368
else []
376369

src/Chainweb/Chainweb.hs

Lines changed: 36 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
330330
{ _cutDbParamsLogLevel = Info
331331
, _cutDbParamsTelemetryLevel = Info
332332
, _cutDbParamsInitialHeightLimit = _cutInitialBlockHeightLimit cutConf
333-
, _cutDbParamsReadOnly = _configReadOnlyReplay conf
333+
, _cutDbParamsReadOnly = False
334334
, _cutDbParamsInitialCutFile = _cutInitialCutFile cutConf
335335
}
336336
where
@@ -394,94 +394,41 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
394394
putPeerThrottler <- mkPutPeerThrottler $ _throttlingPeerRate throt
395395
mempoolThrottler <- mkMempoolThrottler $ _throttlingMempoolRate throt
396396
logg Debug "initialized throttlers"
397-
398-
-- synchronize pact dbs with latest cut before we start the server
399-
-- and clients and begin mining.
400-
--
401-
-- This is a consistency check that validates the blocks in the
402-
-- current cut. If it fails an exception is raised. Also, if it
403-
-- takes long (for example, when doing a reset to a prior block
404-
-- height) we want this to happen before we go online.
405-
--
406-
let
407-
-- pactSyncChains =
408-
-- case _configSyncPactChains conf of
409-
-- Just syncChains
410-
-- | _configReadOnlyReplay conf
411-
-- -> HM.filterWithKey (\k _ -> elem k syncChains) cs
412-
-- _ -> cs
413-
414-
if _configReadOnlyReplay conf
415-
then do
416-
-- FIXME implement replay in payload provider
417-
error "Chainweb.Chainweb.withChainwebInternal: pact replay is not supported"
418-
-- logFunctionJson logger Info PactReplayInProgress
419-
-- -- note that we don't use the "initial cut" from cutdb because its height depends on initialBlockHeightLimit.
420-
-- highestCut <-
421-
-- unsafeMkCut v <$> readHighestCutHeaders v (logFunctionText logger) webchain (cutHashesTable rocksDb)
422-
-- lowerBoundCut <-
423-
-- tryLimitCut webchain (fromMaybe 0 $ _cutInitialBlockHeightLimit $ _configCuts conf) highestCut
424-
-- upperBoundCut <- forM (_cutFastForwardBlockHeightLimit $ _configCuts conf) $ \upperBound ->
425-
-- tryLimitCut webchain upperBound highestCut
426-
-- let
427-
-- replayOneChain :: (ChainResources logger, (BlockHeader, Maybe BlockHeader)) -> IO ()
428-
-- replayOneChain (cr, (l, u)) = do
429-
-- let chainPact = _chainResPact cr
430-
-- let logCr = logFunctionText
431-
-- $ addLabel ("component", "pact")
432-
-- $ addLabel ("sub-component", "init")
433-
-- $ _chainResLogger cr
434-
-- void $ _pactReadOnlyReplay chainPact l u
435-
-- logCr Info "pact db synchronized"
436-
-- let bounds =
437-
-- HM.intersectionWith (,)
438-
-- pactSyncChains
439-
-- (HM.mapWithKey
440-
-- (\cid bh ->
441-
-- (bh, (HM.! cid) . _cutMap <$> upperBoundCut))
442-
-- (_cutMap lowerBoundCut)
443-
-- )
444-
-- mapConcurrently_ replayOneChain bounds
445-
-- logg Info "finished fast forward replay"
446-
-- logFunctionJson logger Info PactReplaySuccessful
447-
-- inner $ Replayed lowerBoundCut upperBoundCut
448-
else do
449-
logg Debug "start initializing miner resources"
450-
logFunctionJson logger Info InitializingMinerResources
451-
452-
withMiningCoordination mLogger mConf mCutDb $ \mc ->
453-
454-
-- Miner resources are used by the test-miner when in-node
455-
-- mining is configured or by the mempool noop-miner (which
456-
-- keeps the mempool updated) in production setups.
457-
--
458-
withMinerResources mLogger (_miningInNode mConf) cs mCutDb mc $ \m -> do
459-
logFunctionJson logger Info ChainwebStarted
460-
logg Debug "finished initializing miner resources"
461-
let !haddr = _peerConfigAddr $ _p2pConfigPeer $ _configP2p conf
462-
inner $ StartedChainweb Chainweb
463-
{ _chainwebHostAddress = haddr
464-
, _chainwebChains = cs
465-
, _chainwebCutResources = cutResources
466-
, _chainwebMiner = m
467-
, _chainwebCoordinator = mc
468-
, _chainwebLogger = logger
469-
, _chainwebPeer = peerRes
470-
, _chainwebManager = mgr
471-
-- , _chainwebPactData = pactData
472-
, _chainwebThrottler = throttler
473-
, _chainwebPutPeerThrottler = putPeerThrottler
474-
, _chainwebMempoolThrottler = mempoolThrottler
475-
, _chainwebConfig = conf
476-
, _chainwebServiceSocket = serviceSock
477-
, _chainwebBackup = BackupEnv
478-
{ _backupRocksDb = rocksDb
479-
, _backupDir = backupDir
480-
, _backupPactDbDir = defaultPactDbDir
481-
, _backupChainIds = cids
482-
, _backupLogger = backupLogger
483-
}
484-
}
397+
logg Debug "start initializing miner resources"
398+
logFunctionJson logger Info InitializingMinerResources
399+
400+
withMiningCoordination mLogger mConf mCutDb $ \mc ->
401+
402+
-- Miner resources are used by the test-miner when in-node
403+
-- mining is configured or by the mempool noop-miner (which
404+
-- keeps the mempool updated) in production setups.
405+
--
406+
withMinerResources mLogger (_miningInNode mConf) cs mCutDb mc $ \m -> do
407+
logFunctionJson logger Info ChainwebStarted
408+
logg Debug "finished initializing miner resources"
409+
let !haddr = _peerConfigAddr $ _p2pConfigPeer $ _configP2p conf
410+
inner $ StartedChainweb Chainweb
411+
{ _chainwebHostAddress = haddr
412+
, _chainwebChains = cs
413+
, _chainwebCutResources = cutResources
414+
, _chainwebMiner = m
415+
, _chainwebCoordinator = mc
416+
, _chainwebLogger = logger
417+
, _chainwebPeer = peerRes
418+
, _chainwebManager = mgr
419+
, _chainwebThrottler = throttler
420+
, _chainwebPutPeerThrottler = putPeerThrottler
421+
, _chainwebMempoolThrottler = mempoolThrottler
422+
, _chainwebConfig = conf
423+
, _chainwebServiceSocket = serviceSock
424+
, _chainwebBackup = BackupEnv
425+
{ _backupRocksDb = rocksDb
426+
, _backupDir = backupDir
427+
, _backupPactDbDir = defaultPactDbDir
428+
, _backupChainIds = cids
429+
, _backupLogger = backupLogger
430+
}
431+
}
485432

486433
-- synchronizePactDb :: HM.HashMap ChainId (ChainResources logger) -> Cut -> IO ()
487434
-- synchronizePactDb cs targetCut = do

src/Chainweb/Chainweb/Configuration.hs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ module Chainweb.Chainweb.Configuration
7171
, configReorgLimit
7272
, configBackup
7373
, configServiceApi
74-
, configReadOnlyReplay
75-
, configSyncChains
7674
, configPayloadProviders
7775
, defaultChainwebConfiguration
7876
, pChainwebConfiguration
@@ -553,16 +551,6 @@ data ChainwebConfiguration = ChainwebConfiguration
553551
, _configPayloadProviders :: PayloadProviderConfig
554552
, _configPrune :: !PruneConfig
555553

556-
-- The following properties are deprecated: history replay should not be
557-
-- part of normal operation mode. It should probably use a completely
558-
-- separate configuration.
559-
560-
, _configReadOnlyReplay :: !Bool
561-
-- ^ do a read-only replay using the cut db params for the block heights
562-
, _configSyncChains :: !(Maybe [ChainId])
563-
-- ^ the only chains to be synchronized on startup to the latest cut.
564-
-- if unset, all chains will be synchronized.
565-
566554
} deriving (Show, Eq, Generic)
567555

568556
makeLenses ''ChainwebConfiguration
@@ -608,9 +596,7 @@ defaultChainwebConfiguration v = ChainwebConfiguration
608596
, _configThrottling = defaultThrottlingConfig
609597
, _configReorgLimit = defaultReorgLimit
610598
, _configServiceApi = defaultServiceApiConfig
611-
, _configReadOnlyReplay = False
612599
, _configPrune = defaultPruneConfig
613-
, _configSyncChains = Nothing
614600
, _configBackup = defaultBackupConfig
615601
, _configPayloadProviders = defaultPayloadProviderConfig
616602
}
@@ -624,8 +610,6 @@ instance ToJSON ChainwebConfiguration where
624610
, "throttling" .= _configThrottling o
625611
, "reorgLimit" .= _configReorgLimit o
626612
, "serviceApi" .= _configServiceApi o
627-
, "readOnlyReplay" .= _configReadOnlyReplay o
628-
, "syncChains" .= _configSyncChains o
629613
, "backup" .= _configBackup o
630614
, "payloadProviders" .= _configPayloadProviders o
631615
, "pruning" .= _configPrune o
@@ -644,8 +628,6 @@ instance FromJSON (ChainwebConfiguration -> ChainwebConfiguration) where
644628
<*< configThrottling %.: "throttling" % o
645629
<*< configReorgLimit ..: "reorgLimit" % o
646630
<*< configServiceApi %.: "serviceApi" % o
647-
<*< configReadOnlyReplay ..: "readOnlyReplay" % o
648-
<*< configSyncChains ..: "syncChains" % o
649631
<*< configBackup %.: "backup" % o
650632
<*< configPayloadProviders %.: "payloadProviders" % o
651633
<*< configPrune %.: "pruning" % o
@@ -662,13 +644,6 @@ pChainwebConfiguration = id
662644
<*< parserOptionGroup "Cut Processing" (configCuts %:: pCutConfig)
663645
<*< parserOptionGroup "Service API" (configServiceApi %:: pServiceApiConfig)
664646
<*< parserOptionGroup "Mining Coordination" (configMining %:: pMiningConfig)
665-
<*< configReadOnlyReplay .:: boolOption_
666-
% long "read-only-replay"
667-
<> help "Replay the block history non-destructively"
668-
<*< configSyncChains .:: fmap Just % jsonOption
669-
% long "sync-chains"
670-
<> help "The only Pact databases to synchronize. If empty or unset, all chains will be synchronized."
671-
<> metavar "JSON list of chain ids"
672647
<*< parserOptionGroup "Backup" (configBackup %:: pBackupConfig)
673648

674649
-- FIXME support payload providers

0 commit comments

Comments
 (0)