diff --git a/config/launchpad-config.yaml b/config/launchpad-config.yaml new file mode 100644 index 0000000..8deac8c --- /dev/null +++ b/config/launchpad-config.yaml @@ -0,0 +1,114 @@ +# Explorer DB Node configuration +NetworkName: launchpad + +EnableLogMetrics: False +EnableLogging: True + +Protocol: Cardano + +# The config file for the node we are connecting to. If this is not the correct +# config, it will likely lead to db-sync throwing up weird error messages from +# the consensus layer. +# The path to the node config file is relative to this config file. + +NodeConfigFile: /nix/store/s2z0clsfwci7z2g4167nlvf3i0m2wb6s-config-0.json + +# ------------------------------------------------------------------------------ +# Logging configuration follows. + +# global filter; messages must have at least this severity to pass: +minSeverity: Info + +# global file rotation settings: +rotation: + rpLogLimitBytes: 5000000 + rpKeepFilesNum: 10 + rpMaxAgeHours: 24 + +# these backends are initialized: +setupBackends: + - AggregationBK + - KatipBK + # - EditorBK + # - EKGViewBK + +# if not indicated otherwise, then messages are passed to these backends: +defaultBackends: + - KatipBK + +# if wanted, the GUI is listening on this port: +# hasGUI: 12787 + +# if wanted, the EKG interface is listening on this port: +# hasEKG: 12788 + +# here we set up outputs of logging in 'katip': +setupScribes: + - scKind: StdoutSK + scName: stdout + scFormat: ScText + scRotation: null + +# if not indicated otherwise, then log output is directed to this: +defaultScribes: + - - StdoutSK + - stdout + +# more options which can be passed as key-value pairs: +options: + cfokey: + value: "Release-1.0.0" + mapSubtrace: + benchmark: + contents: + - GhcRtsStats + - MonotonicClock + subtrace: ObservableTrace + '#ekgview': + contents: + - - tag: Contains + contents: 'cardano.epoch-validation.benchmark' + - - tag: Contains + contents: .monoclock.basic. + - - tag: Contains + contents: 'cardano.epoch-validation.benchmark' + - - tag: Contains + contents: diff.RTS.cpuNs.timed. + - - tag: StartsWith + contents: '#ekgview.#aggregation.cardano.epoch-validation.benchmark' + - - tag: Contains + contents: diff.RTS.gcNum.timed. + subtrace: FilterTrace + 'cardano.epoch-validation.utxo-stats': + # Change the `subtrace` value to `Neutral` in order to log + # `UTxO`-related messages during epoch validation. + subtrace: NoTrace + '#messagecounters.aggregation': + subtrace: NoTrace + '#messagecounters.ekgview': + subtrace: NoTrace + '#messagecounters.switchboard': + subtrace: NoTrace + '#messagecounters.katip': + subtrace: NoTrace + '#messagecounters.monitoring': + subtrace: NoTrace + 'cardano.#messagecounters.aggregation': + subtrace: NoTrace + 'cardano.#messagecounters.ekgview': + subtrace: NoTrace + 'cardano.#messagecounters.switchboard': + subtrace: NoTrace + 'cardano.#messagecounters.katip': + subtrace: NoTrace + 'cardano.#messagecounters.monitoring': + subtrace: NoTrace + mapBackends: + cardano.epoch-validation.benchmark: + - AggregationBK + '#aggregation.cardano.epoch-validation.benchmark': + - EKGViewBK + mapSeverity: + db-sync-node.Subscription: Error + db-sync-node.Mux: Error + db-sync-node: Info diff --git a/smash-sync/src/Cardano/Sync/SmashDbSync.hs b/smash-sync/src/Cardano/Sync/SmashDbSync.hs index ad0eb38..4ef62b9 100644 --- a/smash-sync/src/Cardano/Sync/SmashDbSync.hs +++ b/smash-sync/src/Cardano/Sync/SmashDbSync.hs @@ -616,7 +616,7 @@ chainSyncClient -> WithOrigin BlockNo -> DbActionQueue -> ChainSyncClientPipelined CardanoBlock (Point CardanoBlock) (Tip CardanoBlock) IO () -chainSyncClient dataLayer metricsLayer trce env queryVar latestPoints currentTip actionQueue = do +chainSyncClient dataLayer metricsLayer trce env queryVar latestPoints currentTip actionQueue = do ChainSyncClientPipelined $ pure $ -- Notify the core node about the our latest points at which we are -- synchronised. This client is not persistent and thus it just diff --git a/smash/src/Cardano/SMASH/DB.hs b/smash/src/Cardano/SMASH/DB.hs index 5ed58d5..d9dbe4e 100644 --- a/smash/src/Cardano/SMASH/DB.hs +++ b/smash/src/Cardano/SMASH/DB.hs @@ -306,7 +306,7 @@ postgresqlDataLayer tracer = DataLayer Right _val -> return $ Right poolId , dlAddGenesisMetaBlock = \meta block -> do - -- This whole function has to be atomic! + -- This is a bit tricky, but will do the job. runExceptT $ do -- Well, in theory this should be handled differently. count <- newExceptT (Right <$> (runDbAction tracer $ queryBlockCount)) @@ -314,10 +314,13 @@ postgresqlDataLayer tracer = DataLayer when (count > 0) $ left $ UnknownError "Shelley.insertValidateGenesisDist: Genesis data mismatch." - metaId <- newExceptT $ runDbAction tracer $ insertMeta $ meta - blockId <- newExceptT $ runDbAction tracer $ insertBlock $ block + -- First wrap it so we chain errors, run it and wrap it again so + -- we match the top level chain of errors. + newExceptT . runDbAction tracer . runExceptT $ do + metaId <- newExceptT $ insertMeta meta + blockId <- newExceptT $ insertBlock block + return (metaId, blockId) - pure (metaId, blockId) , dlGetSlotHash = \slotNo -> runDbAction tracer $ querySlotHash slotNo diff --git a/smash/src/Cardano/SMASH/DBSync/Db/Database.hs b/smash/src/Cardano/SMASH/DBSync/Db/Database.hs index d035207..0ff9b46 100644 --- a/smash/src/Cardano/SMASH/DBSync/Db/Database.hs +++ b/smash/src/Cardano/SMASH/DBSync/Db/Database.hs @@ -57,7 +57,8 @@ runDbStartup plugin trce = -- TODO(KS): Needs a @DataLayer@. -- TODO(KS): Metrics layer! runDbThread - :: Trace IO Text + :: HasCallStack + => Trace IO Text -> DbSyncEnv -> DbSyncNodePlugin -> DbActionQueue diff --git a/smash/src/Cardano/SMASH/DBSyncPlugin.hs b/smash/src/Cardano/SMASH/DBSyncPlugin.hs index 071ba59..4779070 100644 --- a/smash/src/Cardano/SMASH/DBSyncPlugin.hs +++ b/smash/src/Cardano/SMASH/DBSyncPlugin.hs @@ -9,60 +9,59 @@ module Cardano.SMASH.DBSyncPlugin import Cardano.Prelude -import Cardano.BM.Trace (Trace, - logError, logInfo) +import Cardano.BM.Trace (Trace, logError, logInfo) -import Control.Monad.Logger (LoggingT) -import Control.Monad.Trans.Except.Extra (firstExceptT, - newExceptT, - runExceptT) -import Control.Monad.Trans.Reader (ReaderT) +import Control.Monad.Logger (LoggingT) +import Control.Monad.Trans.Except.Extra (firstExceptT, newExceptT, + runExceptT) +import Control.Monad.Trans.Reader (ReaderT) -import Cardano.SMASH.DB (DBFail (..), - DataLayer (..)) -import Cardano.SMASH.Offline (fetchInsertNewPoolMetadata) -import Cardano.SMASH.Types (PoolId (..), - PoolMetadataHash (..), - PoolUrl (..)) +import Cardano.SMASH.DB (DBFail (..), + DataLayer (..)) +import Cardano.SMASH.Offline (fetchInsertNewPoolMetadata) +import Cardano.SMASH.Types (PoolId (..), + PoolMetadataHash (..), + PoolUrl (..)) -import qualified Cardano.Chain.Block as Byron +import qualified Cardano.Chain.Block as Byron -import qualified Data.ByteString.Base16 as B16 +import qualified Data.ByteString.Base16 as B16 -import Database.Persist.Sql (IsolationLevel (..), - SqlBackend, - transactionSaveWithIsolation) +import Database.Persist.Sql (IsolationLevel (..), + SqlBackend, + transactionSaveWithIsolation) -import qualified Cardano.SMASH.DBSync.Db.Insert as DB -import qualified Cardano.SMASH.DBSync.Db.Schema as DB +import qualified Cardano.SMASH.DBSync.Db.Insert as DB +import qualified Cardano.SMASH.DBSync.Db.Schema as DB import Cardano.DbSync.Config.Types import Cardano.DbSync.Error -import Cardano.DbSync.Types as DbSync +import Cardano.DbSync.Types as DbSync import Cardano.DbSync.LedgerState -import Cardano.DbSync (DbSyncNodePlugin (..)) +import Cardano.DbSync (DbSyncNodePlugin (..)) import Cardano.DbSync.Util -import qualified Cardano.DbSync.Era.Byron.Util as Byron -import qualified Cardano.DbSync.Era.Shelley.Generic as Shelley +import qualified Cardano.DbSync.Era.Byron.Util as Byron +import qualified Cardano.DbSync.Era.Shelley.Generic as Shelley -import Cardano.Slotting.Block (BlockNo (..)) -import Cardano.Slotting.Slot (EpochNo (..), - SlotNo (..)) +import Cardano.Slotting.Block (BlockNo (..)) +import Cardano.Slotting.Slot (EpochNo (..), + EpochSize (..), + SlotNo (..)) -import Shelley.Spec.Ledger.BaseTypes (strictMaybeToMaybe) -import qualified Shelley.Spec.Ledger.BaseTypes as Shelley -import qualified Shelley.Spec.Ledger.TxBody as Shelley +import Shelley.Spec.Ledger.BaseTypes (strictMaybeToMaybe) +import qualified Shelley.Spec.Ledger.BaseTypes as Shelley +import qualified Shelley.Spec.Ledger.TxBody as Shelley -import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..)) +import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..)) -import Ouroboros.Consensus.Cardano.Block (HardForkBlock (..), - StandardShelley) +import Ouroboros.Consensus.Cardano.Block (HardForkBlock (..), + StandardShelley) -import qualified Cardano.DbSync.Era.Shelley.Generic as Generic +import qualified Cardano.DbSync.Era.Shelley.Generic as Generic -- |Pass in the @DataLayer@. poolMetadataDbSyncNodePlugin :: DataLayer -> DbSyncNodePlugin @@ -157,6 +156,7 @@ insertShelleyBlock blockName dataLayer tracer env blk _lStateSnap details = do liftIO $ do let epoch = unEpochNo (sdEpochNo details) slotWithinEpoch = unEpochSlot (sdEpochSlot details) + globalSlot = epoch * (unEpochSize $ sdEpochSize details) + slotWithinEpoch when (slotWithinEpoch `mod` 1000 == 0) $ logInfo tracer $ mconcat @@ -164,6 +164,7 @@ insertShelleyBlock blockName dataLayer tracer env blk _lStateSnap details = do , "' block pool info: epoch ", show epoch , ", slot ", show slotWithinEpoch , ", block ", show blockNumber + , ", global slot ", show globalSlot ] lift $ transactionSaveWithIsolation Serializable diff --git a/stack.yaml b/stack.yaml index 3ae771c..31b32b6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,8 +15,8 @@ flags: external-libsodium-vrf: false ghc-options: - smash: -Wall -Werror -fwarn-redundant-constraints - #smash-servant-types: -Wall -Werror -fwarn-redundant-constraints + smash: -Wall -Werror -fno-warn-redundant-constraints + #smash-servant-types: -Wall -Werror -fno-warn-redundant-constraints extra-deps: - persistent-2.11.0.1