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

Commit fcc8996

Browse files
committed
Delete some now-unused replay options from cw-node
1 parent 43b5c57 commit fcc8996

3 files changed

Lines changed: 38 additions & 121 deletions

File tree

node/src/ChainwebNode.hs

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

src/Chainweb/Chainweb.hs

Lines changed: 37 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
329329
{ _cutDbParamsLogLevel = Info
330330
, _cutDbParamsTelemetryLevel = Info
331331
, _cutDbParamsInitialHeightLimit = _cutInitialBlockHeightLimit cutConf
332-
, _cutDbParamsReadOnly = _configReadOnlyReplay conf
332+
, _cutDbParamsReadOnly = False
333333
, _cutDbParamsInitialCutFile = _cutInitialCutFile cutConf
334334
}
335335
where
@@ -388,93 +388,42 @@ withChainwebInternal conf logger peerRes serviceSock rocksDb defaultPactDbDir ba
388388
mempoolThrottler <- mkMempoolThrottler $ _throttlingMempoolRate throt
389389
logg Debug "initialized throttlers"
390390

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

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

src/Chainweb/Chainweb/Configuration.hs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ module Chainweb.Chainweb.Configuration
6767
, configReorgLimit
6868
, configBackup
6969
, configServiceApi
70-
, configReadOnlyReplay
71-
, configSyncChains
7270
, configPayloadProviders
7371
, defaultChainwebConfiguration
7472
, pChainwebConfiguration
@@ -519,16 +517,6 @@ data ChainwebConfiguration = ChainwebConfiguration
519517
, _configServiceApi :: !ServiceApiConfig
520518
, _configPayloadProviders :: PayloadProviderConfig
521519

522-
-- The following properties are deprecated: history replay should not be
523-
-- part of normal operation mode. It should probably use a completely
524-
-- separate configuration.
525-
526-
, _configReadOnlyReplay :: !Bool
527-
-- ^ do a read-only replay using the cut db params for the block heights
528-
, _configSyncChains :: !(Maybe [ChainId])
529-
-- ^ the only chains to be synchronized on startup to the latest cut.
530-
-- if unset, all chains will be synchronized.
531-
532520
} deriving (Show, Eq, Generic)
533521

534522
makeLenses ''ChainwebConfiguration
@@ -574,8 +562,6 @@ defaultChainwebConfiguration v = ChainwebConfiguration
574562
, _configThrottling = defaultThrottlingConfig
575563
, _configReorgLimit = defaultReorgLimit
576564
, _configServiceApi = defaultServiceApiConfig
577-
, _configReadOnlyReplay = False
578-
, _configSyncChains = Nothing
579565
, _configBackup = defaultBackupConfig
580566
, _configPayloadProviders = defaultPayloadProviderConfig
581567
}
@@ -589,8 +575,6 @@ instance ToJSON ChainwebConfiguration where
589575
, "throttling" .= _configThrottling o
590576
, "reorgLimit" .= _configReorgLimit o
591577
, "serviceApi" .= _configServiceApi o
592-
, "readOnlyReplay" .= _configReadOnlyReplay o
593-
, "syncChains" .= _configSyncChains o
594578
, "backup" .= _configBackup o
595579
, "payloadProviders" .= _configPayloadProviders o
596580
]
@@ -608,8 +592,6 @@ instance FromJSON (ChainwebConfiguration -> ChainwebConfiguration) where
608592
<*< configThrottling %.: "throttling" % o
609593
<*< configReorgLimit ..: "reorgLimit" % o
610594
<*< configServiceApi %.: "serviceApi" % o
611-
<*< configReadOnlyReplay ..: "readOnlyReplay" % o
612-
<*< configSyncChains ..: "syncChains" % o
613595
<*< configBackup %.: "backup" % o
614596
<*< configPayloadProviders %.: "payloadProviders" % o
615597

@@ -625,13 +607,6 @@ pChainwebConfiguration = id
625607
<*< parserOptionGroup "Cut Processing" (configCuts %:: pCutConfig)
626608
<*< parserOptionGroup "Service API" (configServiceApi %:: pServiceApiConfig)
627609
<*< parserOptionGroup "Mining Coordination" (configMining %:: pMiningConfig)
628-
<*< configReadOnlyReplay .:: boolOption_
629-
% long "read-only-replay"
630-
<> help "Replay the block history non-destructively"
631-
<*< configSyncChains .:: fmap Just % jsonOption
632-
% long "sync-chains"
633-
<> help "The only Pact databases to synchronize. If empty or unset, all chains will be synchronized."
634-
<> metavar "JSON list of chain ids"
635610
<*< parserOptionGroup "Backup" (configBackup %:: pBackupConfig)
636611

637612
-- FIXME support payload providers

0 commit comments

Comments
 (0)