Skip to content

Commit 5a1e223

Browse files
committed
Try no snapshots 1 ledger
1 parent 7d13547 commit 5a1e223

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

cabal.project.local

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
packages:
2+
../ouroboros-consensus
3+
4+
5+
package cardano-db-sync
6+
ghc-options: -finfo-table-map -fdistinct-constructor-tables
7+
8+
package ouroboros-consensus-lsm
9+
ghc-options: -finfo-table-map -fdistinct-constructor-tables
10+
11+
package lsm-tree
12+
ghc-options: -finfo-table-map -fdistinct-constructor-tables

cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ mkHandleFromValues tables = do
184184
pushLedgerDB :: LedgerDB -> CardanoLedgerState -> (LedgerDB, [CardanoLedgerState])
185185
pushLedgerDB db st =
186186
pruneLedgerDb
187-
100
187+
1
188188
db
189189
{ ledgerDbCheckpoints = NE.cons st (ledgerDbCheckpoints db)
190190
}
@@ -444,18 +444,19 @@ storeSnapshotAndCleanupMaybe ::
444444
Bool ->
445445
SyncState ->
446446
IO Bool
447-
storeSnapshotAndCleanupMaybe env oldState appResult isCons syncState =
448-
case maybeFromStrict (apNewEpoch appResult) of
449-
Just newEpoch
450-
| newEpochNo <- unEpochNo (Generic.neEpoch newEpoch)
451-
, newEpochNo > 0
452-
, -- Snapshot every epoch when near tip, every 10 epochs when lagging, or always for epoch >= threshold
453-
(isCons && syncState == SyncFollowing) || (newEpochNo `mod` 10 == 0) || newEpochNo >= leSnapshotNearTipEpoch env ->
454-
do
455-
-- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'?
456-
liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1)
457-
pure True
458-
_ -> pure False
447+
storeSnapshotAndCleanupMaybe _ _ _ _ _ = pure False
448+
-- storeSnapshotAndCleanupMaybe env oldState appResult isCons syncState =
449+
-- case maybeFromStrict (apNewEpoch appResult) of
450+
-- Just newEpoch
451+
-- | newEpochNo <- unEpochNo (Generic.neEpoch newEpoch)
452+
-- , newEpochNo > 0
453+
-- , -- Snapshot every epoch when near tip, every 10 epochs when lagging, or always for epoch >= threshold
454+
-- (isCons && syncState == SyncFollowing) || (newEpochNo `mod` 10 == 0) || newEpochNo >= leSnapshotNearTipEpoch env ->
455+
-- do
456+
-- -- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'?
457+
-- liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1)
458+
-- pure True
459+
-- _ -> pure False
459460

460461
saveCurrentLedgerState :: HasLedgerEnv -> CardanoLedgerState -> Maybe EpochNo -> IO ()
461462
saveCurrentLedgerState env lState mEpochNo = do
@@ -984,15 +985,15 @@ tickThenReapplyCheckHash ::
984985
tickThenReapplyCheckHash registry cfg block state'@CardanoLedgerState {..} =
985986
if blockPrevHash block == Consensus.ledgerTipHash (ledgerState clsState)
986987
then do
987-
-- Read the keys this block needs from the handle
988+
-- Create a new handle first, then read from it
989+
(_rk, newHandle) <- duplicate clsTables registry
988990
let keys = Consensus.getBlockKeySets block
989-
restrictedTables <- read clsTables clsState keys
991+
restrictedTables <- read newHandle clsState keys
990992
-- Attach the tables to the ledger state and apply the block
991993
let ledgerState' = Consensus.withLedgerTables clsState restrictedTables
992994
newLedgerState =
993995
Consensus.tickThenReapplyLedgerResult Consensus.ComputeLedgerEvents cfg block ledgerState'
994-
-- Create a new handle via duplicate + pushDiffs
995-
(_rk, newHandle) <- duplicate clsTables registry
996+
-- Push diffs to the new handle
996997
pushDiffs newHandle clsState (Consensus.lrResult newLedgerState)
997998
pure . Right $
998999
fmap

0 commit comments

Comments
 (0)