diff --git a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs index e9414732a..759a7c5fc 100644 --- a/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs +++ b/cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs @@ -122,8 +122,6 @@ data CommandLineArgs = CommandLineArgs , claEpochDisabled :: Bool , claHasCache :: Bool , claHasLedger :: Bool - , claSkipFix :: Bool - , claOnlyFix :: Bool , claForceIndexes :: Bool , claHasMultiAssets :: Bool , claHasMetadata :: Bool @@ -286,8 +284,6 @@ mkSyncNodeParams staticDir mutableDir CommandLineArgs {..} = do , enpPGPassSource = DB.PGPassCached pgconfig , enpEpochDisabled = claEpochDisabled , enpHasCache = claHasCache - , enpSkipFix = claSkipFix - , enpOnlyFix = claOnlyFix , enpForceIndexes = claForceIndexes , enpHasInOut = True , enpSnEveryFollowing = 35 @@ -361,8 +357,6 @@ initCommandLineArgs = , claEpochDisabled = True , claHasCache = True , claHasLedger = True - , claSkipFix = True - , claOnlyFix = False , claForceIndexes = False , claHasMultiAssets = True , claHasMetadata = True diff --git a/cardano-db-sync/app/cardano-db-sync.hs b/cardano-db-sync/app/cardano-db-sync.hs index 62f7d1bf6..9979a892c 100644 --- a/cardano-db-sync/app/cardano-db-sync.hs +++ b/cardano-db-sync/app/cardano-db-sync.hs @@ -46,7 +46,7 @@ main = do -- Or to ignore ledger and not specify the state (Nothing, LedgerIgnore) -> error stateDirErrorMsg -- Otherwise, it's OK - _ -> pure () + _otherwise -> pure () let prometheusPort = dncPrometheusPort syncNodeConfigFromFile withMetricSetters prometheusPort $ \metricsSetters -> @@ -87,8 +87,6 @@ pRunDbSyncNode = do <*> pPGPassSource <*> pEpochDisabled <*> pHasCache - <*> pSkipFix - <*> pOnlyFix <*> pForceIndexes <*> pHasInOut <*> pure 500 @@ -144,15 +142,6 @@ pEpochDisabled = <> Opt.help "Makes epoch table remain empty" ) -pSkipFix :: Parser Bool -pSkipFix = - Opt.flag - False - True - ( Opt.long "skip-fix" - <> Opt.help "Disables the db-sync fix procedure for the wrong datum and redeemer_data bytes." - ) - pForceIndexes :: Parser Bool pForceIndexes = Opt.flag @@ -162,18 +151,6 @@ pForceIndexes = <> Opt.help "Forces the Index creation at the start of db-sync. Normally they're created later." ) -pOnlyFix :: Parser Bool -pOnlyFix = - Opt.flag - False - True - ( Opt.long "fix-only" - <> Opt.help - "Runs only the db-sync fix procedure for the wrong datum, redeemer_data and plutus script bytes and exits. \ - \This doesn't run any migrations. This can also be ran on previous schema, ie 13.0 13.1 to fix the issues without \ - \bumping the schema version minor number." - ) - pHasCache :: Parser Bool pHasCache = Opt.flag diff --git a/cardano-db-sync/src/Cardano/DbSync.hs b/cardano-db-sync/src/Cardano/DbSync.hs index 9df654d4c..ada70cb44 100644 --- a/cardano-db-sync/src/Cardano/DbSync.hs +++ b/cardano-db-sync/src/Cardano/DbSync.hs @@ -125,7 +125,6 @@ runDbSync metricsSetters knownMigrations iomgr trce params syncNodeConfigFromFil trce iomgr connectionString - ranMigrations (void . runMigration) syncNodeConfigFromFile params @@ -153,15 +152,13 @@ runSyncNode :: Trace IO Text -> IOManager -> ConnectionString -> - -- | migrations were ran on startup - Bool -> -- | run migration function RunMigration -> SyncNodeConfig -> SyncNodeParams -> SyncOptions -> IO () -runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc syncNodeConfigFromFile syncNodeParams syncOptions = do +runSyncNode metricsSetters trce iomgr dbConnString runMigrationFnc syncNodeConfigFromFile syncNodeParams syncOptions = do whenJust maybeLedgerDir $ \enpLedgerStateDir -> do createDirectoryIfMissing True (unLedgerStateDir enpLedgerStateDir) @@ -188,7 +185,6 @@ runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc genCfg syncNodeConfigFromFile syncNodeParams - ranMigrations runMigrationFnc -- Warn the user that jsonb datatypes are being removed from the database schema. @@ -246,8 +242,6 @@ extractSyncOptions snp aop snc = && not (enpEpochDisabled snp || not (enpHasCache snp)) , soptAbortOnInvalid = aop , soptCache = enpHasCache snp - , soptSkipFix = enpSkipFix snp - , soptOnlyFix = enpOnlyFix snp , soptPruneConsumeMigration = initPruneConsumeMigration isTxOutConsumed' diff --git a/cardano-db-sync/src/Cardano/DbSync/Api.hs b/cardano-db-sync/src/Cardano/DbSync/Api.hs index 02f0b9745..88a067898 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Api.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Api.hs @@ -13,11 +13,6 @@ module Cardano.DbSync.Api ( getConsistentLevel, isConsistent, getIsConsumedFixed, - noneFixed, - isDataFixed, - getIsSyncFixed, - setIsFixed, - setIsFixedAndMigrate, getDisableInOutState, getRanIndexes, runIndexMigrations, @@ -125,26 +120,6 @@ getIsConsumedFixed env = pcm = soptPruneConsumeMigration $ envOptions env backend = envBackend env -noneFixed :: FixesRan -> Bool -noneFixed NoneFixRan = True -noneFixed _ = False - -isDataFixed :: FixesRan -> Bool -isDataFixed DataFixRan = True -isDataFixed _ = False - -getIsSyncFixed :: SyncEnv -> IO FixesRan -getIsSyncFixed = readTVarIO . envIsFixed - -setIsFixed :: SyncEnv -> FixesRan -> IO () -setIsFixed env fr = do - atomically $ writeTVar (envIsFixed env) fr - -setIsFixedAndMigrate :: SyncEnv -> FixesRan -> IO () -setIsFixedAndMigrate env fr = do - envRunDelayedMigration env DB.Fix - atomically $ writeTVar (envIsFixed env) fr - getDisableInOutState :: SyncEnv -> IO Bool getDisableInOutState syncEnv = do bst <- readTVarIO $ envBootstrap syncEnv @@ -343,10 +318,9 @@ mkSyncEnv :: SystemStart -> SyncNodeConfig -> SyncNodeParams -> - Bool -> RunMigration -> IO SyncEnv -mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemStart syncNodeConfigFromFile syncNP ranMigrations runMigrationFnc = do +mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemStart syncNodeConfigFromFile syncNP runMigrationFnc = do dbCNamesVar <- newTVarIO =<< dbConstraintNamesExists backend cache <- if soptCache syncOptions @@ -360,7 +334,6 @@ mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemS } else pure useNoCache consistentLevelVar <- newTVarIO Unchecked - fixDataVar <- newTVarIO $ if ranMigrations then DataFixRan else NoneFixRan indexesVar <- newTVarIO $ enpForceIndexes syncNP bts <- getBootstrapInProgress trce (isTxOutConsumedBootstrap' syncNodeConfigFromFile) backend bootstrapVar <- newTVarIO bts @@ -402,7 +375,6 @@ mkSyncEnv trce backend connectionString syncOptions protoInfo nw nwMagic systemS , envCurrentEpochNo = epochVar , envEpochSyncTime = epochSyncTime , envIndexes = indexesVar - , envIsFixed = fixDataVar , envLedgerEnv = ledgerEnvType , envNetworkMagic = nwMagic , envOffChainPoolResultQueue = oprq @@ -426,12 +398,10 @@ mkSyncEnvFromConfig :: GenesisConfig -> SyncNodeConfig -> SyncNodeParams -> - -- | migrations were ran on startup - Bool -> -- | run migration function RunMigration -> IO (Either SyncNodeError SyncEnv) -mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeConfigFromFile syncNodeParams ranMigration runMigrationFnc = +mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeConfigFromFile syncNodeParams runMigrationFnc = case genCfg of GenesisCardano _ bCfg sCfg _ _ | unProtocolMagicId (Byron.configProtocolMagicId bCfg) /= Shelley.sgNetworkMagic (scConfig sCfg) -> @@ -467,7 +437,6 @@ mkSyncEnvFromConfig trce backend connectionString syncOptions genCfg syncNodeCon (SystemStart . Byron.gdStartTime $ Byron.configGenesisData bCfg) syncNodeConfigFromFile syncNodeParams - ranMigration runMigrationFnc -- | 'True' is for in memory points and 'False' for on disk diff --git a/cardano-db-sync/src/Cardano/DbSync/Api/Types.hs b/cardano-db-sync/src/Cardano/DbSync/Api/Types.hs index ac7e85666..cb10af966 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Api/Types.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Api/Types.hs @@ -8,7 +8,6 @@ module Cardano.DbSync.Api.Types ( InsertOptions (..), LedgerEnv (..), RunMigration, - FixesRan (..), ConsistentLevel (..), CurrentEpochNo (..), ) where @@ -46,7 +45,6 @@ data SyncEnv = SyncEnv , envCurrentEpochNo :: !(StrictTVar IO CurrentEpochNo) , envEpochSyncTime :: !(StrictTVar IO UTCTime) , envIndexes :: !(StrictTVar IO Bool) - , envIsFixed :: !(StrictTVar IO FixesRan) , envBootstrap :: !(StrictTVar IO Bool) , envLedgerEnv :: !LedgerEnv , envNetworkMagic :: !NetworkMagic @@ -64,8 +62,6 @@ data SyncOptions = SyncOptions { soptEpochAndCacheEnabled :: !Bool , soptAbortOnInvalid :: !Bool , soptCache :: !Bool - , soptSkipFix :: !Bool - , soptOnlyFix :: !Bool , soptPruneConsumeMigration :: !DB.PruneConsumeMigration , soptInsertOptions :: !InsertOptions , snapshotEveryFollowing :: !Word64 @@ -98,8 +94,6 @@ data LedgerEnv where type RunMigration = DB.MigrationToRun -> IO () -data FixesRan = NoneFixRan | DataFixRan | AllFixRan - data ConsistentLevel = Consistent | DBAheadOfLedger | Unchecked deriving (Show, Eq) diff --git a/cardano-db-sync/src/Cardano/DbSync/Config/Types.hs b/cardano-db-sync/src/Cardano/DbSync/Config/Types.hs index 813ce2956..333405a7e 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Config/Types.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Config/Types.hs @@ -103,8 +103,6 @@ data SyncNodeParams = SyncNodeParams , enpPGPassSource :: !PGPassSource , enpEpochDisabled :: !Bool , enpHasCache :: !Bool - , enpSkipFix :: !Bool - , enpOnlyFix :: !Bool , enpForceIndexes :: !Bool , enpHasInOut :: !Bool , enpSnEveryFollowing :: !Word64 diff --git a/cardano-db-sync/src/Cardano/DbSync/Sync.hs b/cardano-db-sync/src/Cardano/DbSync/Sync.hs index de827a39d..fb6dc5e32 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Sync.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Sync.hs @@ -201,33 +201,31 @@ dbSyncProtocols syncEnv metricsSetters tc codecConfig version bversion = localChainSyncPtcl = InitiatorProtocolOnly $ MiniProtocolCb $ \_ctx channel -> liftIO . logException tracer "ChainSyncWithBlocksPtcl: " $ do - when True $ do - logInfo tracer "Starting ChainSync client" - setConsistentLevel syncEnv Unchecked + logInfo tracer "Starting ChainSync client" + setConsistentLevel syncEnv Unchecked - (latestPoints, currentTip) <- waitRestartState tc - let (inMemory, onDisk) = List.span snd latestPoints - logInfo tracer $ - mconcat - [ "Suggesting intersection points from memory: " - , textShow (fst <$> inMemory) - , " and from disk: " - , textShow (fst <$> onDisk) - ] - void $ - runPipelinedPeer - localChainSyncTracer - (cChainSyncCodec codecs) - channel - ( chainSyncClientPeerPipelined $ - chainSyncClient metricsSetters tracer (fst <$> latestPoints) currentTip tc - ) - atomically $ writeDbActionQueue tc DbFinish - -- We should return leftover bytes returned by 'runPipelinedPeer', but - -- client application do not care about them (it's only important if one - -- would like to restart a protocol on the same mux and thus bearer). - pure () - pure ((), Nothing) + (latestPoints, currentTip) <- waitRestartState tc + let (inMemory, onDisk) = List.span snd latestPoints + logInfo tracer $ + mconcat + [ "Suggesting intersection points from memory: " + , textShow (fst <$> inMemory) + , " and from disk: " + , textShow (fst <$> onDisk) + ] + void $ + runPipelinedPeer + localChainSyncTracer + (cChainSyncCodec codecs) + channel + ( chainSyncClientPeerPipelined $ + chainSyncClient metricsSetters tracer (fst <$> latestPoints) currentTip tc + ) + atomically $ writeDbActionQueue tc DbFinish + -- We should return leftover bytes returned by 'runPipelinedPeer', but + -- client application do not care about them (it's only important if one + -- would like to restart a protocol on the same mux and thus bearer). + pure () dummylocalTxSubmit :: RunMiniProtocolWithMinimalCtx 'InitiatorMode LocalAddress BSL.ByteString IO () Void dummylocalTxSubmit = diff --git a/cardano-db-sync/test/Cardano/DbSync/Gen.hs b/cardano-db-sync/test/Cardano/DbSync/Gen.hs index 86becae0f..2fbbdb406 100644 --- a/cardano-db-sync/test/Cardano/DbSync/Gen.hs +++ b/cardano-db-sync/test/Cardano/DbSync/Gen.hs @@ -70,8 +70,6 @@ syncNodeParams = <*> Gen.bool <*> Gen.bool <*> Gen.bool - <*> Gen.bool - <*> Gen.bool <*> Gen.word64 (Range.linear 0 1000) <*> Gen.word64 (Range.linear 0 1000) <*> pure Nothing diff --git a/cardano-db-tool/app/cardano-db-tool.hs b/cardano-db-tool/app/cardano-db-tool.hs index 821d4cdcb..66690ac2f 100644 --- a/cardano-db-tool/app/cardano-db-tool.hs +++ b/cardano-db-tool/app/cardano-db-tool.hs @@ -37,7 +37,7 @@ data Command = CmdCreateMigration !MigrationDir !TxOutTableType | CmdReport !Report !TxOutTableType | CmdRollback !SlotNo !TxOutTableType - | CmdRunMigrations !MigrationDir !Bool !Bool !(Maybe LogFileDir) !TxOutTableType + | CmdRunMigrations !MigrationDir !Bool !(Maybe LogFileDir) !TxOutTableType | CmdTxOutMigration !TxOutTableType | CmdUtxoSetAtBlock !Word64 !TxOutTableType | CmdPrepareSnapshot !PrepareSnapshotArgs @@ -51,7 +51,7 @@ runCommand cmd = CmdCreateMigration mdir txOutAddressType -> runCreateMigration mdir txOutAddressType CmdReport report txOutAddressType -> runReport report txOutAddressType CmdRollback slotNo txOutAddressType -> runRollback slotNo txOutAddressType - CmdRunMigrations mdir forceIndexes mockFix mldir txOutTabletype -> do + CmdRunMigrations mdir forceIndexes mldir txOutTabletype -> do pgConfig <- runOrThrowIODb (readPGPass PGPassDefaultEnv) unofficial <- snd <$> runMigrations pgConfig False mdir mldir Initial txOutTabletype unless (null unofficial) $ @@ -60,9 +60,6 @@ runCommand cmd = when forceIndexes $ void $ runMigrations pgConfig False mdir mldir Indexes txOutTabletype - when mockFix $ - void $ - runMigrations pgConfig False mdir mldir Fix txOutTabletype CmdTxOutMigration txOutTableType -> do runWithConnectionNoLogging PGPassDefaultEnv $ migrateTxOutDbTool txOutTableType CmdUtxoSetAtBlock blkid txOutAddressType -> utxoSetAtSlot txOutAddressType blkid @@ -170,7 +167,6 @@ pCommand = CmdRunMigrations <$> pMigrationDir <*> pForceIndexes - <*> pMockFix <*> optional pLogFileDir <*> pTxOutTableType @@ -232,20 +228,6 @@ pForceIndexes = ) ) -pMockFix :: Parser Bool -pMockFix = - Opt.flag - False - True - ( Opt.long "mock-fix" - <> Opt.help - ( mconcat - [ "Mocks the execution of the fix chainsync procedure" - , " By using this flag, db-sync later won't run the fixing procedures." - ] - ) - ) - pTxOutTableType :: Parser TxOutTableType pTxOutTableType = Opt.flag diff --git a/cardano-db/src/Cardano/Db/Migration.hs b/cardano-db/src/Cardano/Db/Migration.hs index 582e40117..be65062c1 100644 --- a/cardano-db/src/Cardano/Db/Migration.hs +++ b/cardano-db/src/Cardano/Db/Migration.hs @@ -101,7 +101,7 @@ data MigrationValidateError = UnknownMigrationsFound instance Exception MigrationValidateError -data MigrationToRun = Initial | Full | Fix | Indexes +data MigrationToRun = Initial | Full | Indexes deriving (Show, Eq) -- | Run the migrations in the provided 'MigrationDir' and write date stamped log file @@ -144,11 +144,9 @@ runMigrations pgconfig quiet migrationDir mLogfiledir mToRun txOutTableType = do filterMigrations scripts = case mToRun of Full -> pure (filter filterIndexesFull scripts, True) Initial -> pure (filter filterInitial scripts, True) - Fix -> pure (filter filterFix scripts, False) Indexes -> do pure (filter filterIndexes scripts, False) - filterFix (mv, _) = mvStage mv == 2 && mvVersion mv > hardCoded3_0 filterIndexesFull (mv, _) = do case txOutTableType of TxOutCore -> True @@ -159,9 +157,6 @@ runMigrations pgconfig quiet migrationDir mLogfiledir mToRun txOutTableType = do TxOutCore -> mvStage mv == 4 TxOutVariantAddress -> mvStage mv == 4 && mvVersion mv > 1 -hardCoded3_0 :: Int -hardCoded3_0 = 19 - -- Build hash for each file found in a directory. validateMigrations :: MigrationDir -> [(Text, Text)] -> IO (Maybe (MigrationValidateError, Bool)) validateMigrations migrationDir knownMigrations = do