Skip to content

Commit 3b89ea1

Browse files
committed
remove migration fix related code
1 parent 52ada06 commit 3b89ea1

File tree

10 files changed

+31
-132
lines changed

10 files changed

+31
-132
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ data CommandLineArgs = CommandLineArgs
122122
, claEpochDisabled :: Bool
123123
, claHasCache :: Bool
124124
, claHasLedger :: Bool
125-
, claSkipFix :: Bool
126-
, claOnlyFix :: Bool
127125
, claForceIndexes :: Bool
128126
, claHasMultiAssets :: Bool
129127
, claHasMetadata :: Bool
@@ -286,8 +284,6 @@ mkSyncNodeParams staticDir mutableDir CommandLineArgs {..} = do
286284
, enpPGPassSource = DB.PGPassCached pgconfig
287285
, enpEpochDisabled = claEpochDisabled
288286
, enpHasCache = claHasCache
289-
, enpSkipFix = claSkipFix
290-
, enpOnlyFix = claOnlyFix
291287
, enpForceIndexes = claForceIndexes
292288
, enpHasInOut = True
293289
, enpSnEveryFollowing = 35
@@ -361,8 +357,6 @@ initCommandLineArgs =
361357
, claEpochDisabled = True
362358
, claHasCache = True
363359
, claHasLedger = True
364-
, claSkipFix = True
365-
, claOnlyFix = False
366360
, claForceIndexes = False
367361
, claHasMultiAssets = True
368362
, claHasMetadata = True

cardano-db-sync/app/cardano-db-sync.hs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ main = do
4646
-- Or to ignore ledger and not specify the state
4747
(Nothing, LedgerIgnore) -> error stateDirErrorMsg
4848
-- Otherwise, it's OK
49-
_ -> pure ()
49+
_otherwise -> pure ()
5050

5151
let prometheusPort = dncPrometheusPort syncNodeConfigFromFile
5252
withMetricSetters prometheusPort $ \metricsSetters ->
@@ -87,8 +87,6 @@ pRunDbSyncNode = do
8787
<*> pPGPassSource
8888
<*> pEpochDisabled
8989
<*> pHasCache
90-
<*> pSkipFix
91-
<*> pOnlyFix
9290
<*> pForceIndexes
9391
<*> pHasInOut
9492
<*> pure 500
@@ -144,15 +142,6 @@ pEpochDisabled =
144142
<> Opt.help "Makes epoch table remain empty"
145143
)
146144

147-
pSkipFix :: Parser Bool
148-
pSkipFix =
149-
Opt.flag
150-
False
151-
True
152-
( Opt.long "skip-fix"
153-
<> Opt.help "Disables the db-sync fix procedure for the wrong datum and redeemer_data bytes."
154-
)
155-
156145
pForceIndexes :: Parser Bool
157146
pForceIndexes =
158147
Opt.flag
@@ -162,18 +151,6 @@ pForceIndexes =
162151
<> Opt.help "Forces the Index creation at the start of db-sync. Normally they're created later."
163152
)
164153

165-
pOnlyFix :: Parser Bool
166-
pOnlyFix =
167-
Opt.flag
168-
False
169-
True
170-
( Opt.long "fix-only"
171-
<> Opt.help
172-
"Runs only the db-sync fix procedure for the wrong datum, redeemer_data and plutus script bytes and exits. \
173-
\This doesn't run any migrations. This can also be ran on previous schema, ie 13.0 13.1 to fix the issues without \
174-
\bumping the schema version minor number."
175-
)
176-
177154
pHasCache :: Parser Bool
178155
pHasCache =
179156
Opt.flag

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ runDbSync metricsSetters knownMigrations iomgr trce params syncNodeConfigFromFil
125125
trce
126126
iomgr
127127
connectionString
128-
ranMigrations
129128
(void . runMigration)
130129
syncNodeConfigFromFile
131130
params
@@ -153,15 +152,13 @@ runSyncNode ::
153152
Trace IO Text ->
154153
IOManager ->
155154
ConnectionString ->
156-
-- | migrations were ran on startup
157-
Bool ->
158155
-- | run migration function
159156
RunMigration ->
160157
SyncNodeConfig ->
161158
SyncNodeParams ->
162159
SyncOptions ->
163160
IO ()
164-
runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc syncNodeConfigFromFile syncNodeParams syncOptions = do
161+
runSyncNode metricsSetters trce iomgr dbConnString runMigrationFnc syncNodeConfigFromFile syncNodeParams syncOptions = do
165162
whenJust maybeLedgerDir $
166163
\enpLedgerStateDir -> do
167164
createDirectoryIfMissing True (unLedgerStateDir enpLedgerStateDir)
@@ -188,7 +185,6 @@ runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc
188185
genCfg
189186
syncNodeConfigFromFile
190187
syncNodeParams
191-
ranMigrations
192188
runMigrationFnc
193189

194190
-- Warn the user that jsonb datatypes are being removed from the database schema.
@@ -246,8 +242,6 @@ extractSyncOptions snp aop snc =
246242
&& not (enpEpochDisabled snp || not (enpHasCache snp))
247243
, soptAbortOnInvalid = aop
248244
, soptCache = enpHasCache snp
249-
, soptSkipFix = enpSkipFix snp
250-
, soptOnlyFix = enpOnlyFix snp
251245
, soptPruneConsumeMigration =
252246
initPruneConsumeMigration
253247
isTxOutConsumed'

cardano-db-sync/src/Cardano/DbSync/Api.hs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ module Cardano.DbSync.Api (
1313
getConsistentLevel,
1414
isConsistent,
1515
getIsConsumedFixed,
16-
noneFixed,
17-
isDataFixed,
18-
getIsSyncFixed,
19-
setIsFixed,
20-
setIsFixedAndMigrate,
2116
getDisableInOutState,
2217
getRanIndexes,
2318
runIndexMigrations,
@@ -125,26 +120,6 @@ getIsConsumedFixed env =
125120
pcm = soptPruneConsumeMigration $ envOptions env
126121
backend = envBackend env
127122

128-
noneFixed :: FixesRan -> Bool
129-
noneFixed NoneFixRan = True
130-
noneFixed _ = False
131-
132-
isDataFixed :: FixesRan -> Bool
133-
isDataFixed DataFixRan = True
134-
isDataFixed _ = False
135-
136-
getIsSyncFixed :: SyncEnv -> IO FixesRan
137-
getIsSyncFixed = readTVarIO . envIsFixed
138-
139-
setIsFixed :: SyncEnv -> FixesRan -> IO ()
140-
setIsFixed env fr = do
141-
atomically $ writeTVar (envIsFixed env) fr
142-
143-
setIsFixedAndMigrate :: SyncEnv -> FixesRan -> IO ()
144-
setIsFixedAndMigrate env fr = do
145-
envRunDelayedMigration env DB.Fix
146-
atomically $ writeTVar (envIsFixed env) fr
147-
148123
getDisableInOutState :: SyncEnv -> IO Bool
149124
getDisableInOutState syncEnv = do
150125
bst <- readTVarIO $ envBootstrap syncEnv
@@ -343,10 +318,9 @@ mkSyncEnv ::
343318
SystemStart ->
344319
SyncNodeConfig ->
345320
SyncNodeParams ->
346-
Bool ->
347321
RunMigration ->
348322
IO SyncEnv
349-
mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemStart syncNodeConfigFromFile syncNP ranMigrations runMigrationFnc = do
323+
mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemStart syncNodeConfigFromFile syncNP runMigrationFnc = do
350324
dbCNamesVar <- newTVarIO =<< dbConstraintNamesExists backend
351325
cache <-
352326
if soptCache syncOptions
@@ -360,7 +334,6 @@ mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemS
360334
}
361335
else pure useNoCache
362336
consistentLevelVar <- newTVarIO Unchecked
363-
fixDataVar <- newTVarIO $ if ranMigrations then DataFixRan else NoneFixRan
364337
indexesVar <- newTVarIO $ enpForceIndexes syncNP
365338
bts <- getBootstrapInProgress trce (isTxOutConsumedBootstrap' syncNodeConfigFromFile) backend
366339
bootstrapVar <- newTVarIO bts
@@ -402,7 +375,6 @@ mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemS
402375
, envCurrentEpochNo = epochVar
403376
, envEpochSyncTime = epochSyncTime
404377
, envIndexes = indexesVar
405-
, envIsFixed = fixDataVar
406378
, envLedgerEnv = ledgerEnvType
407379
, envNetworkMagic = nwMagic
408380
, envOffChainPoolResultQueue = oprq
@@ -426,12 +398,10 @@ mkSyncEnvFromConfig ::
426398
GenesisConfig ->
427399
SyncNodeConfig ->
428400
SyncNodeParams ->
429-
-- | migrations were ran on startup
430-
Bool ->
431401
-- | run migration function
432402
RunMigration ->
433403
IO (Either SyncNodeError SyncEnv)
434-
mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeConfigFromFile syncNodeParams ranMigration runMigrationFnc =
404+
mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeConfigFromFile syncNodeParams runMigrationFnc =
435405
case genCfg of
436406
GenesisCardano _ bCfg sCfg _ _
437407
| unProtocolMagicId (Byron.configProtocolMagicId bCfg) /= Shelley.sgNetworkMagic (scConfig sCfg) ->
@@ -467,7 +437,6 @@ mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeCon
467437
(SystemStart . Byron.gdStartTime $ Byron.configGenesisData bCfg)
468438
syncNodeConfigFromFile
469439
syncNodeParams
470-
ranMigration
471440
runMigrationFnc
472441

473442
-- | 'True' is for in memory points and 'False' for on disk

cardano-db-sync/src/Cardano/DbSync/Api/Types.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Cardano.DbSync.Api.Types (
88
InsertOptions (..),
99
LedgerEnv (..),
1010
RunMigration,
11-
FixesRan (..),
1211
ConsistentLevel (..),
1312
CurrentEpochNo (..),
1413
) where
@@ -46,7 +45,6 @@ data SyncEnv = SyncEnv
4645
, envCurrentEpochNo :: !(StrictTVar IO CurrentEpochNo)
4746
, envEpochSyncTime :: !(StrictTVar IO UTCTime)
4847
, envIndexes :: !(StrictTVar IO Bool)
49-
, envIsFixed :: !(StrictTVar IO FixesRan)
5048
, envBootstrap :: !(StrictTVar IO Bool)
5149
, envLedgerEnv :: !LedgerEnv
5250
, envNetworkMagic :: !NetworkMagic
@@ -64,8 +62,6 @@ data SyncOptions = SyncOptions
6462
{ soptEpochAndCacheEnabled :: !Bool
6563
, soptAbortOnInvalid :: !Bool
6664
, soptCache :: !Bool
67-
, soptSkipFix :: !Bool
68-
, soptOnlyFix :: !Bool
6965
, soptPruneConsumeMigration :: !DB.PruneConsumeMigration
7066
, soptInsertOptions :: !InsertOptions
7167
, snapshotEveryFollowing :: !Word64
@@ -98,8 +94,6 @@ data LedgerEnv where
9894

9995
type RunMigration = DB.MigrationToRun -> IO ()
10096

101-
data FixesRan = NoneFixRan | DataFixRan | AllFixRan
102-
10397
data ConsistentLevel = Consistent | DBAheadOfLedger | Unchecked
10498
deriving (Show, Eq)
10599

cardano-db-sync/src/Cardano/DbSync/Config/Types.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ data SyncNodeParams = SyncNodeParams
103103
, enpPGPassSource :: !PGPassSource
104104
, enpEpochDisabled :: !Bool
105105
, enpHasCache :: !Bool
106-
, enpSkipFix :: !Bool
107-
, enpOnlyFix :: !Bool
108106
, enpForceIndexes :: !Bool
109107
, enpHasInOut :: !Bool
110108
, enpSnEveryFollowing :: !Word64

cardano-db-sync/src/Cardano/DbSync/Sync.hs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -201,33 +201,31 @@ dbSyncProtocols syncEnv metricsSetters tc codecConfig version bversion =
201201
localChainSyncPtcl = InitiatorProtocolOnly $
202202
MiniProtocolCb $ \_ctx channel ->
203203
liftIO . logException tracer "ChainSyncWithBlocksPtcl: " $ do
204-
when True $ do
205-
logInfo tracer "Starting ChainSync client"
206-
setConsistentLevel syncEnv Unchecked
204+
logInfo tracer "Starting ChainSync client"
205+
setConsistentLevel syncEnv Unchecked
207206

208-
(latestPoints, currentTip) <- waitRestartState tc
209-
let (inMemory, onDisk) = List.span snd latestPoints
210-
logInfo tracer $
211-
mconcat
212-
[ "Suggesting intersection points from memory: "
213-
, textShow (fst <$> inMemory)
214-
, " and from disk: "
215-
, textShow (fst <$> onDisk)
216-
]
217-
void $
218-
runPipelinedPeer
219-
localChainSyncTracer
220-
(cChainSyncCodec codecs)
221-
channel
222-
( chainSyncClientPeerPipelined $
223-
chainSyncClient metricsSetters tracer (fst <$> latestPoints) currentTip tc
224-
)
225-
atomically $ writeDbActionQueue tc DbFinish
226-
-- We should return leftover bytes returned by 'runPipelinedPeer', but
227-
-- client application do not care about them (it's only important if one
228-
-- would like to restart a protocol on the same mux and thus bearer).
229-
pure ()
230-
pure ((), Nothing)
207+
(latestPoints, currentTip) <- waitRestartState tc
208+
let (inMemory, onDisk) = List.span snd latestPoints
209+
logInfo tracer $
210+
mconcat
211+
[ "Suggesting intersection points from memory: "
212+
, textShow (fst <$> inMemory)
213+
, " and from disk: "
214+
, textShow (fst <$> onDisk)
215+
]
216+
void $
217+
runPipelinedPeer
218+
localChainSyncTracer
219+
(cChainSyncCodec codecs)
220+
channel
221+
( chainSyncClientPeerPipelined $
222+
chainSyncClient metricsSetters tracer (fst <$> latestPoints) currentTip tc
223+
)
224+
atomically $ writeDbActionQueue tc DbFinish
225+
-- We should return leftover bytes returned by 'runPipelinedPeer', but
226+
-- client application do not care about them (it's only important if one
227+
-- would like to restart a protocol on the same mux and thus bearer).
228+
pure ()
231229

232230
dummylocalTxSubmit :: RunMiniProtocolWithMinimalCtx 'InitiatorMode LocalAddress BSL.ByteString IO () Void
233231
dummylocalTxSubmit =

cardano-db-sync/test/Cardano/DbSync/Gen.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ syncNodeParams =
7070
<*> Gen.bool
7171
<*> Gen.bool
7272
<*> Gen.bool
73-
<*> Gen.bool
74-
<*> Gen.bool
7573
<*> Gen.word64 (Range.linear 0 1000)
7674
<*> Gen.word64 (Range.linear 0 1000)
7775
<*> pure Nothing

cardano-db-tool/app/cardano-db-tool.hs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ data Command
3737
= CmdCreateMigration !MigrationDir !TxOutTableType
3838
| CmdReport !Report !TxOutTableType
3939
| CmdRollback !SlotNo !TxOutTableType
40-
| CmdRunMigrations !MigrationDir !Bool !Bool !(Maybe LogFileDir) !TxOutTableType
40+
| CmdRunMigrations !MigrationDir !Bool !(Maybe LogFileDir) !TxOutTableType
4141
| CmdTxOutMigration !TxOutTableType
4242
| CmdUtxoSetAtBlock !Word64 !TxOutTableType
4343
| CmdPrepareSnapshot !PrepareSnapshotArgs
@@ -51,7 +51,7 @@ runCommand cmd =
5151
CmdCreateMigration mdir txOutAddressType -> runCreateMigration mdir txOutAddressType
5252
CmdReport report txOutAddressType -> runReport report txOutAddressType
5353
CmdRollback slotNo txOutAddressType -> runRollback slotNo txOutAddressType
54-
CmdRunMigrations mdir forceIndexes mockFix mldir txOutTabletype -> do
54+
CmdRunMigrations mdir forceIndexes mldir txOutTabletype -> do
5555
pgConfig <- runOrThrowIODb (readPGPass PGPassDefaultEnv)
5656
unofficial <- snd <$> runMigrations pgConfig False mdir mldir Initial txOutTabletype
5757
unless (null unofficial) $
@@ -60,9 +60,6 @@ runCommand cmd =
6060
when forceIndexes $
6161
void $
6262
runMigrations pgConfig False mdir mldir Indexes txOutTabletype
63-
when mockFix $
64-
void $
65-
runMigrations pgConfig False mdir mldir Fix txOutTabletype
6663
CmdTxOutMigration txOutTableType -> do
6764
runWithConnectionNoLogging PGPassDefaultEnv $ migrateTxOutDbTool txOutTableType
6865
CmdUtxoSetAtBlock blkid txOutAddressType -> utxoSetAtSlot txOutAddressType blkid
@@ -170,7 +167,6 @@ pCommand =
170167
CmdRunMigrations
171168
<$> pMigrationDir
172169
<*> pForceIndexes
173-
<*> pMockFix
174170
<*> optional pLogFileDir
175171
<*> pTxOutTableType
176172

@@ -232,20 +228,6 @@ pForceIndexes =
232228
)
233229
)
234230

235-
pMockFix :: Parser Bool
236-
pMockFix =
237-
Opt.flag
238-
False
239-
True
240-
( Opt.long "mock-fix"
241-
<> Opt.help
242-
( mconcat
243-
[ "Mocks the execution of the fix chainsync procedure"
244-
, " By using this flag, db-sync later won't run the fixing procedures."
245-
]
246-
)
247-
)
248-
249231
pTxOutTableType :: Parser TxOutTableType
250232
pTxOutTableType =
251233
Opt.flag

0 commit comments

Comments
 (0)