Skip to content

Commit c6d09eb

Browse files
committed
ChainDB q-s-m: do not copy blocks to ImmutableDB on snapshot
1 parent cbda1fb commit c6d09eb

2 files changed

Lines changed: 12 additions & 35 deletions

File tree

ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/ChainDB/StateMachine.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,18 @@ run cfg env@ChainDBEnv{varDB, ..} cmd =
466466
PersistBlks -> ignore <$> persistBlks DoNotGarbageCollect internal
467467
PersistBlksThenGC -> ignore <$> persistBlks GarbageCollect internal
468468
UpdateLedgerSnapshots -> do
469-
-- TODO(geo2a): for now, we don't copy the immutable blocks when taking
470-
-- a ledger state snapshot, because the model does not faithfully implement
471-
-- this behaviour
472-
let copyImmutableBlocks = pure ()
473-
ignore <$> intTryTakeSnapshot internal copyImmutableBlocks (\_ -> pure 0)
469+
-- In these tests, we don't copy the immutable blocks when taking
470+
-- a ledger state snapshot, because the model cannot yet faithfully implement
471+
-- this behaviour. In production, the snapshots are taken conditionally, and the
472+
-- 'tryTakeSnapshot' routine will only copy blocks only if it does take a snapshot.
473+
-- The model can only always either copy or not, unconditionally, as it does not
474+
-- implement the snapshot decision logic.
475+
--
476+
-- TODO(geo2a): re-enable copying when the model has a notion of ledge state
477+
-- snapshots and can conditionally copy to ImmutableDB.
478+
-- let copyImmutableBlocks = persistBlks GarbageCollect internal
479+
let noCopyImmutableBlocks = pure ()
480+
ignore <$> intTryTakeSnapshot internal noCopyImmutableBlocks (\_ -> pure 0)
474481
WipeVolatileDB -> Point <$> wipeVolatileDB st
475482
where
476483
mbGCedAllComponents = MbGCedAllComponents . MaybeGCedBlock True

ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/ChainDB/Unit.hs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ tests =
121121
[ testGroup
122122
"Chain not long enough to take a snapshot, so blocks are not persisted into ImmutableDB and are lost."
123123
[testCase "system" $ runSystemIO updateLedgerSnapshots_WipeVolatileDB_withoutSnapshot]
124-
, testGroup
125-
"Chain is long enough to take a snapshot, blocks are copied into ImmutableDB."
126-
[testCase "system" $ runSystemIO updateLedgerSnapshots_WipeVolatileDB_withSnapshot]
127124
]
128125
]
129126

@@ -342,9 +339,6 @@ waitForImmutableBlock_emptySlot = do
342339
-- ImmutableDB when the snapshot policy selects slots for snapshotting. When the
343340
-- immutable chain is too short, no blocks should be flushed, and WipeVolatileDB
344341
-- should recover to the tip of the (empty) ImmutableDB.
345-
--
346-
-- See 'updateLedgerSnapshots_WipeVolatileDB_withSnapshot' for the scenario where
347-
-- the snapshot is taken.
348342
updateLedgerSnapshots_WipeVolatileDB_withoutSnapshot ::
349343
forall m.
350344
( Block m ~ TestBlock
@@ -367,30 +361,6 @@ updateLedgerSnapshots_WipeVolatileDB_withoutSnapshot = do
367361
where
368362
fork0 = TestBody 1 True Nothing
369363

370-
-- | See 'updateLedgerSnapshots_WipeVolatileDB_withoutSnapshot' for details.
371-
updateLedgerSnapshots_WipeVolatileDB_withSnapshot ::
372-
forall m.
373-
( Block m ~ TestBlock
374-
, SupportsUnitTest m
375-
, MonadError TestFailure m
376-
) =>
377-
m ()
378-
updateLedgerSnapshots_WipeVolatileDB_withSnapshot = do
379-
b1 <- addBlock $ firstBlock 1 $ fork0
380-
b2 <- addBlock $ mkNextBlock b1 3 $ fork0
381-
b3 <- addBlock $ mkNextBlock b2 5 $ fork0
382-
b4 <- addBlock $ mkNextBlock b3 7 $ fork0
383-
_ <- addBlock $ mkNextBlock b4 9 $ fork0
384-
385-
updateLedgerSnapshots
386-
387-
tip <- wipeVolatileDB
388-
tip
389-
/= genesisPoint
390-
`orFailWith` ("Expected ChainDB non-Origin tip after wiping VolatileDB, got: " <> show tip)
391-
where
392-
fork0 = TestBody 1 True Nothing
393-
394364
{-------------------------------------------------------------------------------
395365
Helpers and testing infrastructure
396366
-------------------------------------------------------------------------------}

0 commit comments

Comments
 (0)