Skip to content

Commit

Permalink
Merge #445
Browse files Browse the repository at this point in the history
445: CAD-391 eliding messages r=CodiePP a=CodiePP

prints first and last message of range of equivalent 'TraceLedgerReplayEvent'.
```
[nixos19:cardano.node.ChainDB:Info:64] [2019-12-24 23:26:57.00 UTC] {"event":{"kind":"TraceOpenEvent.OpenedVolDB"},"kind":"TraceEvent","tip":"genesis(origin)"}
[nixos19:cardano.node.ChainDB:Info:64] [2019-12-24 23:26:57.31 UTC] {"event":{"snapshot":{"snapshot":"DiskSnapshot 9","kind":"snapshot"},"kind":"TraceLedgerReplayEvent.ReplayFromSnapshot","tip":"Tip (At (Block {blockPointSlot = SlotNo {unSlotNo = 3549092}, blockPointHash = ByronHash {unByronHash = AbstractHash 2cfa35fe9617a9c41ef5ec19bed50742e587ab10d18ce6ac80c09bf71308fc3e}}))"},"kind":"TraceEvent","tip":"genesis(origin)"}
[nixos19:cardano.node.ChainDB:Info:64] [2019-12-24 23:26:57.39 UTC] {"event":{"snapshot":{"snapshot":"DiskSnapshot 9","kind":"snapshot"},"kind":"TraceLedgerReplayEvent.ReplayFromSnapshot","tip":"Tip (At (Block {blockPointSlot = SlotNo {unSlotNo = 3549092}, blockPointHash = ByronHash {unByronHash = AbstractHash 2cfa35fe9617a9c41ef5ec19bed50742e587ab10d18ce6ac80c09bf71308fc3e}}))"},"kind":"TraceEvent","tip":"genesis(origin)"}
[nixos19:cardano.node.ChainDB:Info:64] [2019-12-24 23:26:57.39 UTC] messages elided in total = 70
[nixos19:cardano.node.ChainDB:Info:64] [2019-12-24 23:26:57.39 UTC] {"event":{"kind":"TraceOpenEvent.OpenedLgrDB"},"kind":"TraceEvent","tip":"genesis(origin)"}
```

Co-authored-by: Alexander Diemand <[email protected]>
  • Loading branch information
iohk-bors[bot] and CodiePP authored Jan 8, 2020
2 parents 21a52a7 + cdfe112 commit eba1daf
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 18 deletions.
6 changes: 6 additions & 0 deletions benchmarking/chain-sync/benchmark-chain-sync-mainnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ DATADIR=state-node-mainnet
mkdir -p $DATADIR
cd $DATADIR

# remove blockchain
if [ -d db-mainnet-0 ]; then
rm -rf db-mainnet-0
fi

# remove old log files
rm node-0*

#set -euo pipefail
Expand All @@ -21,6 +24,7 @@ ulimit -t $CPU_TIME_LIMIT
date --iso-8601=seconds > STARTTIME

NODE="cabal v2-run exe:cardano-node -- "
NODE="stack --nix exec cardano-node -- "

exec ${NODE} \
--genesis-file ${BASEDIR}/../../configuration/mainnet-genesis.json \
Expand All @@ -32,7 +36,9 @@ exec ${NODE} \
--host-addr 127.0.0.1 \
--port 7778 \
--tracing-verbosity-maximal \
--trace-block-fetch-decisions \
--trace-mempool \
--trace-chain-db \
--trace-forge \
\
$@
Expand Down
2 changes: 1 addition & 1 deletion benchmarking/chain-sync/cardano-byron-proxy.git
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ defaultBackends:
hasEKG: 12789

# if wanted, the Prometheus interface is using this port:
hasPrometheus: 12799
hasPrometheus:
- "localhost"
- 12799

# here we set up outputs of logging in 'katip':
setupScribes:
Expand Down
10 changes: 5 additions & 5 deletions benchmarking/chain-sync/configuration/log-configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# global filter; messages must have at least this severity to pass:
minSeverity: Notice
minSeverity: Debug

# global file rotation settings:
rotation:
Expand Down Expand Up @@ -68,6 +68,8 @@ options:
# Change the `subtrace` value to `Neutral` in order to log
# `UTxO`-related messages during epoch validation.
subtrace: NoTrace
'cardano.#messagecounters':
subtrace: NoTrace
'#messagecounters.aggregation':
subtrace: NoTrace
'#messagecounters.monitoring':
Expand All @@ -84,17 +86,15 @@ options:
cardano.epoch-validation.benchmark:
- AggregationBK
'cardano.node.peers.BlockFetchDecision':
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
'cardano.node.ChainDB':
- KatipBK
- kind: UserDefinedBK
name: LiveViewBackend
'cardano.node.metrics.ChainDB':
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
cardano.node.metrics:
- EKGViewBK
- kind: UserDefinedBK
name: LiveViewBackend
##########################################################
Expand Down
5 changes: 4 additions & 1 deletion benchmarking/chain-sync/launch_mainnet_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ set -euo pipefail

cd ${TARGETDIR}

cabal v2-run exe:cardano-byron-proxy -- \
RUNNER="cabal v2-run exe:cardano-byron-proxy --"
RUNNER="stack --nix exec cardano-byron-proxy --"

${RUNNER} \
+RTS -T -RTS \
--database-path state-proxy-mainnet/db \
--index-path state-proxy-mainnet/index \
Expand Down
2 changes: 1 addition & 1 deletion benchmarking/cluster3nodes/cardano-explorer.git
Submodule cardano-explorer.git updated 99 files
+1 −0 .gitignore
+4 −2 Readme.md
+13 −7 cabal.project
+7 −0 cardano-explorer-db/CHANGELOG.md
+2 −1 cardano-explorer-db/cardano-explorer-db.cabal
+6 −6 cardano-explorer-db/src/Explorer/DB/Run.hs
+32 −0 cardano-explorer-db/test/Test/Property/Upstream.hs
+3 −1 cardano-explorer-db/test/test.hs
+4 −0 cardano-explorer-node/CHANGELOG.md
+1 −1 cardano-explorer-node/cardano-explorer-node.cabal
+25 −16 cardano-explorer-node/src/Explorer/Node.hs
+36 −0 cardano-explorer-webapi/CHANGELOG.md
+0 −0 cardano-explorer-webapi/LICENSE
+0 −0 cardano-explorer-webapi/Setup.hs
+66 −0 cardano-explorer-webapi/app/Explorer/Web/Random.hs
+93 −0 cardano-explorer-webapi/app/Explorer/Web/Validate.hs
+0 −0 cardano-explorer-webapi/app/cardano-explorer-webapi.hs
+0 −0 cardano-explorer-webapi/app/cardano-webapi-compare.hs
+59 −0 cardano-explorer-webapi/app/cardano-webapi-validate.hs
+22 −28 cardano-explorer-webapi/cardano-explorer-webapi.cabal
+2 −2 cardano-explorer-webapi/shell.nix
+16 −0 cardano-explorer-webapi/src/Explorer/Web.hs
+0 −2 cardano-explorer-webapi/src/Explorer/Web/Api.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/HttpBridge.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/HttpBridge/AddressBalance.hs
+16 −32 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy.hs
+24 −15 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/AddressSummary.hs
+14 −9 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/BlockAddress.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/BlockPagesTotal.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/BlocksPages.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/BlocksTxs.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/EpochPage.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/EpochSlot.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/GenesisAddress.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/GenesisPages.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/GenesisSummary.hs
+6 −3 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/RedeemSummary.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/StatsTxs.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/TxLast.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/TxsSummary.hs
+0 −0 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/Types.hs
+3 −4 cardano-explorer-webapi/src/Explorer/Web/Api/Legacy/Util.hs
+11 −8 cardano-explorer-webapi/src/Explorer/Web/ClientTypes.hs
+8 −0 cardano-explorer-webapi/src/Explorer/Web/Error.hs
+37 −48 cardano-explorer-webapi/src/Explorer/Web/Query.hs
+16 −77 cardano-explorer-webapi/src/Explorer/Web/Server.hs
+0 −9 cardano-explorer/CHANGELOG.md
+0 −6 cardano-explorer/app/mock.hs
+0 −5 cardano-explorer/src/Explorer/Web.hs
+0 −32 cardano-explorer/src/Explorer/Web/Api/V1.hs
+0 −24 cardano-explorer/src/Explorer/Web/Api/V1/BlockAddress.hs
+0 −24 cardano-explorer/src/Explorer/Web/Api/V1/Types.hs
+0 −8 cardano-explorer/src/Explorer/Web/TestServer.hs
+0 −187 cardano-explorer/test/Test/IO/Explorer/Web/Query.hs
+0 −11 cardano-explorer/test/test.hs
+202 −0 cardano-tx-submit/LICENSE
+62 −0 cardano-tx-submit/app/cardano-tx-submit-webapi.hs
+127 −0 cardano-tx-submit/cardano-tx-submit.cabal
+61 −0 cardano-tx-submit/src/Cardano/TxSubmit.hs
+76 −0 cardano-tx-submit/src/Cardano/TxSubmit/Config.hs
+34 −0 cardano-tx-submit/src/Cardano/TxSubmit/Metrics.hs
+216 −0 cardano-tx-submit/src/Cardano/TxSubmit/Node.hs
+47 −0 cardano-tx-submit/src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs
+49 −0 cardano-tx-submit/src/Cardano/TxSubmit/Tx.hs
+63 −0 cardano-tx-submit/src/Cardano/TxSubmit/Types.hs
+30 −0 cardano-tx-submit/src/Cardano/TxSubmit/Util.hs
+69 −0 cardano-tx-submit/src/Cardano/TxSubmit/Web.hs
+3 −0 cardano-tx-submit/test/test.hs
+103 −0 config/tx-submit-mainnet-config.yaml
+3 −3 default.nix
+13 −3 doc/building-running.md
+30 −0 doc/webapi-atomic-requests.md
+13 −10 docker/default.nix
+28 −0 docker/runit.patch
+1 −1 lib.nix
+1 −1 nix/.stack.nix/cardano-explorer-db.nix
+1 −1 nix/.stack.nix/cardano-explorer-node.nix
+16 −20 nix/.stack.nix/cardano-explorer-webapi.nix
+120 −0 nix/.stack.nix/cardano-tx-submit.nix
+12 −1 nix/.stack.nix/default.nix
+2 −2 nix/.stack.nix/io-sim-classes.nix
+2 −2 nix/.stack.nix/network-mux.nix
+5 −2 nix/.stack.nix/ouroboros-consensus.nix
+3 −3 nix/.stack.nix/ouroboros-network.nix
+2 −2 nix/.stack.nix/typed-protocols-cbor.nix
+2 −2 nix/.stack.nix/typed-protocols.nix
+7 −10 nix/nixos/cardano-exporter-service.nix
+1 −1 nix/nixos/graphql-engine/default.nix
+6 −6 nix/nixos/graphql-engine/graphql-engine.nix
+2 −2 nix/nixos/graphql-engine/pg-client.nix
+7 −0 nix/nixos/graphql-engine/test.nix
+1 −5 nix/pkgs.nix
+10 −10 nix/sources.json
+1 −1 nix/util.nix
+1 −1 release.nix
+48 −0 schema/migration-2-0010-20191126.sql
+1 −1 schema/migration-3-0001-20190816.sql
+3 −3 scripts/postgresql-setup.sh
+5 −2 stack.yaml
18 changes: 12 additions & 6 deletions cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import Ouroboros.Network.TxSubmission.Outbound
(TraceTxSubmissionOutbound)

import qualified Ouroboros.Storage.ChainDB as ChainDB
import Ouroboros.Storage.Common (EpochNo (..))
import qualified Ouroboros.Storage.LedgerDB.OnDisk as LedgerDB

-- | Tracing wrapper which includes current tip in the logs (thus it requires
Expand Down Expand Up @@ -233,7 +234,8 @@ instance DefineSeverity (ChainDB.TraceEvent blk) where
defineSeverity (ChainDB.TraceLedgerReplayEvent ev) = case ev of
LedgerDB.ReplayFromGenesis {} -> Info
LedgerDB.ReplayFromSnapshot {} -> Info
_ -> Debug
LedgerDB.ReplayedBlock {} -> Info

defineSeverity (ChainDB.TraceLedgerEvent ev) = case ev of
LedgerDB.TookSnapshot {} -> Info
LedgerDB.DeletedSnapshot {} -> Debug
Expand All @@ -251,9 +253,9 @@ instance DefineSeverity (ChainDB.TraceEvent blk) where
ChainDB.OpenedDB {} -> Info
ChainDB.ClosedDB {} -> Info
ChainDB.ReopenedDB {} -> Debug
ChainDB.OpenedImmDB {} -> Debug
ChainDB.OpenedVolDB -> Debug
ChainDB.OpenedLgrDB -> Debug
ChainDB.OpenedImmDB {} -> Info
ChainDB.OpenedVolDB -> Info
ChainDB.OpenedLgrDB -> Info

defineSeverity (ChainDB.TraceReaderEvent ev) = case ev of
ChainDB.NewReader {} -> Info
Expand Down Expand Up @@ -473,7 +475,8 @@ readableChainDBTracer tracer = Tracer $ \case
LedgerDB.ReplayFromSnapshot snap tip' _replayTo -> tr $ WithTip tip $
"Replaying ledger from snapshot " <> show snap <> " at " <>
condense tip'
LedgerDB.ReplayedBlock {} -> pure ()
LedgerDB.ReplayedBlock _r (epochno, slotno) _replayTo -> tr $ WithTip tip $
"Replayed block: " <> show (unSlotNo slotno) <> " in epoch: " <> show (unEpochNo epochno)
WithTip tip (ChainDB.TraceLedgerEvent ev) -> case ev of
LedgerDB.TookSnapshot snap pt -> tr $ WithTip tip $
"Took ledger snapshot " <> show snap <> " at " <> condense pt
Expand Down Expand Up @@ -656,7 +659,10 @@ instance (Condense (HeaderHash blk), ProtocolLedgerView blk)
mkObject [ "kind" .= String "TraceLedgerReplayEvent.ReplayFromSnapshot"
, "snapshot" .= toObject verb snap
, "tip" .= show tip' ]
_ -> emptyObject
LedgerDB.ReplayedBlock _ (epochno, slotno) _replayTo ->
mkObject [ "kind" .= String "TraceLedgerReplayEvent.ReplayedBlock"
, "epoch" .= show (unEpochNo epochno)
, "slot" .= show (unSlotNo slotno) ]

toObject MinimalVerbosity (ChainDB.TraceLedgerEvent _ev) = emptyObject -- no output
toObject verb (ChainDB.TraceLedgerEvent ev) = case ev of
Expand Down
37 changes: 34 additions & 3 deletions cardano-node/src/Cardano/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Cardano.BM.Data.Aggregated (Measurable (..))
import Cardano.BM.Data.LogItem (LOContent (..), LogObject (..),
PrivacyAnnotation (Confidential),
mkLOMeta)
import Cardano.BM.ElidingTracer
import Cardano.BM.Tracing
import Cardano.BM.Trace (traceNamedObject)
import Cardano.BM.Data.Tracer (WithSeverity (..), addName,
Expand Down Expand Up @@ -118,6 +119,26 @@ nullTracers = Tracers {
muxTracer = nullTracer
}


instance ElidingTracer
(WithSeverity (WithTip blk (ChainDB.TraceEvent blk))) where
-- equivalent by type and severity
isEquivalent (WithSeverity s1 (WithTip _tip1 (ChainDB.TraceLedgerReplayEvent _ev1)))
(WithSeverity s2 (WithTip _tip2 (ChainDB.TraceLedgerReplayEvent _ev2))) = s1 == s2
isEquivalent (WithSeverity s1 (WithTip _tip1 (ChainDB.TraceGCEvent _ev1)))
(WithSeverity s2 (WithTip _tip2 (ChainDB.TraceGCEvent _ev2))) = s1 == s2
isEquivalent _ _ = False
-- the types to be elided
doelide (WithSeverity _ (WithTip _ (ChainDB.TraceLedgerReplayEvent _))) = True
doelide (WithSeverity _ (WithTip _ (ChainDB.TraceGCEvent _))) = True
doelide _ = False
conteliding _tform _tverb _tr _ (Nothing, _count) = return (Nothing, 0)
conteliding _tform _tverb tr ev (_old, count) = do
when (count > 0 && count `mod` 100 == 0) $ do -- report every 100th elided message
meta <- mkLOMeta (defineSeverity ev) (definePrivacyAnnotation ev)
traceNamedObject tr (meta, LogValue "messages elided so far" (PureI $ toInteger count))
return (Just ev, count + 1)

-- | Smart constructor of 'NodeTraces'.
--
mkTracers :: forall peer blk.
Expand Down Expand Up @@ -145,11 +166,13 @@ mkTracers traceOptions tracer = do
-- a block.
-- txsOutcomeExtractor <- mkOutcomeExtractor

elided <- newstate -- for eliding messages in ChainDB tracer

pure Tracers
{ chainDBTracer
= tracerOnOff (traceChainDB traceOptions)
$ annotateSeverity
$ teeTraceChainTip StructuredLogging tracingVerbosity
$ teeTraceChainTip StructuredLogging tracingVerbosity elided
$ addName "ChainDB" tracer
, consensusTracers
= mkConsensusTracers forgeTracers traceOptions
Expand Down Expand Up @@ -191,11 +214,19 @@ mkTracers traceOptions tracer = do

teeTraceChainTip :: TracingFormatting
-> TracingVerbosity
-> MVar (Maybe (WithSeverity (WithTip blk (ChainDB.TraceEvent blk))), Int)
-> Tracer IO (LogObject Text)
-> Tracer IO (WithSeverity (WithTip blk (ChainDB.TraceEvent blk)))
teeTraceChainTip tform tverb tr = Tracer $ \ev -> do
teeTraceChainTip tform tverb elided tr = Tracer $ \ev -> do
traceWith (teeTraceChainTip' tr) ev
traceWith (toLogObject' tform tverb tr) ev
traceWith (teeTraceChainTipElide tform tverb elided tr) ev
teeTraceChainTipElide :: TracingFormatting
-> TracingVerbosity
-> MVar (Maybe (WithSeverity (WithTip blk (ChainDB.TraceEvent blk))), Int)
-> Tracer IO (LogObject Text)
-> Tracer IO (WithSeverity (WithTip blk (ChainDB.TraceEvent blk)))
teeTraceChainTipElide = elideToLogObject

teeTraceChainTip' :: Tracer IO (LogObject Text)
-> Tracer IO (WithSeverity (WithTip blk (ChainDB.TraceEvent blk)))
teeTraceChainTip' tr =
Expand Down

0 comments on commit eba1daf

Please sign in to comment.