Skip to content

Commit

Permalink
Diffusion initialization logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Nov 19, 2020
1 parent 2027e15 commit 7a07ebd
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 34 deletions.
16 changes: 8 additions & 8 deletions cabal.project
Expand Up @@ -91,8 +91,8 @@ package io-sim-classes
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: acac87c7af2652b8d86d92c583b6c29234634866
--sha256: 1awxr663zgkn8dw13pjzzlzzz5y9y5l2fy14f87331gbrw6n2xdg
tag: 6226a0feb1d74f50a430242a1b4608fd48e10aad
--sha256: 034q2anpbc7bgp5draykz6lkzznxk31wy4nbgr4jv4f7778yls6b
subdir:
binary
binary/test
Expand All @@ -110,8 +110,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 8d836e61bb88bda4a6a5c00694735928390067a1
--sha256: 0jpdz2294k5q8c90hbg7s808ypglar94j1rm2x81h69ilsp5g3j3
tag: 9ebcfedb3f93852fbeabfc8ce492ddb4d996b3b5
--sha256: 03n1m2030liv55b2jjjc7ga8w3fkbcxr6xpgsxa0gb9lhx41r4m5
subdir:
byron/chain/executable-spec
byron/crypto
Expand All @@ -129,8 +129,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: bec71e48b027b2022e7be1fb7dd265bbbd80490b
--sha256: 0jnxa9m84ka799a3i863sqvlygzf18941pi00d88ar45qdmzkagm
tag: 58e146c14e1349553d0ed75dd5245bbe65f0533e
--sha256: 166rm0sxldnf0g2g9jp4k0rgd01wcbm0g54fcw3bxilzr1dvwqfi
subdir:
cardano-prelude
cardano-prelude-test
Expand Down Expand Up @@ -159,8 +159,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 35c5950088a7c9fc725868f1e68a2f3bf14f0595
--sha256: 1xizr0r36xnsmkcd1p0c9m1bj918n5bja1p6y30qrbxsph5wn94v
tag: fa6d505a425804e2492aba063d97e7376760df61
--sha256: 00giyn3jad4img05xwf0ic79rkj2hq79hnb7x6777gwm0skrm0rb
subdir:
io-sim
io-sim-classes
Expand Down
8 changes: 1 addition & 7 deletions cardano-api/src/Cardano/Api/KeysPraos.hs
Expand Up @@ -29,8 +29,6 @@ import Data.String (IsString (..))
import qualified Cardano.Crypto.DSIGN.Class as Crypto
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.KES.Class as Crypto
import qualified Cardano.Crypto.Libsodium as Crypto
import qualified Cardano.Crypto.Seed as Crypto
import qualified Cardano.Crypto.VRF.Class as Crypto

import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto)
Expand Down Expand Up @@ -73,11 +71,7 @@ instance Key KesKey where

--This loses the mlock safety of the seed, since it starts from a normal in-memory seed.
deterministicSigningKey :: AsType KesKey -> Crypto.Seed -> SigningKey KesKey
deterministicSigningKey AsKesKey =
KesSigningKey
. Crypto.genKeyKES
. Crypto.mlsbFromByteString
. Crypto.getSeedBytes
deterministicSigningKey AsKesKey = KesSigningKey . Crypto.genKeyKES

deterministicSigningKeySeedSize :: AsType KesKey -> Word
deterministicSigningKeySeedSize AsKesKey =
Expand Down
12 changes: 4 additions & 8 deletions cardano-api/src/Cardano/Api/Script.hs
Expand Up @@ -71,7 +71,6 @@ import qualified Cardano.Ledger.ShelleyMA.Timelocks as Timelock
import Ouroboros.Consensus.Shelley.Eras
(StandardAllegra, StandardMary, StandardShelley,
StandardCrypto)
import Shelley.Spec.Ledger.BaseTypes (StrictMaybe (..))
import qualified Shelley.Spec.Ledger.Keys as Shelley
import qualified Shelley.Spec.Ledger.Scripts as Shelley
import qualified Shelley.Spec.Ledger.Tx as Shelley
Expand Down Expand Up @@ -312,8 +311,8 @@ simpleScriptToTimelock = go
go (RequireAllOf s) = Timelock.RequireAllOf (Seq.fromList (map go s))
go (RequireAnyOf s) = Timelock.RequireAnyOf (Seq.fromList (map go s))
go (RequireMOf m s) = Timelock.RequireMOf m (Seq.fromList (map go s))
go (RequireTimeBefore _ sl) = Timelock.RequireTimeExpire (SJust sl)
go (RequireTimeAfter _ sl) = Timelock.RequireTimeStart (SJust sl)
go (RequireTimeBefore _ sl) = Timelock.RequireTimeExpire sl
go (RequireTimeAfter _ sl) = Timelock.RequireTimeStart sl


scriptToSimpleScript :: Script era -> SimpleScript era
Expand Down Expand Up @@ -348,15 +347,12 @@ timelockToSimpleScript signaturesInEra timeLocksInEra = go
go :: Timelock.Timelock ledgerera -> SimpleScript era
go (Timelock.RequireSignature kh) = RequireSignature signaturesInEra
(PaymentKeyHash (Shelley.coerceKeyRole kh))
go (Timelock.RequireTimeExpire (SJust sl)) = RequireTimeBefore timeLocksInEra sl
go (Timelock.RequireTimeStart (SJust sl)) = RequireTimeAfter timeLocksInEra sl
go (Timelock.RequireTimeExpire sl) = RequireTimeBefore timeLocksInEra sl
go (Timelock.RequireTimeStart sl) = RequireTimeAfter timeLocksInEra sl
go (Timelock.RequireAllOf s) = RequireAllOf (map go (toList s))
go (Timelock.RequireAnyOf s) = RequireAnyOf (map go (toList s))
go (Timelock.RequireMOf i s) = RequireMOf i (map go (toList s))

go (Timelock.RequireTimeExpire SNothing) = error "TODO: review need for this case with ledger team"
go (Timelock.RequireTimeStart SNothing) = error "TODO: review need for this case with ledger team"


--
-- JSON serialisation
Expand Down
1 change: 1 addition & 0 deletions cardano-node/src/Cardano/Node/Run.hs
Expand Up @@ -274,6 +274,7 @@ handleSimpleNode p trace nodeTracers nc onKernel = do
, dtMuxLocalTracer = nullTracer
, dtHandshakeTracer = handshakeTracer nodeTracers'
, dtHandshakeLocalTracer = localHandshakeTracer nodeTracers'
, dtDiffusionInitializationTracer = diffusionInitializationTracer nodeTracers'
}

createTracers
Expand Down
5 changes: 5 additions & 0 deletions cardano-node/src/Cardano/Tracing/Config.hs
Expand Up @@ -40,6 +40,7 @@ type TraceChainSyncClient = ("TraceChainSyncClient" :: Symbol)
type TraceChainSyncBlockServer = ("TraceChainSyncBlockServer" :: Symbol)
type TraceChainSyncHeaderServer = ("TraceChainSyncHeaderServer" :: Symbol)
type TraceChainSyncProtocol = ("TraceChainSyncProtocol" :: Symbol)
type TraceDiffusionInitialization = ("TraceDiffusionInitialization" :: Symbol)
type TraceDnsResolver = ("TraceDnsResolver" :: Symbol)
type TraceDnsSubscription = ("TraceDnsSubscription" :: Symbol)
type TraceErrorPolicy = ("TraceErrorPolicy" :: Symbol)
Expand Down Expand Up @@ -86,6 +87,7 @@ data TraceSelection
, traceChainSyncClient :: OnOff TraceChainSyncClient
, traceChainSyncHeaderServer :: OnOff TraceChainSyncHeaderServer
, traceChainSyncProtocol :: OnOff TraceChainSyncProtocol
, traceDiffusionInitialization :: OnOff TraceDiffusionInitialization
, traceDnsResolver :: OnOff TraceDnsResolver
, traceDnsSubscription :: OnOff TraceDnsSubscription
, traceErrorPolicy :: OnOff TraceErrorPolicy
Expand Down Expand Up @@ -134,6 +136,8 @@ traceConfigParser v =
chainSyncHeaderServer = OnOff False
chainSyncProtocol :: OnOff TraceChainSyncProtocol
chainSyncProtocol = OnOff False
diffusionInitialization :: OnOff TraceDiffusionInitialization
diffusionInitialization = OnOff False
dnsResolver :: OnOff TraceDnsResolver
dnsResolver = OnOff False
dnsSubscription :: OnOff TraceDnsSubscription
Expand Down Expand Up @@ -188,6 +192,7 @@ traceConfigParser v =
<*> v .:? getName chainSyncClient .!= chainSyncClient
<*> v .:? getName chainSyncHeaderServer .!= chainSyncHeaderServer
<*> v .:? getName chainSyncProtocol .!= chainSyncProtocol
<*> v .:? getName diffusionInitialization .!= diffusionInitialization
<*> v .:? getName dnsResolver .!= dnsResolver
<*> v .:? getName dnsSubscription .!= dnsSubscription
<*> v .:? getName errorPolicy .!= errorPolicy
Expand Down
13 changes: 6 additions & 7 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs
Expand Up @@ -27,18 +27,18 @@ import Cardano.Tracing.OrphanInstances.Common
import Cardano.Tracing.OrphanInstances.Consensus ()

import Cardano.Slotting.Slot (EpochSize (..))
import Ouroboros.Consensus.Block (BlockProtocol, CannotForge,
ForgeStateInfo, ForgeStateUpdateError)
import Ouroboros.Consensus.Block (BlockProtocol, CannotForge, ForgeStateInfo,
ForgeStateUpdateError)
import Ouroboros.Consensus.BlockchainTime (getSlotLength)
import Ouroboros.Consensus.Cardano.Condense ()
import Ouroboros.Consensus.HardFork.Combinator
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch (..),
OneEraCannotForge (..), OneEraEnvelopeErr (..), OneEraLedgerError (..),
OneEraCannotForge (..), OneEraEnvelopeErr (..), OneEraForgeStateInfo (..),
OneEraForgeStateUpdateError (..), OneEraLedgerError (..),
OneEraLedgerUpdate (..), OneEraLedgerWarning (..), OneEraValidationErr (..),
OneEraForgeStateInfo (..), OneEraForgeStateUpdateError (..), mkEraMismatch)
mkEraMismatch)
import Ouroboros.Consensus.HardFork.Combinator.Condense ()
import Ouroboros.Consensus.HardFork.History.EraParams (EraParams (..), SafeBeforeEpoch,
SafeZone)
import Ouroboros.Consensus.HardFork.History.EraParams (EraParams (..), SafeZone)
import Ouroboros.Consensus.HeaderValidation (OtherHeaderEnvelopeError)
import Ouroboros.Consensus.Ledger.Abstract (LedgerError)
import Ouroboros.Consensus.Ledger.Inspect (LedgerUpdate, LedgerWarning)
Expand Down Expand Up @@ -198,7 +198,6 @@ instance ToObject EraParams where
]

deriving instance ToJSON SafeZone
deriving instance ToJSON SafeBeforeEpoch


--
Expand Down
53 changes: 53 additions & 0 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs
Expand Up @@ -53,13 +53,19 @@ import Ouroboros.Network.Subscription (ConnectResult (..), DnsTrace (.
import Ouroboros.Network.TxSubmission.Inbound (TraceTxSubmissionInbound (..))
import Ouroboros.Network.TxSubmission.Outbound (TraceTxSubmissionOutbound (..))

import qualified Ouroboros.Network.Diffusion as ND

{- HLINT ignore "Use record patterns" -}

--
-- * instances of @HasPrivacyAnnotation@ and @HasSeverityAnnotation@
--
-- NOTE: this list is sorted by the unqualified name of the outermost type.

instance HasPrivacyAnnotation ND.DiffusionInitializationTracer
instance HasSeverityAnnotation ND.DiffusionInitializationTracer where
getSeverityAnnotation _ = Info

instance HasPrivacyAnnotation NtC.HandshakeTr
instance HasSeverityAnnotation NtC.HandshakeTr where
getSeverityAnnotation _ = Info
Expand Down Expand Up @@ -288,6 +294,11 @@ instance HasSeverityAnnotation (WithMuxBearer peer MuxTrace) where
--
-- NOTE: this list is sorted by the unqualified name of the outermost type.

instance Transformable Text IO ND.DiffusionInitializationTracer where
trTransformer = trStructuredText
instance HasTextFormatter ND.DiffusionInitializationTracer where
formatText _ = pack . show . toList

instance Transformable Text IO NtN.HandshakeTr where
trTransformer = trStructuredText
instance HasTextFormatter NtN.HandshakeTr where
Expand Down Expand Up @@ -465,6 +476,48 @@ instance ToObject (FetchDecision [Point header]) where
, "length" .= String (pack $ show $ length results)
]

instance ToObject ND.DiffusionInitializationTracer where
toObject _verb ND.RunServer = mkObject
[ "kind" .= String "RunServer"
]
toObject _verb ND.RunLocalServer = mkObject
[ "kind" .= String "RunLocalServer"
]
toObject _verb (ND.CreatingSystemdSocketForUnixPath path) = mkObject
[ "kind" .= String "CreatingSystemdSocketForUnixPath"
, "path" .= String (pack path)
]

toObject _verb (ND.CreateSystemdSocketForSnocketPath path) = mkObject
[ "kind" .= String "CreateSystemdSocketForSnocketPath"
, "path" .= String (pack path)
]
toObject _verb (ND.CreatedSystemdSocketForSnocketPath path) = mkObject
[ "kind" .= String "CreatedSystemdSocketForSnocketPath"
, "path" .= String (pack path)
]
toObject _verb (ND.BindingToSocket path socket) = mkObject
[ "kind" .= String "BindingToSocket"
, "path" .= String (pack path)
, "socket" .= String (pack socket)
]
toObject _verb (ND.ListeningToSocket path socket) = mkObject
[ "kind" .= String "ListeningToSocket"
, "path" .= String (pack path)
, "socket" .= String (pack socket)
]
toObject _verb (ND.CreatingServerSocket socket) = mkObject
[ "kind" .= String "CreatingServerSocket"
, "socket" .= String (pack (show socket))
]
toObject _verb (ND.BindingServerSocket socket) = mkObject
[ "kind" .= String "BindingServerSocket"
, "socket" .= String (pack (show socket))
]
toObject _verb (ND.UnsupportedSystemdSocket path) = mkObject
[ "kind" .= String "UnsupportedSystemdSocket"
, "path" .= String (pack (show path))
]

instance ToObject NtC.HandshakeTr where
toObject _verb (WithMuxBearer b ev) =
Expand Down
8 changes: 4 additions & 4 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs
Expand Up @@ -409,13 +409,13 @@ instance ToJSONKey (MA.PolicyID era) where
where
render (MA.PolicyID (ScriptHash h)) = hashToTextAsHex h

instance ToJSON MA.AssetID where
toJSON = Aeson.String . Text.decodeLatin1 . B16.encode . MA.assetID
instance ToJSON MA.AssetName where
toJSON = Aeson.String . Text.decodeLatin1 . B16.encode . MA.assetName

instance ToJSONKey MA.AssetID where
instance ToJSONKey MA.AssetName where
toJSONKey = ToJSONKeyText render (Aeson.text . render)
where
render = Text.decodeLatin1 . B16.encode . MA.assetID
render = Text.decodeLatin1 . B16.encode . MA.assetName

instance ToJSON MA.ValidityInterval where
toJSON vi =
Expand Down
6 changes: 6 additions & 0 deletions cardano-node/src/Cardano/Tracing/Tracers.hs
Expand Up @@ -91,6 +91,8 @@ import Cardano.Tracing.Queries
import Cardano.Node.Protocol.Byron ()
import Cardano.Node.Protocol.Shelley ()

import qualified Ouroboros.Network.Diffusion as ND

{- HLINT ignore "Redundant bracket" -}
{- HLINT ignore "Use record patterns" -}

Expand Down Expand Up @@ -119,6 +121,7 @@ data Tracers peer localPeer blk = Tracers
, muxTracer :: Tracer IO (WithMuxBearer peer MuxTrace)
, handshakeTracer :: Tracer IO NtN.HandshakeTr
, localHandshakeTracer :: Tracer IO NtC.HandshakeTr
, diffusionInitializationTracer :: Tracer IO ND.DiffusionInitializationTracer
}

data ForgeTracers = ForgeTracers
Expand Down Expand Up @@ -151,6 +154,7 @@ nullTracers = Tracers
, muxTracer = nullTracer
, handshakeTracer = nullTracer
, localHandshakeTracer = nullTracer
, diffusionInitializationTracer = nullTracer
}


Expand Down Expand Up @@ -296,6 +300,7 @@ mkTracers tOpts@(TracingOn trSel) tr nodeKern = do
, muxTracer = tracerOnOff (traceMux trSel) verb "Mux" tr
, handshakeTracer = tracerOnOff (traceHandshake trSel) verb "Handshake" tr
, localHandshakeTracer = tracerOnOff (traceLocalHandshake trSel) verb "LocalHandshake" tr
, diffusionInitializationTracer = tracerOnOff (traceDiffusionInitialization trSel) verb "DiffusionInitializationTracer" tr
}
where
verb :: TracingVerbosity
Expand Down Expand Up @@ -341,6 +346,7 @@ mkTracers TracingOff _ _ =
, muxTracer = nullTracer
, handshakeTracer = nullTracer
, localHandshakeTracer = nullTracer
, diffusionInitializationTracer = nullTracer
}

--------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions configuration/chairman/byron-shelley/configuration.yaml
Expand Up @@ -185,6 +185,9 @@ TraceChainSyncHeaderServer: False
TraceChainSyncProtocol: False
PBftSignatureThreshold: 0.6

# Trace diffusion initialization messages
TraceDiffusionInitialization: True

# Trace DNS Resolver messages.
TraceDNSResolver: True

Expand Down
3 changes: 3 additions & 0 deletions configuration/chairman/defaults/simpleview/config-0.yaml
Expand Up @@ -158,6 +158,9 @@ TraceChainSyncHeaderServer: False
# Trace ChainSync protocol messages.
TraceChainSyncProtocol: True

# Trace diffusion initialization messages
TraceDiffusionInitialization: True

# Trace DNS Resolver messages.
TraceDNSResolver: False

Expand Down
3 changes: 3 additions & 0 deletions configuration/chairman/defaults/simpleview/config-1.yaml
Expand Up @@ -157,6 +157,9 @@ TraceChainSyncHeaderServer: False
# Trace ChainSync protocol messages.
TraceChainSyncProtocol: True

# Trace diffusion initialization messages
TraceDiffusionInitialization: True

# Trace DNS Resolver messages.
TraceDNSResolver: False

Expand Down
3 changes: 3 additions & 0 deletions configuration/chairman/defaults/simpleview/config-2.yaml
Expand Up @@ -163,6 +163,9 @@ TraceChainSyncHeaderServer: False
# Trace ChainSync protocol messages.
TraceChainSyncProtocol: True

# Trace diffusion initialization messages
TraceDiffusionInitialization: True

# Trace DNS Resolver messages.
TraceDNSResolver: False

Expand Down
3 changes: 3 additions & 0 deletions configuration/chairman/shelly-only/configuration.yaml
Expand Up @@ -179,6 +179,9 @@ TraceChainSyncHeaderServer: False
# Trace ChainSync protocol messages.
TraceChainSyncProtocol: False

# Trace diffusion initialization messages
TraceDiffusionInitialization: True

# Trace DNS Resolver messages.
TraceDNSResolver: True

Expand Down

0 comments on commit 7a07ebd

Please sign in to comment.