Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Try #142:
Browse files Browse the repository at this point in the history
  • Loading branch information
iohk-bors[bot] committed Jan 18, 2021
2 parents 8e1bd4c + a64765e commit f32036c
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 42 deletions.
114 changes: 114 additions & 0 deletions config/launchpad-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion smash-sync/src/Cardano/Sync/SmashDbSync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions smash/src/Cardano/SMASH/DB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,21 @@ 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))

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
Expand Down
3 changes: 2 additions & 1 deletion smash/src/Cardano/SMASH/DBSync/Db/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
69 changes: 35 additions & 34 deletions smash/src/Cardano/SMASH/DBSyncPlugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,13 +156,15 @@ 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
[ "Insert '", show blockName
, "' block pool info: epoch ", show epoch
, ", slot ", show slotWithinEpoch
, ", block ", show blockNumber
, ", global slot ", show globalSlot
]

lift $ transactionSaveWithIsolation Serializable
Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f32036c

Please sign in to comment.