Skip to content

Commit bbf0011

Browse files
iohk-bors[bot]mrBlisscoot
authored
Merge #1908 #1909
1908: Revert "ImmutableDB: truncate blocks from the future" r=mrBliss a=mrBliss This reverts commit 81f2f1e. See #1773, we first have to open the ImmutableDB /with/ all blocks because we don't know yet in which slot we are. We need the ImmutableDB to obtain a ledger state which will tell us which slot we're in. Afterwards, we can truncate the future blocks from the ImmutableDB. This last step will be done by the ChainDB and will follow in a future PR. 1909: Fix typos r=coot a=coot Co-authored-by: Thomas Winant <[email protected]> Co-authored-by: Marcin Szamotulski <[email protected]>
3 parents c3c1e52 + 49b0aa0 + c77fd46 commit bbf0011

File tree

14 files changed

+39
-139
lines changed

14 files changed

+39
-139
lines changed

ouroboros-consensus-byron/tools/db-analyser/Main.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import Ouroboros.Network.Block (HasHeader (..), SlotNo (..),
3535
genesisPoint)
3636

3737
import Ouroboros.Consensus.Block
38-
import Ouroboros.Consensus.BlockchainTime.Mock (fixedBlockchainTime)
3938
import Ouroboros.Consensus.Config
4039
import Ouroboros.Consensus.Node.NetworkProtocolVersion
4140
import Ouroboros.Consensus.Node.ProtocolInfo
@@ -365,6 +364,4 @@ withImmDB fp cfg chunkInfo registry = ImmDB.withImmDB args
365364
, immCheckIntegrity = nodeCheckIntegrity cfg
366365
, immAddHdrEnv = nodeAddHeaderEnvelope (Proxy @ByronBlock)
367366
, immRegistry = registry
368-
-- We don't want to truncate blocks from the future
369-
, immBlockchainTime = fixedBlockchainTime maxBound
370367
}

ouroboros-consensus/ouroboros-consensus-test-infra/src/Test/ThreadNet/Network.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ runThreadNetwork ThreadNetworkArgs
744744
, maxBlockSize = NoOverride
745745
, mempoolCap = NoMempoolCapacityBytesOverride
746746
, miniProtocolParameters = MiniProtocolParameters {
747-
chainSyncPipelineingHighMark = 4,
748-
chainSyncPipelineingLowMark = 2,
749-
blockFetchPipelineingMax = 10,
750-
txSubmissionMaxUnacked = 1000 -- TODO ?
747+
chainSyncPipeliningHighMark = 4,
748+
chainSyncPipeliningLowMark = 2,
749+
blockFetchPipeliningMax = 10,
750+
txSubmissionMaxUnacked = 1000 -- TODO ?
751751
}
752752
}
753753

ouroboros-consensus/src/Ouroboros/Consensus/NodeKernel.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ initNodeKernel args@NodeArgs { registry, cfg, tracers, maxBlockSize
220220
blockFetchConfiguration = BlockFetchConfiguration
221221
{ bfcMaxConcurrencyBulkSync = 1 -- Set to 1 for now, see #1526
222222
, bfcMaxConcurrencyDeadline = 1
223-
, bfcMaxRequestsInflight = blockFetchPipelineingMax miniProtocolParameters
223+
, bfcMaxRequestsInflight = blockFetchPipeliningMax miniProtocolParameters
224224
}
225225

226226
{-------------------------------------------------------------------------------

ouroboros-consensus/src/Ouroboros/Consensus/NodeNetwork.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ protocolHandlers NodeArgs {btime, cfg, maxClockSkew, tracers, miniProtocolParame
161161
ProtocolHandlers {
162162
phChainSyncClient =
163163
chainSyncClient
164-
(pipelineDecisionLowHighMark (chainSyncPipelineingLowMark miniProtocolParameters)
165-
(chainSyncPipelineingHighMark miniProtocolParameters))
164+
(pipelineDecisionLowHighMark (chainSyncPipeliningLowMark miniProtocolParameters)
165+
(chainSyncPipeliningHighMark miniProtocolParameters))
166166
(chainSyncClientTracer tracers)
167167
getTopLevelConfig
168168
btime

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ChainDB/Impl/Args.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ fromChainDbArgs ChainDbArgs{..} = (
183183
, immAddHdrEnv = cdbAddHdrEnv
184184
, immCacheConfig = cdbImmDbCacheConfig
185185
, immRegistry = cdbRegistry
186-
, immBlockchainTime = cdbBlockchainTime
187186
}
188187
, VolDB.VolDbArgs {
189188
volHasFS = cdbHasFSVolDb

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ChainDB/Impl/ImmDB.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ import Ouroboros.Network.Block (pattern BlockPoint,
8282
import Ouroboros.Network.Point (WithOrigin (..))
8383

8484
import Ouroboros.Consensus.Block
85-
import Ouroboros.Consensus.BlockchainTime (BlockchainTime)
8685
import Ouroboros.Consensus.Util.IOLike
8786
import Ouroboros.Consensus.Util.Orphans ()
8887
import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry)
@@ -159,7 +158,6 @@ data ImmDbArgs m blk = forall h. Eq h => ImmDbArgs {
159158
, immTracer :: Tracer m (TraceEvent blk)
160159
, immCacheConfig :: Index.CacheConfig
161160
, immRegistry :: ResourceRegistry m
162-
, immBlockchainTime :: BlockchainTime m
163161
}
164162

165163
-- | Default arguments when using the 'IO' monad
@@ -178,7 +176,6 @@ data ImmDbArgs m blk = forall h. Eq h => ImmDbArgs {
178176
-- * 'immCheckIntegrity'
179177
-- * 'immAddHdrEnv'
180178
-- * 'immRegistry'
181-
-- * 'immBlockchainTime'
182179
defaultArgs :: FilePath -> ImmDbArgs IO blk
183180
defaultArgs fp = ImmDbArgs{
184181
immHasFS = ioHasFS $ MountPoint (fp </> "immutable")
@@ -197,7 +194,6 @@ defaultArgs fp = ImmDbArgs{
197194
, immCheckIntegrity = error "no default for immCheckIntegrity"
198195
, immAddHdrEnv = error "no default for immAddHdrEnv"
199196
, immRegistry = error "no default for immRegistry"
200-
, immBlockchainTime = error "no default for immBlockchainTime"
201197
}
202198
where
203199
-- Cache 250 past chunks by default. This will take roughly 250 MB of RAM.
@@ -241,7 +237,6 @@ openDB ImmDbArgs {..} = do
241237
, hashInfo = immHashInfo
242238
, tracer = immTracer
243239
, cacheConfig = immCacheConfig
244-
, btime = immBlockchainTime
245240
, valPol = immValidation
246241
, parser = parser
247242
}

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ImmutableDB/Impl.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ import Cardano.Slotting.Block
107107
import Cardano.Slotting.Slot
108108

109109
import Ouroboros.Consensus.Block (IsEBB (..))
110-
import Ouroboros.Consensus.BlockchainTime (BlockchainTime,
111-
getCurrentSlot)
112110
import Ouroboros.Consensus.Util (SomePair (..))
113111
import Ouroboros.Consensus.Util.IOLike
114112
import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry,
@@ -178,7 +176,6 @@ data ImmutableDbArgs m h hash e = ImmutableDbArgs
178176
, hashInfo :: HashInfo hash
179177
, tracer :: Tracer m (TraceEvent e hash)
180178
, cacheConfig :: Index.CacheConfig
181-
, btime :: BlockchainTime m
182179
, valPol :: ValidationPolicy
183180
, parser :: ChunkFileParser e m (BlockSummary hash) hash
184181
}
@@ -234,15 +231,13 @@ openDBInternal
234231
=> ImmutableDbArgs m h hash e
235232
-> m (ImmutableDB hash m, Internal hash m)
236233
openDBInternal ImmutableDbArgs {..} = runWithTempRegistry $ do
237-
currentSlot <- atomically $ getCurrentSlot btime
238234
let validateEnv = ValidateEnv
239235
{ hasFS
240236
, chunkInfo
241237
, hashInfo
242238
, parser
243239
, tracer
244240
, cacheConfig
245-
, currentSlot
246241
}
247242
ost <- validateAndReopen validateEnv registry valPol
248243

@@ -257,7 +252,6 @@ openDBInternal ImmutableDbArgs {..} = runWithTempRegistry $ do
257252
, tracer = tracer
258253
, registry = registry
259254
, cacheConfig = cacheConfig
260-
, blockchainTime = btime
261255
}
262256
db = mkDBRecord dbEnv
263257
internal = Internal

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ImmutableDB/Impl/State.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import GHC.Stack (HasCallStack)
3232

3333
import Cardano.Prelude (NoUnexpectedThunks (..))
3434

35-
import Ouroboros.Consensus.BlockchainTime (BlockchainTime)
3635
import Ouroboros.Consensus.Util (SomePair (..))
3736
import Ouroboros.Consensus.Util.IOLike
3837
import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry,
@@ -66,7 +65,6 @@ data ImmutableDBEnv m hash = forall h e. Eq h => ImmutableDBEnv
6665
, tracer :: !(Tracer m (TraceEvent e hash))
6766
, registry :: !(ResourceRegistry m)
6867
, cacheConfig :: !Index.CacheConfig
69-
, blockchainTime :: !(BlockchainTime m)
7068
}
7169

7270
data InternalState m hash h =

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ImmutableDB/Impl/Validation.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ data ValidateEnv m hash h e = ValidateEnv
6363
, parser :: !(ChunkFileParser e m (BlockSummary hash) hash)
6464
, tracer :: !(Tracer m (TraceEvent e hash))
6565
, cacheConfig :: !Index.CacheConfig
66-
, currentSlot :: !SlotNo
6766
}
6867

6968
-- | Perform validation as per the 'ValidationPolicy' using 'validate' and
@@ -323,7 +322,7 @@ validateChunk ValidateEnv{..} shouldBeFinalised chunk mbPrevHash = do
323322
-- expensive integrity check of a block.
324323
let expectedChecksums = map Secondary.checksum entriesFromSecondaryIndex
325324
(entriesWithPrevHashes, mbErr) <- lift $
326-
runChunkFileParser parser chunkFile currentSlot expectedChecksums $ \entries ->
325+
runChunkFileParser parser chunkFile expectedChecksums $ \entries ->
327326
(\(es :> mbErr) -> (es, mbErr)) <$> S.toList entries
328327

329328
-- Check whether the first block of this chunk fits onto the last block of

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ImmutableDB/Parser.hs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ data ChunkFileError hash =
6060
-- 'BlockOrEBB' number returned 'False', indicating that the block got
6161
-- corrupted.
6262
| ChunkErrCorrupt hash BlockOrEBB
63-
64-
-- | The block has a slot number greater than the current slot (wall
65-
-- clock). This block is in the future, so we must truncate it.
66-
| ChunkErrFutureBlock
67-
SlotNo -- ^ Current slot (wall clock)
68-
SlotNo -- ^ Slot number of the block
6963
deriving (Eq, Show)
7064

7165
-- | Information about a block returned by the parser
@@ -93,12 +87,11 @@ chunkFileParser'
9387
hash
9488
chunkFileParser' getSlotNo getBlockNo getHash getPrevHash hasFS decodeBlock isEBB
9589
getBinaryInfo isNotCorrupt =
96-
ChunkFileParser $ \fsPath currentSlotNo expectedChecksums k ->
90+
ChunkFileParser $ \fsPath expectedChecksums k ->
9791
Util.CBOR.withStreamIncrementalOffsets hasFS decoder fsPath
9892
( k
9993
. checkIfHashesLineUp
10094
. checkEntries expectedChecksums
101-
. checkFutureSlot currentSlotNo
10295
. fmap (fmap (first ChunkErrRead))
10396
)
10497
where
@@ -108,21 +101,6 @@ chunkFileParser' getSlotNo getBlockNo getHash getPrevHash hasFS decodeBlock isEB
108101
!checksum = computeCRC bs
109102
in (blk, checksum)
110103

111-
-- | Stop when a block has slot number > the current slot, return
112-
-- 'ChunkErrFutureBlock'.
113-
checkFutureSlot
114-
:: SlotNo -- ^ Current slot (wall clock).
115-
-> Stream (Of (Word64, (Word64, (blk, CRC))))
116-
m
117-
(Maybe (ChunkFileError hash, Word64))
118-
-> Stream (Of (Word64, (Word64, (blk, CRC))))
119-
m
120-
(Maybe (ChunkFileError hash, Word64))
121-
checkFutureSlot currentSlotNo = mapS $ \x@(offset, (_, (blk, _))) ->
122-
if getSlotNo blk > currentSlotNo
123-
then Left $ Just (ChunkErrFutureBlock currentSlotNo (getSlotNo blk), offset)
124-
else Right x
125-
126104
-- | Go over the expected checksums and blocks in parallel. Stop with an
127105
-- error when a block is corrupt. Yield correct entries along the way.
128106
--
@@ -266,12 +244,3 @@ mapAccumS0 initAcc updateAcc = mapAccumS Nothing updateAcc'
266244
where
267245
updateAcc' :: Maybe s -> a -> Either r (b, Maybe s)
268246
updateAcc' mbSt = fmap (fmap Just) . maybe initAcc updateAcc mbSt
269-
270-
-- | Map over elements of a stream, allowing an early return by returning
271-
-- 'Left'.
272-
mapS
273-
:: Monad m
274-
=> (a -> Either r b)
275-
-> Stream (Of a) m r
276-
-> Stream (Of b) m r
277-
mapS updateAcc = mapAccumS () (\() a -> (, ()) <$> updateAcc a)

ouroboros-consensus/src/Ouroboros/Consensus/Storage/ImmutableDB/Types.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ newtype ChunkFileParser e m entry hash = ChunkFileParser
130130
{ runChunkFileParser
131131
:: forall r.
132132
FsPath
133-
-> SlotNo
134-
-- Current slot (wall clock)
135133
-> [CRC]
136134
-- The expected checksums are given as input. This list can be empty
137135
-- when the secondary index file is missing. If the expected checksum

ouroboros-consensus/test-storage/Test/Ouroboros/Storage/ImmutableDB.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Test.Tasty.HUnit
1212
import Cardano.Slotting.Slot
1313

1414
import Ouroboros.Consensus.Block (getHeader)
15-
import Ouroboros.Consensus.BlockchainTime.Mock (fixedBlockchainTime)
1615
import Ouroboros.Consensus.Util.IOLike
1716
import Ouroboros.Consensus.Util.ResourceRegistry
1817

@@ -61,7 +60,6 @@ openTestDB registry hasFS =
6160
, hashInfo = testHashInfo
6261
, tracer = nullTracer
6362
, cacheConfig = Index.CacheConfig 2 60
64-
, btime = fixedBlockchainTime maxBound
6563
, valPol = ValidateMostRecentChunk
6664
, parser
6765
}

0 commit comments

Comments
 (0)