diff --git a/cabal.project b/cabal.project index bc421ffd20b..90eae799bc2 100644 --- a/cabal.project +++ b/cabal.project @@ -62,6 +62,8 @@ allow-newer: , ekg-forward:ouroboros-network-framework , ekg-wai:time + , cardano-api + -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. @@ -98,3 +100,79 @@ if impl (ghc >= 9.12) , ouroboros-network-api:base , ouroboros-network-framework:base , ouroboros-network-protocols:base + +allow-newer: + cardano-ledger-core, + cardano-ledger-byron, + serdoc-core:tasty-quickcheck, + +source-repository-package + type: git + location: https://github.com/input-output-hk/kes-agent + tag: 07437ed49022b13759c87c4e314f08fcff64b81a + --sha256: sha256-oTsxaFAs1c/H0oYLhiivO5mr48oHNsPi5k2XyXxwCJg= + subdir: + kes-agent + +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-network + tag: 3e8d3b4b8c87ead794876c62d7fe25f32efb5142 + --sha256: 08fpkx3iagj83nn413h9a865zjcj3lrf7017a756qd2wg2jg3amq + subdir: + ouroboros-network-api + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-ledger + tag: b44ce911475794a15f908ad27a6f497d6a27e8ba + --sha256: sha256-MXaVKKH9siUsmOnJmYyL6if48dx11zugux7AWGPABfA= + subdir: + eras/allegra/impl + eras/alonzo/impl + eras/alonzo/test-suite + eras/babbage/impl + eras/babbage/test-suite + eras/byron/chain/executable-spec + eras/byron/crypto + eras/byron/ledger/executable-spec + eras/byron/ledger/impl + eras/conway/impl + eras/conway/test-suite + eras/mary/impl + eras/shelley/impl + eras/shelley-ma/test-suite + eras/shelley/test-suite + libs/cardano-data + libs/cardano-ledger-api + libs/cardano-ledger-binary + libs/cardano-ledger-core + libs/cardano-ledger-test + libs/cardano-protocol-tpraos + libs/constrained-generators + libs/non-integral + libs/set-algebra + libs/small-steps + libs/vector-map + +source-repository-package + type: git + location: https://github.com/IntersectMBO/ouroboros-consensus + tag: 9fdeacc0ba74009bd3078f08cd6b443a3f296515 + --sha256: sha256-oTsxaFAs1c/H0oYLhiivO5mr48oHNsPi5k2XyXxwCJg= + subdir: + ouroboros-consensus + ouroboros-consensus-cardano + ouroboros-consensus-diffusion + ouroboros-consensus-protocol + sop-extras + strict-sop-core + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-api + tag: 5e32849f753e40b9db852a3999ccf506da776a44 + --sha256: sha256-oTsxaFAs1c/H0oYLhiivO5mr48oHNsPi5k2XyXxwCJg= + subdir: + cardano-api + diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 43b1763f08c..3b2989ec729 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -181,6 +181,7 @@ library , hostname , io-classes >= 1.5 , iohk-monitoring ^>= 0.2 + , kes-agent , microlens , network-mux , iproute diff --git a/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs b/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs index cb90f3a9454..a252d7b644e 100644 --- a/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs +++ b/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs @@ -34,7 +34,7 @@ import Cardano.Api import Ouroboros.Network.PeerSelection.RelayAccessPoint (DomainAccessPoint (..)) -import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), object, withObject, (.:), (.=)) +import Data.Aeson (Value (..), object, withObject, (.:), (.=)) import Data.IP (IP (..), IPv4, IPv6) import qualified Data.IP as IP import Data.Text (Text) diff --git a/cardano-node/src/Cardano/Node/Parsers.hs b/cardano-node/src/Cardano/Node/Parsers.hs index e8b2fadac9f..b983c9fce00 100644 --- a/cardano-node/src/Cardano/Node/Parsers.hs +++ b/cardano-node/src/Cardano/Node/Parsers.hs @@ -56,7 +56,7 @@ nodeRunParser = do -- Protocol files byronCertFile <- optional parseByronDelegationCert byronKeyFile <- optional parseByronSigningKey - shelleyKESFile <- optional parseKesKeyFilePath + shelleyKESSource <- optional parseKesSourceFilePath shelleyVRFFile <- optional parseVrfKeyFilePath shelleyCertFile <- optional parseOperationalCertFilePath shelleyBulkCredsFile <- optional parseBulkCredsFilePath @@ -89,7 +89,7 @@ nodeRunParser = do , pncProtocolFiles = Last $ Just ProtocolFilepaths { byronCertFile , byronKeyFile - , shelleyKESFile + , shelleyKESSource , shelleyVRFFile , shelleyCertFile , shelleyBulkCredsFile @@ -334,15 +334,33 @@ parseBulkCredsFilePath = <> completer (bashCompleter "file") ) ---TODO: pass the current KES evolution, not the KES_0 -parseKesKeyFilePath :: Parser FilePath -parseKesKeyFilePath = - strOption - ( long "shelley-kes-key" - <> metavar "FILEPATH" - <> help "Path to the KES signing key." - <> completer (bashCompleter "file") - ) +-- --TODO: pass the current KES evolution, not the KES_0 +-- parseKesKeyFilePath :: Parser FilePath +-- parseKesKeyFilePath = +-- strOption +-- ( long "shelley-kes-key" +-- <> metavar "FILEPATH" +-- <> help "Path to the KES signing key." +-- <> completer (bashCompleter "file") +-- ) + +parseKesSourceFilePath :: Parser KESSource +parseKesSourceFilePath = asum + [ KESKeyFilePath <$> + strOption + ( long "shelley-kes-key" + <> metavar "FILEPATH" + <> help "Path to the KES signing key." + <> completer (bashCompleter "file") + ) + , KESAgentSocketPath <$> + strOption + ( long "shelley-kes-agent-socket" + <> metavar "SOCKET_FILEPATH" + <> help "Path to the KES Agent socket" + <> completer (bashCompleter "file") + ) + ] parseVrfKeyFilePath :: Parser FilePath parseVrfKeyFilePath = diff --git a/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs b/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs index dbb22da04a1..9376f53a607 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs @@ -9,7 +9,6 @@ module Cardano.Node.Protocol.Alonzo ) where import Cardano.Api -import Cardano.Api.Shelley import qualified Cardano.Ledger.Alonzo.Genesis as Alonzo import Cardano.Node.Orphans () diff --git a/cardano-node/src/Cardano/Node/Protocol/Byron.hs b/cardano-node/src/Cardano/Node/Protocol/Byron.hs index 01f91c07a23..c725887f2a0 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Byron.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Byron.hs @@ -13,6 +13,7 @@ module Cardano.Node.Protocol.Byron ) where import Cardano.Api.Byron +import Cardano.Api import qualified Cardano.Chain.Genesis as Genesis import qualified Cardano.Chain.Update as Update diff --git a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs index 24b24b5951c..be9e0b1a33a 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs @@ -23,7 +23,7 @@ module Cardano.Node.Protocol.Shelley ) where import qualified Cardano.Api as Api -import Cardano.Api.Shelley hiding (FileError) +import Cardano.Api hiding (FileError) import qualified Cardano.Crypto.Hash.Class as Crypto import Cardano.Ledger.BaseTypes (ProtVer (..), natVersion) @@ -39,7 +39,7 @@ import Cardano.Protocol.Crypto (StandardCrypto) import Cardano.Tracing.OrphanInstances.HardFork () import Cardano.Tracing.OrphanInstances.Shelley () import qualified Ouroboros.Consensus.Cardano as Consensus -import Ouroboros.Consensus.Protocol.Praos.Common (PraosCanBeLeader (..)) +import Ouroboros.Consensus.Protocol.Praos.Common (PraosCanBeLeader (..), PraosCredentialsSource(..)) import Ouroboros.Consensus.Shelley.Node (Nonce (..), ProtocolParamsShelleyBased (..), ShelleyLeaderCredentials (..)) @@ -141,27 +141,38 @@ readLeaderCredentialsSingleton ProtocolFilepaths { shelleyCertFile = Nothing, shelleyVRFFile = Nothing, - shelleyKESFile = Nothing + shelleyKESSource = Nothing } = pure [] -- Or to supply all of the files readLeaderCredentialsSingleton ProtocolFilepaths { shelleyCertFile = Just opCertFile, shelleyVRFFile = Just vrfFile, - shelleyKESFile = Just kesFile + shelleyKESSource = Just kesSource } = do vrfSKey <- firstExceptT FileError (newExceptT $ readFileTextEnvelope (File vrfFile)) - (opCert, kesSKey) <- opCertKesKeyCheck (File kesFile) (File opCertFile) + (credentialsSource, vkey) <- case kesSource of + KESKeyFilePath kesFile -> do + (OperationalCertificate opCert vkey, KesSigningKey kesKey) <- + opCertKesKeyCheck (File kesFile) (File opCertFile) + pure (PraosCredentialsUnsound opCert kesKey, vkey) - return [mkPraosLeaderCredentials opCert vrfSKey kesSKey] + -- TODO: minor yikes: when we're using an agent, we don't check that the + -- opcert and the key provided by the KES agent match, like we do when + -- the key is provided in a file on the command line + KESAgentSocketPath socketFile -> do + OperationalCertificate _ vkey <- firstExceptT FileError $ newExceptT $ readFileTextEnvelope $ File opCertFile + pure (PraosCredentialsAgent socketFile, vkey) + + return [mkPraosLeaderCredentials credentialsSource vkey vrfSKey] -- But not OK to supply some of the files without the others. readLeaderCredentialsSingleton ProtocolFilepaths {shelleyCertFile = Nothing} = left OCertNotSpecified readLeaderCredentialsSingleton ProtocolFilepaths {shelleyVRFFile = Nothing} = left VRFKeyNotSpecified -readLeaderCredentialsSingleton ProtocolFilepaths {shelleyKESFile = Nothing} = +readLeaderCredentialsSingleton ProtocolFilepaths {shelleyKESSource = Nothing} = left KESKeyNotSpecified opCertKesKeyCheck @@ -200,10 +211,11 @@ readLeaderCredentialsBulk ProtocolFilepaths { shelleyBulkCredsFile = mfp } = :: ShelleyCredentials -> ExceptT PraosLeaderCredentialsError IO (ShelleyLeaderCredentials StandardCrypto) parseShelleyCredentials ShelleyCredentials { scCert, scVrf, scKes } = do - mkPraosLeaderCredentials - <$> parseEnvelope scCert - <*> parseEnvelope scVrf - <*> parseEnvelope scKes + OperationalCertificate opCert vkey <- parseEnvelope scCert + scVrf' <- parseEnvelope scVrf + KesSigningKey scKes' <- parseEnvelope scKes + pure $ + mkPraosLeaderCredentials (PraosCredentialsUnsound opCert scKes') vkey scVrf' readBulkFile :: Maybe FilePath @@ -225,22 +237,21 @@ readLeaderCredentialsBulk ProtocolFilepaths { shelleyBulkCredsFile = mfp } = (teKes, loc "kes") mkPraosLeaderCredentials :: - OperationalCertificate + PraosCredentialsSource StandardCrypto + -> VerificationKey StakePoolKey -> SigningKey VrfKey - -> SigningKey KesKey -> ShelleyLeaderCredentials StandardCrypto mkPraosLeaderCredentials - (OperationalCertificate opcert (StakePoolVerificationKey vkey)) - (VrfSigningKey vrfKey) - (KesSigningKey kesKey) = + credentialsSource + (StakePoolVerificationKey vkey) + (VrfSigningKey vrfKey) = ShelleyLeaderCredentials { shelleyLeaderCredentialsCanBeLeader = PraosCanBeLeader { - praosCanBeLeaderOpCert = opcert, + praosCanBeLeaderCredentialsSource = credentialsSource, praosCanBeLeaderColdVerKey = coerceKeyRole vkey, praosCanBeLeaderSignKeyVRF = vrfKey }, - shelleyLeaderCredentialsInitSignKey = kesKey, shelleyLeaderCredentialsLabel = "Shelley" } diff --git a/cardano-node/src/Cardano/Node/Queries.hs b/cardano-node/src/Cardano/Node/Queries.hs index 6575bf34ec0..df9cc42ce18 100644 --- a/cardano-node/src/Cardano/Node/Queries.hs +++ b/cardano-node/src/Cardano/Node/Queries.hs @@ -260,8 +260,10 @@ instance Shelley.EraCertState era => LedgerQueries (Shelley.ShelleyBlock protoco . Shelley.shelleyLedgerState ledgerDRepCount = Map.size - . Shelley.vsDReps - . (^. Shelley.certVStateL) + . undefined + -- . State.vsDReps + -- . (^. vsDRepsL) + -- . (^. Shelley.certVStateL) . Shelley.lsCertState . Shelley.esLState . Shelley.nesEs diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index a81e778428a..cecc3bf5a1d 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -22,8 +22,7 @@ module Cardano.Node.Run , checkVRFFilePermissions ) where -import Cardano.Api (File (..), FileDirection (..)) -import Cardano.Api.Internal.Error (displayError) +import Cardano.Api (File (..), FileDirection (..), displayError) import qualified Cardano.Api as Api import System.Random (randomIO) @@ -249,7 +248,7 @@ handleNodeWithTracers cmdPc nc0 p@(SomeConsensusProtocol blockType runP) = do EnabledP2PMode -> nc0 case ncTraceConfig nc of TraceDispatcher{} -> do - blockForging <- snd (Api.protocolInfo runP) + blockForging <- snd (Api.protocolInfo runP) nullTracer -- FIXME: this should be a real tracer tracers <- initTraceDispatcher nc @@ -308,7 +307,7 @@ handleNodeWithTracers cmdPc nc0 p@(SomeConsensusProtocol blockType runP) = do traceWith (nodeVersionTracer tracers) getNodeVersion let isNonProducing = ncStartAsNonProducingNode nc - blockForging <- snd (Api.protocolInfo runP) + blockForging <- snd (Api.protocolInfo runP) nullTracer -- FIXME: this should be a real tracer traceWith (startupTracer tracers) (BlockForgingUpdate (if isNonProducing || null blockForging then DisabledBlockForging @@ -506,7 +505,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do , rnProtocolInfo = pInfo , rnNodeKernelHook = \registry nodeKernel -> do -- set the initial block forging - blockForging <- snd (Api.protocolInfo runP) + blockForging <- snd (Api.protocolInfo runP) nullTracer -- FIXME: this should be a real tracer unless (ncStartAsNonProducingNode nc) $ setBlockForging nodeKernel blockForging @@ -604,7 +603,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do , rnProtocolInfo = pInfo , rnNodeKernelHook = \registry nodeKernel -> do -- set the initial block forging - blockForging <- snd (Api.protocolInfo runP) + blockForging <- snd (Api.protocolInfo runP)nullTracer -- FIXME: this should be a real tracer unless (ncStartAsNonProducingNode nc) $ setBlockForging nodeKernel blockForging @@ -813,7 +812,7 @@ updateBlockForging startupTracer blockType nodeKernel nc = do case Api.reflBlockType blockType blockType' of Just Refl -> do -- TODO: check if runP' has changed - blockForging <- snd (Api.protocolInfo runP') + blockForging <- snd (Api.protocolInfo runP') nullTracer -- FIXME: this should be a real tracer traceWith startupTracer (BlockForgingUpdate (if null blockForging then DisabledBlockForging diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs index 0b85ad51932..a2eb094ad7c 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs @@ -19,7 +19,7 @@ module Cardano.Node.Tracing.Era.Shelley () where import Cardano.Api (textShow) import Cardano.Api.Ledger (fromVRFVerKeyHash) -import qualified Cardano.Api.Shelley as Api +import qualified Cardano.Api as Api import qualified Cardano.Crypto.Hash.Class as Crypto import qualified Cardano.Crypto.VRF.Class as Crypto @@ -740,9 +740,6 @@ instance ) => LogFormatting (ShelleyNewEpochPredFailure era) where forMachine dtal (EpochFailure f) = forMachine dtal f forMachine dtal (MirFailure f) = forMachine dtal f - forMachine _dtal (CorruptRewardUpdate update) = - mconcat [ "kind" .= String "CorruptRewardUpdate" - , "update" .= String (textShow update) ] instance diff --git a/cardano-node/src/Cardano/Node/Tracing/Render.hs b/cardano-node/src/Cardano/Node/Tracing/Render.hs index d6f88431dd0..21eb099be60 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Render.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Render.hs @@ -30,7 +30,7 @@ module Cardano.Node.Tracing.Render , renderMissingRedeemers ) where -import qualified Cardano.Api.Shelley as Api +import qualified Cardano.Api as Api import qualified Cardano.Crypto.Hash.Class as Crypto import Cardano.Ledger.Alonzo.Scripts (AlonzoPlutusPurpose (..), AsItem (..), diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs index da4c82fd265..3dfb8413d43 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs @@ -342,6 +342,10 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf ["Consensus", "Startup"] configureTracers configReflection trConfig [consensusStartupErrorTr] + !consensusKESAgentTr <- mkCardanoTracer + trBase trForward mbTrEKG + ["Consensus", "KESAgent"] + !consensusGddTr <- mkCardanoTracer trBase trForward mbTrEKG ["Consensus", "GDD"] @@ -402,6 +406,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf traceWith keepAliveClientTr , Consensus.consensusErrorTracer = Tracer $ traceWith consensusStartupErrorTr . ConsensusStartupException + , Consensus.kesAgentTracer = Tracer $ + traceWith consensusKESAgentTr , Consensus.gsmTracer = Tracer $ traceWith consensusGsmTr , Consensus.csjTracer = Tracer $ diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs index 1bf1c7a1284..c5385c6f7a7 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs @@ -2223,21 +2223,24 @@ instance MetaTrace V1.BackingStoreValueHandleTrace where ] instance LogFormatting V2.FlavorImplSpecificTrace where - forMachine _dtal V2.FlavorImplSpecificTraceInMemory = - mconcat [ "kind" .= String "InMemory" ] - forMachine _dtal V2.FlavorImplSpecificTraceOnDisk = - mconcat [ "kind" .= String "OnDisk" ] - - forHuman V2.FlavorImplSpecificTraceInMemory = - "An in-memory backing store event was traced" - forHuman V2.FlavorImplSpecificTraceOnDisk = - "An on-disk backing store event was traced" + forMachine _dtal _ = undefined + -- forMachine _dtal V2.FlavorImplSpecificTraceInMemory = + -- mconcat [ "kind" .= String "InMemory" ] + -- forMachine _dtal V2.FlavorImplSpecificTraceOnDisk = + -- mconcat [ "kind" .= String "OnDisk" ] + + forHuman _ = undefined + -- forHuman V2.FlavorImplSpecificTraceInMemory = + -- "An in-memory backing store event was traced" + -- forHuman V2.FlavorImplSpecificTraceOnDisk = + -- "An on-disk backing store event was traced" instance MetaTrace V2.FlavorImplSpecificTrace where - namespaceFor V2.FlavorImplSpecificTraceInMemory = - Namespace [] ["InMemory"] - namespaceFor V2.FlavorImplSpecificTraceOnDisk = - Namespace [] ["OnDisk"] + namespaceFor _ = undefined + -- namespaceFor V2.FlavorImplSpecificTraceInMemory = + -- Namespace [] ["InMemory"] + -- namespaceFor V2.FlavorImplSpecificTraceOnDisk = + -- Namespace [] ["OnDisk"] severityFor (Namespace _ ["InMemory"]) _ = Just Info severityFor (Namespace _ ["OnDisk"]) _ = Just Info diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs index 3daec1eb691..46ba795028f 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs @@ -80,6 +80,8 @@ import qualified Data.Text as Text import Data.Time (NominalDiffTime) import Data.Word (Word32, Word64) import Network.TypedProtocol.Core +import Ouroboros.Consensus.Protocol.Praos.AgentClient +import qualified Cardano.KESAgent.Processes.ServiceClient as Agent instance (LogFormatting adr, Show adr) => LogFormatting (ConnectionId adr) where @@ -2267,3 +2269,137 @@ instance ( StandardHash blk ] forHuman = showT + +-------------------------------------------------------------------------------- +-- KES Agent tracer +-------------------------------------------------------------------------------- + +instance LogFormatting Agent.ServiceClientTrace where + forMachine _dtal = \case + Agent.ServiceClientVersionHandshakeTrace _vhdt -> + mconcat [ "kind" .= String "ServiceClientVersionHandshakeTrace" ] + Agent.ServiceClientVersionHandshakeFailed -> + mconcat [ "kind" .= String "ServiceClientVersionHandshakeFailed" ] + Agent.ServiceClientDriverTrace _sdt -> + mconcat [ "kind" .= String "ServiceClientDriverTrace" ] + Agent.ServiceClientSocketClosed -> + mconcat [ "kind" .= String "ServiceClientSocketClosed" ] + Agent.ServiceClientConnected _s -> + mconcat [ "kind" .= String "ServiceClientConnected" ] + Agent.ServiceClientAttemptReconnect _ _ _ _ -> + mconcat [ "kind" .= String "ServiceClientAttemptReconnect" ] + Agent.ServiceClientReceivedKey _tbt -> + mconcat [ "kind" .= String "ServiceClientReceivedKey" ] + Agent.ServiceClientDeclinedKey _tbt -> + mconcat [ "kind" .= String "ServiceClientDeclinedKey" ] + Agent.ServiceClientDroppedKey -> + mconcat [ "kind" .= String "ServiceClientDroppedKey" ] + Agent.ServiceClientOpCertNumberCheck _ _ -> + mconcat [ "kind" .= String "ServiceClientOpCertNumberCheck" ] + Agent.ServiceClientAbnormalTermination _s -> + mconcat [ "kind" .= String "ServiceClientAbnormalTermination" ] + Agent.ServiceClientStopped -> + mconcat [ "kind" .= String "ServiceClientStopped" ] + + forHuman = showT + +instance MetaTrace Agent.ServiceClientTrace where + namespaceFor = \case + Agent.ServiceClientVersionHandshakeTrace _vhdt -> + Namespace [] ["ServiceClientVersionHandshakeTrace"] + Agent.ServiceClientVersionHandshakeFailed -> + Namespace [] ["ServiceClientVersionHandshakeFailed"] + Agent.ServiceClientDriverTrace _sdt -> + Namespace [] ["ServiceClientDriverTrace"] + Agent.ServiceClientSocketClosed -> + Namespace [] ["ServiceClientSocketClosed"] + Agent.ServiceClientConnected _s -> + Namespace [] ["ServiceClientConnected"] + Agent.ServiceClientAttemptReconnect _ _ _ _ -> + Namespace [] ["ServiceClientAttemptReconnect"] + Agent.ServiceClientReceivedKey _tbt -> + Namespace [] ["ServiceClientReceivedKey"] + Agent.ServiceClientDeclinedKey _tbt -> + Namespace [] ["ServiceClientDeclinedKey"] + Agent.ServiceClientDroppedKey -> + Namespace [] ["ServiceClientDroppedKey"] + Agent.ServiceClientOpCertNumberCheck _ _ -> + Namespace [] ["ServiceClientOpCertNumberCheck"] + Agent.ServiceClientAbnormalTermination _s -> + Namespace [] ["ServiceClientAbnormalTermination"] + Agent.ServiceClientStopped -> + Namespace [] ["ServiceClientStopped"] + + severityFor ns _ = case ns of + Namespace [] ["ServiceClientVersionHandshakeTrace"] -> + Just Debug + Namespace [] ["ServiceClientVersionHandshakeFailed"] -> + Just Error + Namespace [] ["ServiceClientDriverTrace"] -> + Just Debug + Namespace [] ["ServiceClientSocketClosed"] -> + Just Info + Namespace [] ["ServiceClientConnected"] -> + Just Info + Namespace [] ["ServiceClientAttemptReconnect"] -> + Just Info + Namespace [] ["ServiceClientReceivedKey"] -> + Just Info + Namespace [] ["ServiceClientDeclinedKey"] -> + Just Info + Namespace [] ["ServiceClientDroppedKey"] -> + Just Info + Namespace [] ["ServiceClientOpCertNumberCheck"] -> + Just Debug + Namespace [] ["ServiceClientAbnormalTermination"] -> + Just Error + Namespace [] ["ServiceClientStopped"] -> + Just Info + Namespace _ _ -> Nothing + + documentFor _ = Nothing + allNamespaces = + [ Namespace [] ["ServiceClientVersionHandshakeTrace"] + , Namespace [] ["ServiceClientVersionHandshakeFailed"] + , Namespace [] ["ServiceClientDriverTrace"] + , Namespace [] ["ServiceClientSocketClosed"] + , Namespace [] ["ServiceClientConnected"] + , Namespace [] ["ServiceClientAttemptReconnect"] + , Namespace [] ["ServiceClientReceivedKey"] + , Namespace [] ["ServiceClientDeclinedKey"] + , Namespace [] ["ServiceClientDroppedKey"] + , Namespace [] ["ServiceClientOpCertNumberCheck"] + , Namespace [] ["ServiceClientAbnormalTermination"] + , Namespace [] ["ServiceClientStopped"] + ] + +instance LogFormatting KESAgentClientTrace where + forMachine dtal = \case + KESAgentClientException ex -> mconcat + [ "kind" .= String "KESAgentClientException" + , "exception" .= String (Text.pack $ show ex) + ] + KESAgentClientTrace t -> mconcat + [ "kind" .= String "KESAgentClientTrace" + , "trace" .= forMachine dtal t + ] + + forHuman = showT + + +instance MetaTrace KESAgentClientTrace where + namespaceFor = \case + KESAgentClientException _ -> + Namespace [] ["KESAgentClientException"] + KESAgentClientTrace t -> nsCast $ namespaceFor t + + severityFor (Namespace [] ["KESAgentClientException"]) _ = Just Error + severityFor (Namespace [] ["KESAgentClientTrace"]) _ = Just Info + severityFor _ _ = Nothing + + documentFor _ = Nothing + + allNamespaces = + Namespace [] ["KESAgentClientException"] : + fmap nsCast (allNamespaces :: [Namespace Agent.ServiceClientTrace]) + diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs index 21050bb0ed6..67bf485f0f1 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs @@ -471,6 +471,7 @@ nodeToClientVersionToInt = \case NodeToClientV_18 -> 18 NodeToClientV_19 -> 19 NodeToClientV_20 -> 20 + NodeToClientV_21 -> 21 nodeToNodeVersionToInt :: NodeToNodeVersion -> Int nodeToNodeVersionToInt = \case diff --git a/cardano-node/src/Cardano/Node/Types.hs b/cardano-node/src/Cardano/Node/Types.hs index 1356505f99d..24e0cc7f118 100644 --- a/cardano-node/src/Cardano/Node/Types.hs +++ b/cardano-node/src/Cardano/Node/Types.hs @@ -16,6 +16,7 @@ module Cardano.Node.Types , GenesisFile(..) , PeerSnapshotFile (..) , CheckpointsFile(..) + , KESSource(..) , ProtocolFilepaths (..) , GenesisHash(..) , CheckpointsHash(..) @@ -164,11 +165,16 @@ class AdjustFilePaths a where adjustFilePaths :: (FilePath -> FilePath) -> a -> a +data KESSource + = KESKeyFilePath FilePath + | KESAgentSocketPath FilePath + deriving (Eq, Show) + data ProtocolFilepaths = ProtocolFilepaths { byronCertFile :: !(Maybe FilePath) , byronKeyFile :: !(Maybe FilePath) - , shelleyKESFile :: !(Maybe FilePath) + , shelleyKESSource :: !(Maybe KESSource) , shelleyVRFFile :: !(Maybe FilePath) , shelleyCertFile :: !(Maybe FilePath) , shelleyBulkCredsFile :: !(Maybe FilePath) diff --git a/cardano-node/src/Cardano/Tracing/Config.hs b/cardano-node/src/Cardano/Tracing/Config.hs index b71e90f52aa..61667f8f111 100644 --- a/cardano-node/src/Cardano/Tracing/Config.hs +++ b/cardano-node/src/Cardano/Tracing/Config.hs @@ -162,6 +162,7 @@ type TraceLocalTxMonitorProtocol = ("TraceLocalTxMonitorProtocol" :: Symbol) type TraceLocalTxSubmissionProtocol = ("TraceLocalTxSubmissionProtocol" :: Symbol) type TraceLocalTxSubmissionServer = ("TraceLocalTxSubmissionServer" :: Symbol) type TraceMempool = ("TraceMempool" :: Symbol) +type TraceKESAgent = ("TraceKESAgent" :: Symbol) type TraceBackingStore = ("TraceBackingStore" :: Symbol) type TraceMux = ("TraceMux" :: Symbol) type TraceLocalMux = ("TraceLocalMux" :: Symbol) @@ -242,6 +243,7 @@ data TraceSelection , traceLocalTxSubmissionProtocol :: OnOff TraceLocalTxSubmissionProtocol , traceLocalTxSubmissionServer :: OnOff TraceLocalTxSubmissionServer , traceMempool :: OnOff TraceMempool + , traceKESAgent :: OnOff TraceKESAgent , traceBackingStore :: OnOff TraceBackingStore , traceMux :: OnOff TraceMux , tracePeerSelection :: OnOff TracePeerSelection @@ -312,6 +314,7 @@ data PartialTraceSelection , pTraceLocalTxSubmissionProtocol :: Last (OnOff TraceLocalTxSubmissionProtocol) , pTraceLocalTxSubmissionServer :: Last (OnOff TraceLocalTxSubmissionServer) , pTraceMempool :: Last (OnOff TraceMempool) + , pTraceKESAgent :: Last (OnOff TraceKESAgent) , pTraceBackingStore :: Last (OnOff TraceBackingStore) , pTraceMux :: Last (OnOff TraceMux) , pTracePeerSelection :: Last (OnOff TracePeerSelection) @@ -383,6 +386,7 @@ instance FromJSON PartialTraceSelection where <*> parseTracer (Proxy @TraceLocalTxSubmissionProtocol) v <*> parseTracer (Proxy @TraceLocalTxSubmissionServer) v <*> parseTracer (Proxy @TraceMempool) v + <*> parseTracer (Proxy @TraceKESAgent) v <*> parseTracer (Proxy @TraceBackingStore) v <*> parseTracer (Proxy @TraceMux) v <*> parseTracer (Proxy @TracePeerSelection) v @@ -451,6 +455,7 @@ defaultPartialTraceConfiguration = , pTraceLocalTxSubmissionProtocol = pure $ OnOff False , pTraceLocalTxSubmissionServer = pure $ OnOff False , pTraceMempool = pure $ OnOff True + , pTraceKESAgent = pure $ OnOff True , pTraceBackingStore = pure $ OnOff False , pTraceMux = pure $ OnOff True , pTracePeerSelection = pure $ OnOff True @@ -521,6 +526,7 @@ partialTraceSelectionToEither (Last (Just (PartialTraceDispatcher pTraceSelectio traceLocalTxSubmissionProtocol <- proxyLastToEither (Proxy @TraceLocalTxSubmissionProtocol) pTraceLocalTxSubmissionProtocol traceLocalTxSubmissionServer <- proxyLastToEither (Proxy @TraceLocalTxSubmissionServer) pTraceLocalTxSubmissionServer traceMempool <- proxyLastToEither (Proxy @TraceMempool) pTraceMempool + traceKESAgent <- proxyLastToEither (Proxy @TraceKESAgent) pTraceKESAgent traceBackingStore <- proxyLastToEither (Proxy @TraceBackingStore) pTraceBackingStore traceMux <- proxyLastToEither (Proxy @TraceMux) pTraceMux tracePeerSelection <- proxyLastToEither (Proxy @TracePeerSelection) pTracePeerSelection @@ -584,6 +590,7 @@ partialTraceSelectionToEither (Last (Just (PartialTraceDispatcher pTraceSelectio , traceLocalTxSubmissionProtocol = traceLocalTxSubmissionProtocol , traceLocalTxSubmissionServer = traceLocalTxSubmissionServer , traceMempool = traceMempool + , traceKESAgent = traceKESAgent , traceBackingStore = traceBackingStore , traceMux = traceMux , tracePeerSelection = tracePeerSelection @@ -651,6 +658,7 @@ partialTraceSelectionToEither (Last (Just (PartialTracingOnLegacy pTraceSelectio traceLocalTxSubmissionProtocol <- proxyLastToEither (Proxy @TraceLocalTxSubmissionProtocol) pTraceLocalTxSubmissionProtocol traceLocalTxSubmissionServer <- proxyLastToEither (Proxy @TraceLocalTxSubmissionServer) pTraceLocalTxSubmissionServer traceMempool <- proxyLastToEither (Proxy @TraceMempool) pTraceMempool + traceKESAgent <- proxyLastToEither (Proxy @TraceKESAgent) pTraceKESAgent traceBackingStore <- proxyLastToEither (Proxy @TraceBackingStore) pTraceBackingStore traceMux <- proxyLastToEither (Proxy @TraceMux) pTraceMux tracePeerSelection <- proxyLastToEither (Proxy @TracePeerSelection) pTracePeerSelection @@ -714,6 +722,7 @@ partialTraceSelectionToEither (Last (Just (PartialTracingOnLegacy pTraceSelectio , traceLocalTxSubmissionProtocol = traceLocalTxSubmissionProtocol , traceLocalTxSubmissionServer = traceLocalTxSubmissionServer , traceMempool = traceMempool + , traceKESAgent = traceKESAgent , traceBackingStore = traceBackingStore , traceMux = traceMux , tracePeerSelection = tracePeerSelection diff --git a/cardano-node/src/Cardano/Tracing/HasIssuer.hs b/cardano-node/src/Cardano/Tracing/HasIssuer.hs index 17b1acc9f09..c3245b42c25 100644 --- a/cardano-node/src/Cardano/Tracing/HasIssuer.hs +++ b/cardano-node/src/Cardano/Tracing/HasIssuer.hs @@ -11,9 +11,8 @@ module Cardano.Tracing.HasIssuer , HasIssuer (..) ) where -import Cardano.Api (serialiseToRawBytes, verificationKeyHash) +import Cardano.Api (serialiseToRawBytes, VerificationKey( StakePoolVerificationKey), verificationKeyHash) import Cardano.Api.Byron (VerificationKey (ByronVerificationKey)) -import Cardano.Api.Shelley (VerificationKey (StakePoolVerificationKey)) import qualified Cardano.Chain.Block as Byron import qualified Cardano.Ledger.Shelley.API as Shelley diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs index 5e3398c9174..9f197c1a60a 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs @@ -2388,6 +2388,7 @@ instance ToJSON NodeToClientVersion where toJSON NodeToClientV_18 = Number 18 toJSON NodeToClientV_19 = Number 19 toJSON NodeToClientV_20 = Number 20 + toJSON NodeToClientV_21 = Number 21 -- NB: When adding a new version here, update FromJSON below as well! instance FromJSON NodeToClientVersion where @@ -2395,6 +2396,8 @@ instance FromJSON NodeToClientVersion where parseJSON (Number 17) = return NodeToClientV_17 parseJSON (Number 18) = return NodeToClientV_18 parseJSON (Number 19) = return NodeToClientV_19 + parseJSON (Number 20) = return NodeToClientV_20 + parseJSON (Number 21) = return NodeToClientV_21 parseJSON (Number x) = fail ("FromJSON.NodeToClientVersion: unsupported node-to-client protocol version " ++ show x) parseJSON x = fail ("FromJSON.NodeToClientVersion: error parsing NodeToClientVersion: " ++ show x) diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs index ba8f0140710..83c0cfeb308 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs @@ -20,7 +20,7 @@ module Cardano.Tracing.OrphanInstances.Shelley () where import Cardano.Api (textShow) -import qualified Cardano.Api.Shelley as Api +import qualified Cardano.Api as Api import qualified Cardano.Crypto.Hash.Class as Crypto import qualified Cardano.Crypto.VRF.Class as Crypto @@ -859,9 +859,6 @@ instance ) => ToObject (ShelleyNewEpochPredFailure ledgerera) where toObject verb (EpochFailure f) = toObject verb f toObject verb (MirFailure f) = toObject verb f - toObject _verb (CorruptRewardUpdate update) = - mconcat [ "kind" .= String "CorruptRewardUpdate" - , "update" .= String (textShow update) ] instance @@ -1326,6 +1323,7 @@ instance ToJSON ShelleyNodeToClientVersion where toJSON ShelleyNodeToClientVersion10 = String "ShelleyNodeToClientVersion10" toJSON ShelleyNodeToClientVersion11 = String "ShelleyNodeToClientVersion11" toJSON ShelleyNodeToClientVersion12 = String "ShelleyNodeToClientVersion12" + toJSON ShelleyNodeToClientVersion13 = String "ShelleyNodeToClientVersion13" instance Core.Crypto c => ToObject (PraosChainSelectView c) where toObject _ PraosChainSelectView { diff --git a/cardano-node/src/Cardano/Tracing/Tracers.hs b/cardano-node/src/Cardano/Tracing/Tracers.hs index 8a8d9bab3f6..f8285ba3b90 100644 --- a/cardano-node/src/Cardano/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Tracing/Tracers.hs @@ -553,6 +553,7 @@ mkTracers _ _ _ _ _ enableP2P = , Consensus.forgeTracer = nullTracer , Consensus.blockchainTimeTracer = nullTracer , Consensus.consensusErrorTracer = nullTracer + , Consensus.kesAgentTracer = nullTracer , Consensus.gsmTracer = nullTracer , Consensus.csjTracer = nullTracer , Consensus.dbfTracer = nullTracer @@ -859,6 +860,7 @@ mkConsensusTracers mbEKGDirect trSel verb tr nodeKern fStats = do traceWith (toLogObject tr) (readableTraceBlockchainTimeEvent ev) , Consensus.consensusErrorTracer = Tracer $ \err -> traceWith (toLogObject tr) (ConsensusStartupException err) + , Consensus.kesAgentTracer = contramap show $ tracerOnOff (traceKESAgent trSel) verb "KESAgent" tr , Consensus.gsmTracer = tracerOnOff (traceGsm trSel) verb "GSM" tr , Consensus.csjTracer = tracerOnOff (traceCsj trSel) verb "CSJ" tr , Consensus.dbfTracer = tracerOnOff (traceDevotedBlockFetch trSel) verb "DevotedBlockFetch" tr