diff --git a/cabal.project b/cabal.project index d46ed1b5114..2ac670b9e49 100644 --- a/cabal.project +++ b/cabal.project @@ -10,6 +10,12 @@ package cardano-config package cardano-node ghc-options: -Wall -fwarn-redundant-constraints +package ouroboros-consensus-byron + tests: False + +package ouroboros-consensus-mock + tests: False + source-repository-package type: git location: https://github.com/input-output-hk/cardano-base @@ -184,66 +190,94 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: ouroboros-network source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: io-sim source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: ouroboros-network-testing source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: ouroboros-consensus source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y + subdir: ouroboros-consensus/ouroboros-consensus-mock + +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y + subdir: ouroboros-consensus-byron + +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y + subdir: ouroboros-consensus-cardano + +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: typed-protocols source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: typed-protocols-examples source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: ouroboros-network-framework source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: network-mux source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 5f77e24c2263560ad58b9ba092c8cfed174675ae - --sha256: 00bm1fa83lc6jgh36mwr4zymzg9hvmq68y2hm4klk8c8gn7vwqqb + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y subdir: io-sim-classes +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 36861a97272de1e4de448925dd9bb9c0fddd80f6 + --sha256: 08jb0qj60i5dfsq17dyix3pdv05kg505n9kd7ps9j7dzl1p9pb2y + subdir: Win32-network + source-repository-package type: git location: http://github.com/well-typed/canonical-json diff --git a/cardano-config/cardano-config.cabal b/cardano-config/cardano-config.cabal index f87c2300f77..70ffd17d488 100644 --- a/cardano-config/cardano-config.cabal +++ b/cardano-config/cardano-config.cabal @@ -44,6 +44,8 @@ library , network , optparse-applicative , ouroboros-consensus + , ouroboros-consensus-byron + , ouroboros-consensus-cardano , ouroboros-network , process , iproute diff --git a/cardano-config/src/Cardano/Config/Protocol.hs b/cardano-config/src/Cardano/Config/Protocol.hs index 1122d8ed5b8..68c4f25a38d 100644 --- a/cardano-config/src/Cardano/Config/Protocol.hs +++ b/cardano-config/src/Cardano/Config/Protocol.hs @@ -1,8 +1,8 @@ -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -Wno-all-missed-specialisations #-} @@ -16,15 +16,13 @@ module Cardano.Config.Protocol , TraceConstraints ) where - - import Cardano.Prelude import Test.Cardano.Prelude (canonicalDecodePretty) -import Codec.CBOR.Read (deserialiseFromBytes, DeserialiseFailure) +import Codec.CBOR.Read (DeserialiseFailure, deserialiseFromBytes) import Control.Monad.Trans.Except (ExceptT) -import Control.Monad.Trans.Except.Extra ( bimapExceptT, firstExceptT - , hoistEither, left) +import Control.Monad.Trans.Except.Extra (bimapExceptT, firstExceptT, + hoistEither, left) import qualified Data.ByteString.Lazy as LB import qualified Cardano.Chain.Genesis as Genesis @@ -32,32 +30,29 @@ import qualified Cardano.Chain.Update as Update import Cardano.Crypto (RequiresNetworkMagic, decodeHash) import qualified Cardano.Crypto.Signing as Signing -import Ouroboros.Consensus.Block (Header) -import Ouroboros.Consensus.BlockchainTime - (SlotLength, slotLengthFromSec, - SlotLengths, singletonSlotLengths) +import Ouroboros.Consensus.Block (Header, BlockProtocol) +import Ouroboros.Consensus.BlockchainTime (SlotLength, SlotLengths, + singletonSlotLengths, + slotLengthFromSec) +import Ouroboros.Consensus.Cardano hiding (Protocol) +import qualified Ouroboros.Consensus.Cardano as Consensus import Ouroboros.Consensus.Mempool.API (ApplyTxErr, GenTx, GenTxId, HasTxId, TxId) -import Ouroboros.Consensus.Node.ProtocolInfo (NumCoreNodes (..), - PBftLeaderCredentials, - PBftLeaderCredentialsError, - PBftSignatureThreshold(..), - mkPBftLeaderCredentials) -import Ouroboros.Consensus.NodeId (CoreNodeId (..), NodeId (..)) +import Ouroboros.Consensus.Node.ProtocolInfo (NumCoreNodes (..)) + +import Ouroboros.Consensus.Byron.Ledger (ByronBlock) import Ouroboros.Consensus.Node.Run (RunNode) -import Ouroboros.Consensus.Protocol (SecurityParam (..), - PraosParams (..), - PBftParams (..)) -import qualified Ouroboros.Consensus.Protocol as Consensus -import qualified Ouroboros.Consensus.Ledger.Byron as Consensus -import Ouroboros.Consensus.Util (Dict(..)) +import Ouroboros.Consensus.NodeId (CoreNodeId (..), NodeId (..)) +import Ouroboros.Consensus.Protocol.Abstract (SecurityParam (..)) +import Ouroboros.Consensus.Util (Dict (..)) import Ouroboros.Consensus.Util.Condense -import Ouroboros.Network.Block +import Ouroboros.Network.Block (HeaderHash) -import Cardano.Config.Types - (DelegationCertFile (..), GenesisFile (..), - LastKnownBlockVersion (..), Update (..), - Protocol (..), SigningKeyFile (..)) +import Cardano.Config.Types (DelegationCertFile (..), + GenesisFile (..), + LastKnownBlockVersion (..), + Protocol (..), SigningKeyFile (..), + Update (..)) -- TODO: consider not throwing this, or wrap it in a local error type here -- that has proper error messages. @@ -105,7 +100,7 @@ mockSomeProtocol => Maybe NodeId -> Maybe Word64 -- ^ Number of core nodes - -> (CoreNodeId -> NumCoreNodes -> Consensus.Protocol blk) + -> (CoreNodeId -> NumCoreNodes -> Consensus.Protocol blk (BlockProtocol blk)) -> Either ProtocolInstantiationError SomeProtocol mockSomeProtocol nId mNumCoreNodes mkConsensusProtocol = do (cid, numCoreNodes) <- extractNodeInfo nId mNumCoreNodes @@ -115,7 +110,7 @@ mockSomeProtocol nId mNumCoreNodes mkConsensusProtocol = do data SomeProtocol where SomeProtocol :: (RunNode blk, TraceConstraints blk) - => Consensus.Protocol blk -> SomeProtocol + => Consensus.Protocol blk (BlockProtocol blk) -> SomeProtocol data ProtocolInstantiationError = ByronLegacyProtocolNotImplemented @@ -149,21 +144,25 @@ fromProtocol _ nId mNumCoreNodes _ _ _ _ _ _ BFT = Consensus.ProtocolMockBFT numCoreNodes cid mockSecurityParam mockSlotLengths fromProtocol _ nId mNumCoreNodes _ _ _ _ _ _ Praos = hoistEither $ mockSomeProtocol nId mNumCoreNodes $ \cid numCoreNodes -> - Consensus.ProtocolMockPraos numCoreNodes cid PraosParams { - praosSecurityParam = mockSecurityParam - , praosSlotsPerEpoch = 3 - , praosLeaderF = 0.5 - , praosLifetimeKES = 1000000 - , praosSlotLength = slotLengthFromSec 2 - } + Consensus.ProtocolMockPraos + numCoreNodes + cid + PraosParams { + praosSecurityParam = mockSecurityParam + , praosSlotsPerEpoch = 3 + , praosLeaderF = 0.5 + , praosLifetimeKES = 1000000 + } + (singletonSlotLengths (slotLengthFromSec 2)) fromProtocol _ nId mNumCoreNodes _ _ _ _ _ _ MockPBFT = hoistEither $ mockSomeProtocol nId mNumCoreNodes $ \cid numCoreNodes@(NumCoreNodes numNodes) -> Consensus.ProtocolMockPBFT PBftParams { pbftSecurityParam = mockSecurityParam , pbftNumNodes = numCoreNodes , pbftSignatureThreshold = (1.0 / fromIntegral numNodes) + 0.1 - , pbftSlotLength = mockSlotLength + } + (singletonSlotLengths mockSlotLength) cid fromProtocol gHash _ _ mGenFile nMagic sigThresh delCertFp sKeyFp update RealPBFT = do let genHash = either panic identity $ decodeHash gHash @@ -194,7 +193,7 @@ protocolConfigRealPbft :: Update -> Maybe Double -> Genesis.Config -> Maybe PBftLeaderCredentials - -> Consensus.Protocol Consensus.ByronBlock + -> Consensus.Protocol ByronBlock ProtocolRealPBFT protocolConfigRealPbft (Update appName appVer lastKnownBlockVersion) pbftSignatureThresh genesis leaderCredentials = @@ -247,6 +246,6 @@ extractNodeInfo mNodeId ncNumCoreNodes = do coreNodeId <- case mNodeId of Just (CoreId coreNodeId) -> pure coreNodeId - _ -> Left MissingCoreNodeId + _ -> Left MissingCoreNodeId numCoreNodes <- maybe (Left MissingNumCoreNodes) Right ncNumCoreNodes return (coreNodeId , NumCoreNodes numCoreNodes) diff --git a/cardano-config/src/Cardano/Config/Types.hs b/cardano-config/src/Cardano/Config/Types.hs index 5ab9f571f96..a193dfafc73 100644 --- a/cardano-config/src/Cardano/Config/Types.hs +++ b/cardano-config/src/Cardano/Config/Types.hs @@ -166,6 +166,7 @@ instance FromJSON NodeConfiguration where <*> v .:? "TraceDNSResolver" .!= False <*> v .:? "TraceDNSSubscription" .!= True <*> v .:? "TraceErrorPolicy" .!= True + <*> v .:? "TraceLocalErrorPolicy" .!= True <*> v .:? "TraceForge" .!= True <*> v .:? "TraceIpSubscription" .!= True <*> v .:? "TraceLocalChainSyncProtocol" .!= False @@ -277,6 +278,7 @@ data TraceOptions = TraceOptions , traceDnsResolver :: !Bool , traceDnsSubscription :: !Bool , traceErrorPolicy :: !Bool + , traceLocalErrorPolicy :: !Bool , traceForge :: !Bool , traceIpSubscription :: !Bool , traceLocalChainSyncProtocol :: !Bool diff --git a/cardano-node/app/cardano-cli.hs b/cardano-node/app/cardano-cli.hs index 7d6b517d621..c01c4c2e398 100644 --- a/cardano-node/app/cardano-cli.hs +++ b/cardano-node/app/cardano-cli.hs @@ -13,6 +13,7 @@ import Cardano.CLI.Parsers import Cardano.CLI.Run import Cardano.Common.TopHandler + main :: IO () main = toplevelExceptionHandler $ do diff --git a/cardano-node/app/chairman.hs b/cardano-node/app/chairman.hs index 4271bf560a8..89a0e0c3334 100644 --- a/cardano-node/app/chairman.hs +++ b/cardano-node/app/chairman.hs @@ -15,6 +15,7 @@ import Control.Monad.Trans.Except.Extra (runExceptT) import Control.Tracer (stdoutTracer) import Ouroboros.Network.Block (BlockNo) +import Ouroboros.Network.NodeToClient (withIOManager) import Ouroboros.Consensus.Protocol.Abstract (SecurityParam (..)) import Cardano.Config.CommonCLI @@ -27,7 +28,7 @@ import Cardano.Common.Parsers import Cardano.Chairman (runChairman) main :: IO () -main = do +main = withIOManager $ \iocp -> do ChairmanArgs { caSecurityParam , caMaxBlockNo , caTimeout @@ -58,7 +59,8 @@ main = do Left err -> do putTextLn $ renderPtclInstantiationErr err exitFailure - let run = runChairman p + let run = runChairman iocp + p caSecurityParam caMaxBlockNo caSocketPaths diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 3ce86867e13..f9776a40569 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -36,7 +36,6 @@ library Cardano.CLI.Tx Cardano.Common.Help Cardano.Common.LocalSocket - Cardano.Common.Orphans Cardano.Common.Parsers Cardano.Common.TopHandler Cardano.Node.Features.Node @@ -90,6 +89,8 @@ library , network-mux , optparse-applicative , ouroboros-consensus + , ouroboros-consensus-byron + , ouroboros-consensus-cardano , ouroboros-network , safe-exceptions , serialise diff --git a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/Generation.hs b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/Generation.hs index d5b73a6d0d2..47ed442363d 100644 --- a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/Generation.hs +++ b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/Generation.hs @@ -83,18 +83,16 @@ import Cardano.CLI.Benchmarking.Tx.NodeToNode (BenchmarkTxSubmitTracer import Cardano.Node.TxSubClient import Control.Tracer (Tracer, traceWith) +import Ouroboros.Network.NodeToClient (AssociateWithIOCP) + import Ouroboros.Consensus.Node.Run (RunNode) -import Ouroboros.Consensus.Block(BlockProtocol) -import Ouroboros.Consensus.Ledger.Byron.Config (pbftProtocolMagic) -import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo (..), - protocolInfo) -import qualified Ouroboros.Consensus.Protocol as Consensus +import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo (..)) +import qualified Ouroboros.Consensus.Cardano as Consensus +import Ouroboros.Consensus.Config (TopLevelConfig (configBlock)) import qualified Ouroboros.Consensus.Mempool as Mempool -import Ouroboros.Consensus.Ledger.Byron (ByronBlock (..), +import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..), GenTx (..), - ByronConsensusProtocol) -import Ouroboros.Consensus.Protocol.Abstract (NodeConfig) -import Ouroboros.Consensus.Protocol.ExtConfig (extNodeConfig) + byronProtocolMagicId) newtype NumberOfTxs = NumberOfTxs Word64 @@ -145,8 +143,9 @@ newtype ExplorerAPIEnpoint = ----------------------------------------------------------------------------------------- genesisBenchmarkRunner :: LoggingLayer + -> AssociateWithIOCP -> SocketPath - -> Consensus.Protocol ByronBlock + -> Consensus.Protocol ByronBlock Consensus.ProtocolRealPBFT -> NonEmpty NodeAddress -> NumberOfTxs -> NumberOfInputsPerTx @@ -158,6 +157,7 @@ genesisBenchmarkRunner -> [FilePath] -> ExceptT TxGenError IO () genesisBenchmarkRunner loggingLayer + iocp socketFp protocol@(Consensus.ProtocolRealPBFT genesisConfig _ _ _ _) targetNodeAddresses @@ -190,7 +190,7 @@ genesisBenchmarkRunner loggingLayer liftIO . traceWith benchTracer . TraceBenchTxSubDebug $ "******* Tx generator, genesis UTxO is ready *******" - let ProtocolInfo{pInfoConfig} = protocolInfo protocol + let ProtocolInfo{pInfoConfig} = Consensus.protocolInfo protocol genesisAddress = mkAddressForKey pInfoConfig genesisKey sourceAddress = mkAddressForKey pInfoConfig sourceKey recipientAddress = mkAddressForKey pInfoConfig recepientKey @@ -203,6 +203,7 @@ genesisBenchmarkRunner loggingLayer fundsWithGenesisMoney <- liftIO $ prepareInitialFunds benchTracer lowLevelSubmitTracer + iocp socketFp genesisConfig pInfoConfig @@ -221,6 +222,7 @@ genesisBenchmarkRunner loggingLayer connectTracer submitTracer lowLevelSubmitTracer + iocp socketFp pInfoConfig sourceKey @@ -322,7 +324,7 @@ prepareSigningKeys skeys = do pure . map (Crypto.SigningKey . snd) $ rights desKeys mkAddressForKey - :: NodeConfig ByronConsensusProtocol + :: TopLevelConfig ByronBlock -> Crypto.SigningKey -> CC.Common.Address mkAddressForKey _pInfoConfig = @@ -391,9 +393,10 @@ extractGenesisFunds genesisConfig signingKeys = prepareInitialFunds :: Tracer IO (TraceBenchTxSubmit (Mempool.GenTxId ByronBlock)) -> Tracer IO TraceLowLevelSubmit + -> AssociateWithIOCP -> SocketPath -> CC.Genesis.Config - -> NodeConfig ByronConsensusProtocol + -> TopLevelConfig ByronBlock -> Map Int ((CC.UTxO.TxIn, CC.UTxO.TxOut), Crypto.SigningKey) -> CC.Common.Address -> CC.Common.Address @@ -402,6 +405,7 @@ prepareInitialFunds -> IO AvailableFunds prepareInitialFunds benchTracer llTracer + iocp socketFp genesisConfig pInfoConfig @@ -430,7 +434,7 @@ prepareInitialFunds benchTracer Nothing -> do -- There's no Explorer's API endpoint specified, submit genesis -- transaction to the target nodes via 'ouroboros-network'. - submitTx socketFp pInfoConfig genesisTxGeneral llTracer + submitTx iocp socketFp pInfoConfig genesisTxGeneral llTracer Just (ExplorerAPIEnpoint endpoint) -> do -- Explorer's API endpoint is specified, submit genesis -- transaction to that endpoint using POST-request. @@ -460,7 +464,7 @@ getTxIdFromGenTx _ = panic "Impossible happened: generated transaction is not a -- | One or more inputs -> one or more outputs. mkTransaction :: (FiscalRecipient r) - => NodeConfig ByronConsensusProtocol + => TopLevelConfig ByronBlock -> NonEmpty (TxDetails, Crypto.SigningKey) -- ^ Non-empty list of (TxIn, TxOut) that will be used as -- inputs and the key to spend the associated value @@ -589,7 +593,7 @@ appendr l nel = foldr NE.cons nel l -- | ... createTxAux - :: NodeConfig ByronConsensusProtocol + :: TopLevelConfig ByronBlock -> CC.UTxO.Tx -> Crypto.SigningKey -> CC.UTxO.ATxAux ByteString @@ -599,7 +603,7 @@ createTxAux config tx signingKey = CC.UTxO.annotateTxAux $ CC.UTxO.mkTxAux tx wi CC.UTxO.VKWitness (Crypto.toVerification signingKey) (Crypto.sign - (Crypto.getProtocolMagicId . pbftProtocolMagic . extNodeConfig $ config) + (byronProtocolMagicId (configBlock config)) -- provide ProtocolMagicId so as not to calculate it every time Crypto.SignTx signingKey @@ -635,8 +639,9 @@ runBenchmark -> Tracer IO SendRecvConnect -> Tracer IO (SendRecvTxSubmission ByronBlock) -> Tracer IO TraceLowLevelSubmit + -> AssociateWithIOCP -> SocketPath - -> NodeConfig ByronConsensusProtocol + -> TopLevelConfig ByronBlock -> Crypto.SigningKey -> CC.Common.Address -> NonEmpty NodeAddress @@ -653,6 +658,7 @@ runBenchmark benchTracer connectTracer submitTracer lowLevelSubmitTracer + iocp socketFp pInfoConfig sourceKey @@ -671,6 +677,7 @@ runBenchmark benchTracer fundsWithSufficientCoins <- createMoreFundCoins benchTracer lowLevelSubmitTracer + iocp socketFp pInfoConfig sourceKey @@ -768,6 +775,7 @@ runBenchmark benchTracer launchTxPeer benchTracer benchmarkTracers + iocp txSubmissionTerm pInfoConfig localAddr @@ -826,8 +834,9 @@ postTx benchTracer initialRequest serializedTx = do createMoreFundCoins :: Tracer IO (TraceBenchTxSubmit (Mempool.GenTxId ByronBlock)) -> Tracer IO TraceLowLevelSubmit + -> AssociateWithIOCP -> SocketPath - -> NodeConfig ByronConsensusProtocol + -> TopLevelConfig ByronBlock -> Crypto.SigningKey -> FeePerTx -> NumberOfTxs @@ -837,6 +846,7 @@ createMoreFundCoins -> ExceptT TxGenError IO AvailableFunds createMoreFundCoins benchTracer llTracer + iocp socketFp pInfoConfig sourceKey @@ -886,7 +896,7 @@ createMoreFundCoins benchTracer liftIO $ forM_ splittingTxs $ \(txAux, _) -> do let splittingTxGeneral :: GenTx ByronBlock splittingTxGeneral = normalByronTxToGenTx txAux - submitTx socketFp pInfoConfig splittingTxGeneral llTracer + submitTx iocp socketFp pInfoConfig splittingTxGeneral llTracer Just (ExplorerAPIEnpoint endpoint) -> do -- Explorer's API endpoint is specified, submit splitting -- transactions to that endpoint using POST-request. @@ -900,7 +910,7 @@ createMoreFundCoins benchTracer where -- create txs which split the funds to numTxOuts equal parts createSplittingTxs - :: NodeConfig ByronConsensusProtocol + :: TopLevelConfig ByronBlock -> (TxDetails, Crypto.SigningKey) -> Word64 -> Word64 @@ -973,7 +983,7 @@ minimalTPSRate (TPSRate tps) = picosecondsToDiffTime timeInPicoSecs txGenerator :: Tracer IO (TraceBenchTxSubmit (Mempool.GenTxId ByronBlock)) - -> NodeConfig ByronConsensusProtocol + -> TopLevelConfig ByronBlock -> CC.Common.Address -> Crypto.SigningKey -> FeePerTx @@ -1147,7 +1157,9 @@ writeTxsInListForTargetNode txsListsForTargetNodes txs listIndex = STM.atomicall -- | To get higher performance we need to hide latency of getting and -- forwarding (in sufficient numbers) transactions. - +-- +-- TODO: transform comments into haddocks. +-- launchTxPeer :: forall m block txid tx. ( RunNode block @@ -1161,9 +1173,11 @@ launchTxPeer -- tracer for lower level connection and details of -- protocol interactisn, intended for debugging -- associated issues. + -> AssociateWithIOCP + -- ^ associate a file descriptor with IO completion port -> MSTM.TVar m Bool -- a "global" stop variable, set to True to force shutdown - -> NodeConfig (Ouroboros.Consensus.Block.BlockProtocol block) + -> TopLevelConfig block -- the configuration -> Maybe Network.Socket.AddrInfo -- local address binding (if wanted) @@ -1176,7 +1190,7 @@ launchTxPeer -- give this peer 1 or more transactions, empty list -- signifies stop this peer -> m (Async (), Async ()) -launchTxPeer tr1 tr2 termTM nc localAddr remoteAddr updROEnv txInChan = do +launchTxPeer tr1 tr2 iocp termTM nc localAddr remoteAddr updROEnv txInChan = do tmv <- MSTM.newEmptyTMVarM - (,) <$> (async $ benchmarkConnectTxSubmit tr2 nc localAddr remoteAddr (txSubmissionClient tmv)) + (,) <$> (async $ benchmarkConnectTxSubmit iocp tr2 nc localAddr remoteAddr (txSubmissionClient tmv)) <*> (async $ bulkSubmission updROEnv tr1 termTM txInChan tmv) diff --git a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/NodeToNode.hs b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/NodeToNode.hs index 94845e27c73..a3d1a9ff889 100644 --- a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/NodeToNode.hs +++ b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/NodeToNode.hs @@ -31,7 +31,7 @@ import Data.Proxy (Proxy (..)) import qualified Data.Text as T import Data.Time.Clock (getCurrentTime) import Network.Mux (AppType(InitiatorApp), WithMuxBearer (..)) -import Network.Socket (AddrInfo) +import Network.Socket (AddrInfo (..)) import Network.TypedProtocol.Codec (AnyMessage (..)) import Network.TypedProtocol.Driver (TraceSendRecv (..), runPeer) @@ -41,25 +41,28 @@ import Cardano.BM.Data.Tracer (DefinePrivacyAnnotation (..), DefineSeverity (..), ToObject (..), TracingFormatting (..), TracingVerbosity (..), Transformable (..), emptyObject, mkObject, trStructured) -import Ouroboros.Consensus.Block (BlockProtocol) -import Ouroboros.Consensus.Ledger.Byron (ByronBlock (..)) +import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..)) import Ouroboros.Consensus.Mempool.API (GenTxId, GenTx) import Ouroboros.Consensus.Node.NetworkProtocolVersion import Ouroboros.Consensus.Node.Run (RunNode, nodeNetworkMagic) import Ouroboros.Consensus.NodeNetwork (ProtocolCodecs(..), protocolCodecs) -import Ouroboros.Consensus.Protocol.Abstract (NodeConfig) +import Ouroboros.Consensus.Config (TopLevelConfig) import Ouroboros.Network.Mux (OuroborosApplication(..)) import Ouroboros.Network.NodeToNode (NetworkConnectTracers (..)) import qualified Ouroboros.Network.NodeToNode as NtN +-- TODO: #1685 (ouroboros-network) IO manager terms and types should be exported +-- from NodeToNode module as well. +import Ouroboros.Network.NodeToClient (AssociateWithIOCP) import Ouroboros.Network.Protocol.BlockFetch.Client (BlockFetchClient(..), blockFetchClientPeer) import Ouroboros.Network.Protocol.ChainSync.Client (chainSyncClientNull, chainSyncClientPeer) import Ouroboros.Network.Protocol.Handshake.Type (Handshake) import Ouroboros.Network.Protocol.Handshake.Version (Versions, simpleSingletonVersions) import Ouroboros.Network.Protocol.TxSubmission.Client (TxSubmissionClient, txSubmissionClientPeer) import qualified Ouroboros.Network.Protocol.TxSubmission.Type as TS +import Ouroboros.Network.Snocket (socketSnocket) type SendRecvConnect = WithMuxBearer - NtN.ConnectionId + NtN.RemoteConnectionId (TraceSendRecv (Handshake NtN.NodeToNodeVersion CBOR.Term)) @@ -190,9 +193,10 @@ data BenchmarkTxSubmitTracers m blk = BenchmarkTracers benchmarkConnectTxSubmit :: forall m blk . (RunNode blk, m ~ IO) - => BenchmarkTxSubmitTracers m blk + => AssociateWithIOCP + -> BenchmarkTxSubmitTracers m blk -- ^ For tracing the send/receive actions - -> NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk -- ^ The particular block protocol -> Maybe AddrInfo -- ^ local address information (typically local interface/port to use) @@ -201,25 +205,26 @@ benchmarkConnectTxSubmit -> TxSubmissionClient (GenTxId blk) (GenTx blk) m () -- ^ the particular txSubmission peer -> m () -benchmarkConnectTxSubmit trs nc localAddr remoteAddr myTxSubClient = do +benchmarkConnectTxSubmit iocp trs cfg localAddr remoteAddr myTxSubClient = do NtN.connectTo + (socketSnocket iocp) NetworkConnectTracers { nctMuxTracer = nullTracer, nctHandshakeTracer = trSendRecvConnect trs } peerMultiplex - localAddr - remoteAddr + (addrAddress <$> localAddr) + (addrAddress remoteAddr) where myCodecs :: ProtocolCodecs blk DeserialiseFailure m ByteString ByteString ByteString ByteString ByteString ByteString ByteString ByteString - myCodecs = protocolCodecs nc (mostRecentNetworkProtocolVersion (Proxy @blk)) + myCodecs = protocolCodecs cfg (mostRecentNetworkProtocolVersion (Proxy @blk)) peerMultiplex :: Versions NtN.NodeToNodeVersion NtN.DictVersion (OuroborosApplication 'InitiatorApp - NtN.ConnectionId + NtN.RemoteConnectionId NtN.NodeToNodeProtocols m ByteString @@ -228,7 +233,7 @@ benchmarkConnectTxSubmit trs nc localAddr remoteAddr myTxSubClient = do peerMultiplex = simpleSingletonVersions NtN.NodeToNodeV_1 - (NtN.NodeToNodeVersionData { NtN.networkMagic = nodeNetworkMagic (Proxy @blk) nc}) + (NtN.NodeToNodeVersionData { NtN.networkMagic = nodeNetworkMagic (Proxy @blk) cfg}) (NtN.DictVersion NtN.nodeToNodeCodecCBORTerm) $ OuroborosInitiatorApplication $ \_peer ptcl -> case ptcl of diff --git a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/TxSubmission.hs b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/TxSubmission.hs index 7b6bfe107fa..f3751b662f7 100644 --- a/cardano-node/src/Cardano/CLI/Benchmarking/Tx/TxSubmission.hs +++ b/cardano-node/src/Cardano/CLI/Benchmarking/Tx/TxSubmission.hs @@ -40,7 +40,7 @@ import Cardano.BM.Data.Tracer (DefinePrivacyAnnotation (..), emptyObject, mkObject, nullTracer, trStructured) import Control.Tracer (Tracer, traceWith) -import Ouroboros.Consensus.Ledger.Byron (ByronBlock (..)) +import Ouroboros.Consensus.Byron.Ledger (ByronBlock (..)) import qualified Ouroboros.Consensus.Mempool as Mempool import qualified Ouroboros.Network.Protocol.TxSubmission.Type as TxSubmit diff --git a/cardano-node/src/Cardano/CLI/Ops.hs b/cardano-node/src/Cardano/CLI/Ops.hs index 89ddb00c619..b74c312aeb6 100644 --- a/cardano-node/src/Cardano/CLI/Ops.hs +++ b/cardano-node/src/Cardano/CLI/Ops.hs @@ -48,15 +48,16 @@ import Control.Tracer (nullTracer, stdoutTracer, traceWith) import Network.Mux (MuxError) import Network.TypedProtocol.Driver (runPeer) import Ouroboros.Consensus.Block (BlockProtocol) -import Ouroboros.Consensus.Ledger.Byron (ByronBlock, GenTx) +import Ouroboros.Consensus.Byron.Ledger (ByronBlock, GenTx) +import qualified Ouroboros.Consensus.Cardano as Consensus import Ouroboros.Consensus.Mempool.API (ApplyTxErr) import Ouroboros.Consensus.NodeNetwork (ProtocolCodecs(..), protocolCodecs) import Ouroboros.Consensus.Node.NetworkProtocolVersion (NodeToClientVersion, mostRecentNetworkProtocolVersion) -import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo(..), protocolInfo) +import Ouroboros.Consensus.Config (TopLevelConfig) +import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo(..)) import Ouroboros.Consensus.Node.Run (RunNode(..)) -import qualified Ouroboros.Consensus.Protocol as Consensus import Ouroboros.Consensus.Util.Condense (Condense(..)) import Ouroboros.Consensus.Util.IOLike (IOLike) import Ouroboros.Network.Block @@ -64,9 +65,9 @@ import Ouroboros.Network.Codec (Codec) import Ouroboros.Network.Mux (AppType(InitiatorApp), OuroborosApplication(..)) import Ouroboros.Network.NodeToClient - (NetworkConnectTracers(..), NodeToClientProtocols(..), NodeToClientVersionData(..) - , NodeToClientVersion(NodeToClientV_1), connectTo, localTxSubmissionClientNull - , nodeToClientCodecCBORTerm) + (AssociateWithIOCP, NetworkConnectTracers(..), NodeToClientProtocols(..) + , NodeToClientVersionData(..), NodeToClientVersion(NodeToClientV_1), connectTo + , localTxSubmissionClientNull, nodeToClientCodecCBORTerm) import Ouroboros.Network.Protocol.ChainSync.Client (ChainSyncClient(..), ClientStIdle(..), ClientStNext(..) , chainSyncClientPeer, recvMsgRollForward) @@ -77,6 +78,7 @@ import Ouroboros.Network.Protocol.LocalTxSubmission.Type (LocalTxSubmission) import Ouroboros.Network.Protocol.LocalTxSubmission.Client (localTxSubmissionClientPeer) +import Ouroboros.Network.Snocket (socketSnocket) import Cardano.Common.LocalSocket import Cardano.Config.Protocol @@ -246,7 +248,7 @@ withRealPBFT -> Update -> Protocol -> (RunNode ByronBlock - => Consensus.Protocol ByronBlock + => Consensus.Protocol ByronBlock Consensus.ProtocolRealPBFT -> ExceptT RealPBFTError IO a) -> ExceptT RealPBFTError IO a withRealPBFT gHash genFile nMagic sigThresh delCertFp sKeyFp update ptcl action = do @@ -274,9 +276,10 @@ withRealPBFT gHash genFile nMagic sigThresh delCertFp sKeyFp update ptcl action getLocalTip :: ConfigYamlFilePath -> GenesisFile + -> AssociateWithIOCP -> SocketPath -> IO () -getLocalTip configFp genFp sockPath = do +getLocalTip configFp genFp iocp sockPath = do nc <- parseNodeConfigurationFP $ unConfigPath configFp eGenHash <- runExceptT $ getGenesisHash genFp @@ -304,22 +307,23 @@ getLocalTip configFp genFp sockPath = do Left err -> do putTextLn . toS $ show err exitFailure - createNodeConnection (Proxy) p sockPath + createNodeConnection (Proxy) p iocp sockPath createNodeConnection :: forall blk . (Condense (HeaderHash blk), RunNode blk) => Proxy blk - -> Consensus.Protocol blk + -> Consensus.Protocol blk (BlockProtocol blk) + -> AssociateWithIOCP -> SocketPath -> IO () -createNodeConnection proxy ptcl socketPath = do - addr <- localSocketAddrInfo socketPath - let ProtocolInfo{pInfoConfig} = protocolInfo ptcl +createNodeConnection proxy ptcl iocp socketPath = do + addr <- localSocketPath socketPath + let ProtocolInfo{pInfoConfig} = Consensus.protocolInfo ptcl connectTo + (socketSnocket iocp) (NetworkConnectTracers nullTracer nullTracer) (localInitiatorNetworkApplication proxy pInfoConfig) - Nothing addr `catch` handleMuxError @@ -335,14 +339,14 @@ localInitiatorNetworkApplication , MonadTimer m ) => Proxy blk - -> Consensus.NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk -> Versions NodeToClientVersion DictVersion (OuroborosApplication 'InitiatorApp peer NodeToClientProtocols m LB.ByteString () Void) -localInitiatorNetworkApplication proxy pInfoConfig = +localInitiatorNetworkApplication proxy cfg = simpleSingletonVersions NodeToClientV_1 - (NodeToClientVersionData { networkMagic = nodeNetworkMagic proxy pInfoConfig }) + (NodeToClientVersionData { networkMagic = nodeNetworkMagic proxy cfg }) (DictVersion nodeToClientCodecCBORTerm) $ OuroborosInitiatorApplication $ \_peer ptcl -> case ptcl of @@ -361,10 +365,10 @@ localInitiatorNetworkApplication proxy pInfoConfig = (chainSyncClientPeer chainSyncClient) where localChainSyncCodec :: Codec (ChainSync (Serialised blk) (Tip blk)) DeserialiseFailure m LB.ByteString - localChainSyncCodec = pcLocalChainSyncCodec . protocolCodecs pInfoConfig $ mostRecentNetworkProtocolVersion proxy + localChainSyncCodec = pcLocalChainSyncCodec . protocolCodecs cfg $ mostRecentNetworkProtocolVersion proxy localTxSubmissionCodec :: Codec (LocalTxSubmission (GenTx blk) (ApplyTxErr blk)) DeserialiseFailure m LB.ByteString - localTxSubmissionCodec = pcLocalTxSubmissionCodec . protocolCodecs pInfoConfig $ mostRecentNetworkProtocolVersion proxy + localTxSubmissionCodec = pcLocalTxSubmissionCodec . protocolCodecs cfg $ mostRecentNetworkProtocolVersion proxy chainSyncClient :: forall blk m . (Condense (HeaderHash blk), MonadIO m) diff --git a/cardano-node/src/Cardano/CLI/Run.hs b/cardano-node/src/Cardano/CLI/Run.hs index 03ec036d54f..63d4f9e8468 100644 --- a/cardano-node/src/Cardano/CLI/Run.hs +++ b/cardano-node/src/Cardano/CLI/Run.hs @@ -26,6 +26,10 @@ module Cardano.CLI.Run ( , TPSRate(..) , TxAdditionalSize(..) , ExplorerAPIEnpoint(..) + + -- * re-exports from Ouroboros-Network + , AssociateWithIOCP + , withIOManager ) where import Cardano.Prelude hiding (option, trace) @@ -53,7 +57,11 @@ import Cardano.Crypto (ProtocolMagicId, RequiresNetworkMagic(..)) import qualified Cardano.Crypto.Hashing as Crypto import qualified Cardano.Crypto.Signing as Crypto -import qualified Ouroboros.Consensus.Protocol as Consensus +import Ouroboros.Network.NodeToClient ( AssociateWithIOCP + , withIOManager + ) + +import qualified Ouroboros.Consensus.Cardano as Consensus import Cardano.CLI.Delegation import Cardano.CLI.Genesis @@ -65,7 +73,6 @@ import Cardano.CLI.Benchmarking.Tx.Generation , NumberOfInputsPerTx (..), NumberOfOutputsPerTx (..) , FeePerTx (..), TPSRate (..), TxAdditionalSize (..) , genesisBenchmarkRunner) -import Cardano.Common.Orphans () import Cardano.Config.Protocol import Cardano.Config.Logging (createLoggingFeatureCLI) import Cardano.Config.Types @@ -193,18 +200,18 @@ data ClientCommand [SigningKeyFile] deriving Show + runCommand :: ClientCommand -> ExceptT CliError IO () runCommand (Genesis outDir params ptcl) = do gen <- mkGenesis params dumpGenesis ptcl outDir `uncurry` gen -runCommand (GetLocalNodeTip configFp gFile sockPath) = do - liftIO $ getLocalTip configFp gFile sockPath +runCommand (GetLocalNodeTip configFp gFile sockPath) = withIOManagerE $ \iocp -> + liftIO $ getLocalTip configFp gFile iocp sockPath runCommand (PrettySigningKeyPublic ptcl skF) = do sK <- readSigningKey ptcl skF liftIO . putTextLn . prettyPublicKey $ Crypto.toVerification sK - runCommand (MigrateDelegateKeyFrom oldPtcl oldKey newPtcl (NewSigningKeyFile newKey)) = do sk <- readSigningKey oldPtcl oldKey sDk <- hoistEither $ serialiseDelegateKey newPtcl sk @@ -247,7 +254,7 @@ runCommand (CheckDelegation magic cert issuerVF delegateVF) = do delegateVK <- readVerificationKey delegateVF liftIO $ checkByronGenesisDelegation cert magic issuerVK delegateVK -runCommand (SubmitTx fp ptcl genFile socketPath) = do +runCommand (SubmitTx fp ptcl genFile socketPath) = withIOManagerE $ \iocp -> do -- Default update value let update = Update (ApplicationName "cardano-sl") 1 $ LastKnownBlockVersion 0 2 0 tx <- liftIO $ readByronTx fp @@ -256,6 +263,7 @@ runCommand (SubmitTx fp ptcl genFile socketPath) = do firstExceptT NodeSubmitTxError $ nodeSubmitTx + iocp genHash Nothing genFile @@ -268,26 +276,26 @@ runCommand (SubmitTx fp ptcl genFile socketPath) = do ptcl tx runCommand (SpendGenesisUTxO ptcl genFile (NewTxFile ctTx) ctKey genRichAddr outs) = do - sk <- readSigningKey ptcl ctKey - -- Default update value - let update = Update (ApplicationName "cardano-sl") 1 $ LastKnownBlockVersion 0 2 0 - - genHash <- getGenesisHash genFile - - tx <- firstExceptT SpendGenesisUTxOError - $ issueGenesisUTxOExpenditure - genRichAddr - outs - genHash - genFile - RequiresNoMagic - Nothing - Nothing - Nothing - update - ptcl - sk - liftIO . ensureNewFileLBS ctTx $ toCborTxAux tx + sk <- readSigningKey ptcl ctKey + -- Default update value + let update = Update (ApplicationName "cardano-sl") 1 $ LastKnownBlockVersion 0 2 0 + + genHash <- getGenesisHash genFile + + tx <- firstExceptT SpendGenesisUTxOError + $ issueGenesisUTxOExpenditure + genRichAddr + outs + genHash + genFile + RequiresNoMagic + Nothing + Nothing + Nothing + update + ptcl + sk + liftIO . ensureNewFileLBS ctTx $ toCborTxAux tx runCommand (SpendUTxO ptcl genFile (NewTxFile ctTx) ctKey ins outs) = do sk <- readSigningKey ptcl ctKey @@ -313,20 +321,20 @@ runCommand (SpendUTxO ptcl genFile (NewTxFile ctTx) ctKey ins outs) = do liftIO . ensureNewFileLBS ctTx $ toCborTxAux gTx runCommand (GenerateTxs - logConfigFp - signingKey - delegCert - genFile - socketFp - targetNodeAddresses - numOfTxs - numOfInsPerTx - numOfOutsPerTx - feePerTx - tps - txAdditionalSize - explorerAPIEndpoint - sigKeysFiles) = do + logConfigFp + signingKey + delegCert + genFile + socketFp + targetNodeAddresses + numOfTxs + numOfInsPerTx + numOfOutsPerTx + feePerTx + tps + txAdditionalSize + explorerAPIEndpoint + sigKeysFiles) = withIOManagerE $ \iocp -> do -- Default update value let update = Update (ApplicationName "cardano-sl") 1 $ LastKnownBlockVersion 0 2 0 nc <- liftIO $ parseNodeConfigurationFP logConfigFp @@ -354,6 +362,7 @@ runCommand (GenerateTxs firstExceptT GenesisBenchmarkRunnerError $ genesisBenchmarkRunner loggingLayer + iocp socketFp protocol targetNodeAddresses @@ -382,3 +391,6 @@ ensureNewFile writer outFile blob = do ensureNewFileLBS :: FilePath -> LB.ByteString -> IO () ensureNewFileLBS = ensureNewFile LB.writeFile + +withIOManagerE :: (AssociateWithIOCP -> ExceptT e IO a) -> ExceptT e IO a +withIOManagerE k = ExceptT $ withIOManager (runExceptT . k) diff --git a/cardano-node/src/Cardano/CLI/Tx.hs b/cardano-node/src/Cardano/CLI/Tx.hs index 798850df8a1..70bb4dd78b0 100644 --- a/cardano-node/src/Cardano/CLI/Tx.hs +++ b/cardano-node/src/Cardano/CLI/Tx.hs @@ -48,10 +48,12 @@ import Cardano.Crypto (SigningKey(..), ProtocolMagicId, RequiresNetwor import qualified Cardano.Crypto.Hashing as Crypto import qualified Cardano.Crypto.Signing as Crypto -import qualified Ouroboros.Consensus.Ledger.Byron as Byron -import Ouroboros.Consensus.Ledger.Byron (GenTx(..), ByronBlock) -import qualified Ouroboros.Consensus.Protocol as Consensus -import Ouroboros.Consensus.Node.ProtocolInfo (protocolInfo, pInfoConfig) +import Ouroboros.Network.NodeToClient (AssociateWithIOCP) + +import qualified Ouroboros.Consensus.Byron.Ledger as Byron +import Ouroboros.Consensus.Byron.Ledger (GenTx(..), ByronBlock) +import qualified Ouroboros.Consensus.Cardano as Consensus +import Ouroboros.Consensus.Node.ProtocolInfo (pInfoConfig) import qualified Ouroboros.Consensus.Mempool as Consensus import Ouroboros.Consensus.Util.Condense (condense) @@ -60,7 +62,6 @@ import Cardano.Node.Submission import Cardano.Config.Protocol import Cardano.Config.Types (DelegationCertFile, GenesisFile, SigningKeyFile, SocketPath, Update) -import Cardano.Common.Orphans () newtype TxFile = @@ -247,7 +248,8 @@ issueUTxOExpenditure -- | Submit a transaction to a node specified by topology info. nodeSubmitTx - :: Text + :: AssociateWithIOCP + -> Text -- ^ Genesis hash. -> Maybe Int -- ^ Number of core nodes. @@ -262,6 +264,7 @@ nodeSubmitTx -> GenTx ByronBlock -> ExceptT RealPBFTError IO () nodeSubmitTx + iocp gHash _mNumCoreNodes genFile @@ -277,8 +280,8 @@ nodeSubmitTx \p@Consensus.ProtocolRealPBFT{} -> liftIO $ do -- TODO: Update submitGenTx to use `ExceptT` traceWith stdoutTracer ("TxId: " ++ condense (Consensus.txId gentx)) - submitTx targetSocketFp - (pInfoConfig (protocolInfo p)) + submitTx iocp targetSocketFp + (pInfoConfig (Consensus.protocolInfo p)) gentx nullTracer -- stdoutTracer diff --git a/cardano-node/src/Cardano/Chairman.hs b/cardano-node/src/Cardano/Chairman.hs index 1437751c239..a9b2d70b894 100644 --- a/cardano-node/src/Cardano/Chairman.hs +++ b/cardano-node/src/Cardano/Chairman.hs @@ -37,10 +37,11 @@ import Control.Tracer import Network.Mux (MuxError) import Ouroboros.Consensus.Block (BlockProtocol, GetHeader (..)) +import Ouroboros.Consensus.Config (TopLevelConfig) import Ouroboros.Consensus.Mempool import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.Node.Run -import Ouroboros.Consensus.Protocol +import Ouroboros.Consensus.Cardano import Ouroboros.Consensus.Util.Condense import Network.TypedProtocol.Driver @@ -58,6 +59,7 @@ import Ouroboros.Network.Protocol.ChainSync.Client import Ouroboros.Network.Protocol.ChainSync.Codec import Ouroboros.Network.Protocol.Handshake.Version import Ouroboros.Network.NodeToClient +import Ouroboros.Network.Snocket (socketSnocket) import Cardano.Common.LocalSocket import Cardano.Config.Types (SocketPath) @@ -73,7 +75,8 @@ runChairman :: forall blk. ( RunNode blk , TraceConstraints blk ) - => Protocol blk + => AssociateWithIOCP + -> Protocol blk (BlockProtocol blk) -> SecurityParam -- ^ security parameter, if a fork is deeper than it 'runChairman' -- will throw an exception. @@ -83,20 +86,21 @@ runChairman :: forall blk. -- ^ local socket dir -> Tracer IO String -> IO () -runChairman ptcl securityParam maxBlockNo socketPaths tracer = do +runChairman iocp ptcl securityParam maxBlockNo socketPaths tracer = do (chainsVar :: ChainsVar IO blk) <- newTVarM (Map.fromList $ map (\socketPath -> (socketPath, AF.Empty AF.AnchorGenesis)) socketPaths) void $ flip mapConcurrently socketPaths $ \sockPath -> - let ProtocolInfo{pInfoConfig} = protocolInfo ptcl + let ProtocolInfo { pInfoConfig = cfg } = protocolInfo ptcl in createConnection chainsVar securityParam maxBlockNo tracer - pInfoConfig + cfg + iocp sockPath -- catch 'MuxError'; it will be thrown if a node shuts down closing the @@ -122,7 +126,8 @@ createConnection -> SecurityParam -> Maybe BlockNo -> Tracer IO String - -> NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk + -> AssociateWithIOCP -> SocketPath -> IO () createConnection @@ -130,26 +135,27 @@ createConnection securityParam maxBlockNo tracer - pInfoConfig + cfg + iocp socketPath = do - addr <- localSocketAddrInfo socketPath - connectTo - NetworkConnectTracers { - nctMuxTracer = nullTracer, - nctHandshakeTracer = nullTracer - } - (localInitiatorNetworkApplication - socketPath - chainsVar - securityParam - maxBlockNo - (showTracing tracer) - nullTracer - nullTracer - pInfoConfig) - Nothing - addr - `catch` handleMuxError tracer chainsVar socketPath + path <- localSocketPath socketPath + connectTo + (socketSnocket iocp) + NetworkConnectTracers { + nctMuxTracer = nullTracer, + nctHandshakeTracer = nullTracer + } + (localInitiatorNetworkApplication + socketPath + chainsVar + securityParam + maxBlockNo + (showTracing tracer) + nullTracer + nullTracer + cfg) + path + `catch` handleMuxError tracer chainsVar socketPath data ChairmanTrace blk = WitnessedConsensus [Point (Header blk)] @@ -371,14 +377,14 @@ localInitiatorNetworkApplication -- ^ tracer which logs all local tx submission protocol messages send and -- received by the client (see 'Ouroboros.Network.Protocol.LocalTxSubmission.Type' -- in 'ouroboros-network' package). - -> NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk -> Versions NodeToClientVersion DictVersion (OuroborosApplication 'InitiatorApp peer NodeToClientProtocols m ByteString () Void) -localInitiatorNetworkApplication sockPath chainsVar securityParam maxBlockNo chairmanTracer chainSyncTracer localTxSubmissionTracer pInfoConfig = +localInitiatorNetworkApplication sockPath chainsVar securityParam maxBlockNo chairmanTracer chainSyncTracer localTxSubmissionTracer cfg = simpleSingletonVersions NodeToClientV_1 - (NodeToClientVersionData (nodeNetworkMagic (Proxy @blk) pInfoConfig)) + (NodeToClientVersionData (nodeNetworkMagic (Proxy @blk) cfg)) (DictVersion nodeToClientCodecCBORTerm) $ OuroborosInitiatorApplication $ \_peer ptcl -> case ptcl of @@ -392,7 +398,7 @@ localInitiatorNetworkApplication sockPath chainsVar securityParam maxBlockNo cha ChainSyncWithBlocksPtcl -> \channel -> runPeer chainSyncTracer - (localChainSyncCodec pInfoConfig) + (localChainSyncCodec cfg) channel (chainSyncClientPeer $ chainSyncClient chairmanTracer sockPath chainsVar securityParam maxBlockNo) @@ -417,13 +423,13 @@ localChainSyncCodec ( RunNode blk , MonadST m ) - => NodeConfig (BlockProtocol blk) + => TopLevelConfig blk -> Codec (ChainSync blk (Tip blk)) DeserialiseFailure m ByteString -localChainSyncCodec pInfoConfig = +localChainSyncCodec cfg = codecChainSync - (Block.wrapCBORinCBOR (nodeEncodeBlock pInfoConfig)) - (Block.unwrapCBORinCBOR (nodeDecodeBlock pInfoConfig)) + (Block.wrapCBORinCBOR (nodeEncodeBlock cfg)) + (Block.unwrapCBORinCBOR (nodeDecodeBlock cfg)) (Block.encodePoint (nodeEncodeHeaderHash (Proxy @blk))) (Block.decodePoint (nodeDecodeHeaderHash (Proxy @blk))) (Block.encodeTip (nodeEncodeHeaderHash (Proxy @blk))) diff --git a/cardano-node/src/Cardano/Common/LocalSocket.hs b/cardano-node/src/Cardano/Common/LocalSocket.hs index 5c56b83edd8..cab63dce392 100644 --- a/cardano-node/src/Cardano/Common/LocalSocket.hs +++ b/cardano-node/src/Cardano/Common/LocalSocket.hs @@ -1,5 +1,5 @@ module Cardano.Common.LocalSocket - ( localSocketAddrInfo + ( localSocketPath , nodeLocalSocketAddrInfo , removeStaleLocalSocket ) @@ -10,32 +10,24 @@ import Cardano.Prelude import System.Directory (createDirectoryIfMissing, removeFile) import System.FilePath (takeDirectory) import System.IO.Error (isDoesNotExistError) -import Network.Socket as Socket import Cardano.Config.Types ( MiscellaneousFilepaths(..), NodeCLI(..) , NodeMockCLI(..), NodeProtocolMode(..) , SocketPath(..)) -nodeLocalSocketAddrInfo :: NodeProtocolMode -> IO Socket.AddrInfo +nodeLocalSocketAddrInfo :: NodeProtocolMode -> IO FilePath nodeLocalSocketAddrInfo npm = case npm of - MockProtocolMode (NodeMockCLI mscFp' _ _ _ _) -> localSocketAddrInfo $ socketFile mscFp' - RealProtocolMode (NodeCLI mscFp' _ _ _ _) -> localSocketAddrInfo $ socketFile mscFp' + MockProtocolMode (NodeMockCLI mscFp' _ _ _ _) -> localSocketPath $ socketFile mscFp' + RealProtocolMode (NodeCLI mscFp' _ _ _ _) -> localSocketPath $ socketFile mscFp' --- | Provide an AF_UNIX address for a socket situated in 'socketDir', with its name --- derived from the node ID. When 'mkdir' is 'MkdirIfMissing', the directory is created. -localSocketAddrInfo :: SocketPath -> IO Socket.AddrInfo -localSocketAddrInfo (SocketFile fp) = do +-- | Provide an filepath intended for a socket situated in 'socketDir'. +-- When 'mkdir' is 'MkdirIfMissing', the directory is created. +localSocketPath :: SocketPath -> IO FilePath +localSocketPath (SocketFile fp) = do createDirectoryIfMissing True $ takeDirectory fp - pure $ - Socket.AddrInfo - [] - Socket.AF_UNIX - Socket.Stream - Socket.defaultProtocol - (Socket.SockAddrUnix fp) - Nothing + return fp -- TODO: Convert to ExceptT -- | Remove the socket established with 'localSocketAddrInfo'. diff --git a/cardano-node/src/Cardano/Common/Orphans.hs b/cardano-node/src/Cardano/Common/Orphans.hs deleted file mode 100644 index ac9c9dc77c2..00000000000 --- a/cardano-node/src/Cardano/Common/Orphans.hs +++ /dev/null @@ -1,19 +0,0 @@ -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# OPTIONS_GHC -Wno-all-missed-specialisations #-} -{-# OPTIONS_GHC -Wno-orphans #-} - -module Cardano.Common.Orphans - () -where - -import Codec.Serialise (Serialise(..)) - -import Ouroboros.Consensus.Ledger.Byron - ( ByronBlock, GenTx(..) - , decodeByronGenTx, encodeByronGenTx) - -instance Serialise (GenTx ByronBlock) where - decode = decodeByronGenTx - encode = encodeByronGenTx diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index ca77adffdcf..0a6d5698407 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -54,22 +54,26 @@ import Cardano.Config.Logging (LoggingLayer (..)) import Cardano.Config.Types (MiscellaneousFilepaths(..), NodeConfiguration (..), ViewMode (..)) + import Ouroboros.Network.Block +import Ouroboros.Network.NodeToClient (LocalConnectionId) import Ouroboros.Consensus.Block (BlockProtocol) import Ouroboros.Consensus.Node (NodeKernel (getChainDB), - ConnectionId (..), DiffusionTracers (..), DiffusionArguments (..), + DiffusionTracers (..), DiffusionArguments (..), DnsSubscriptionTarget (..), IPSubscriptionTarget (..), - RunNode (nodeNetworkMagic, nodeStartTime), IsProducer (..)) + RunNode (nodeNetworkMagic, nodeStartTime), IsProducer (..), + RemoteConnectionId) import qualified Ouroboros.Consensus.Node as Node (run) import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.NodeId -import qualified Ouroboros.Consensus.Protocol as Consensus +import qualified Ouroboros.Consensus.Config as Consensus +import qualified Ouroboros.Consensus.Cardano as Consensus import Ouroboros.Consensus.Util.Orphans () import Ouroboros.Consensus.Util.STM (onEachChange) -import qualified Ouroboros.Storage.ChainDB as ChainDB -import Ouroboros.Storage.ImmutableDB (ValidationPolicy (..)) -import Ouroboros.Storage.VolatileDB (BlockValidationPolicy (..)) +import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB +import Ouroboros.Consensus.Storage.ImmutableDB (ValidationPolicy (..)) +import Ouroboros.Consensus.Storage.VolatileDB (BlockValidationPolicy (..)) import Cardano.Common.LocalSocket import Cardano.Config.Protocol (SomeProtocol(..), fromProtocol) @@ -113,7 +117,7 @@ runNode loggingLayer npm = do (ncUpdate nc) (ncProtocol nc) - SomeProtocol (p :: Consensus.Protocol blk) <- + SomeProtocol (p :: Consensus.Protocol blk (BlockProtocol blk)) <- case eitherSomeProtocol of Left err -> (putTextLn . pack $ show err) >> exitFailure Right (SomeProtocol p) -> pure $ SomeProtocol p @@ -155,18 +159,18 @@ runNode loggingLayer npm = do handleSimpleNode :: forall blk. RunNode blk - => Consensus.Protocol blk + => Consensus.Protocol blk (BlockProtocol blk) -> Trace IO Text - -> Tracers ConnectionId blk + -> Tracers RemoteConnectionId LocalConnectionId blk -> NodeProtocolMode - -> (NodeKernel IO ConnectionId blk -> IO ()) + -> (NodeKernel IO RemoteConnectionId blk -> IO ()) -- ^ Called on the 'NodeKernel' after creating it, but before the network -- layer is initialised. This implies this function must not block, -- otherwise the node won't actually start. -> IO () handleSimpleNode p trace nodeTracers npm onKernel = do - let pInfo@ProtocolInfo{ pInfoConfig = cfg } = protocolInfo p + let pInfo@ProtocolInfo{ pInfoConfig = cfg } = Consensus.protocolInfo p tracer = contramap pack $ toLogObject trace -- Node configuration @@ -241,12 +245,14 @@ handleSimpleNode p trace nodeTracers npm onKernel = do Just (CoreId _) -> IsProducer _ -> IsNotProducer - createDiffusionTracers :: Tracers ConnectionId blk -> DiffusionTracers + createDiffusionTracers :: Tracers RemoteConnectionId LocalConnectionId blk + -> DiffusionTracers createDiffusionTracers nodeTracers' = DiffusionTracers { dtIpSubscriptionTracer = ipSubscriptionTracer nodeTracers' , dtDnsSubscriptionTracer = dnsSubscriptionTracer nodeTracers' , dtDnsResolverTracer = dnsResolverTracer nodeTracers' , dtErrorPolicyTracer = errorPolicyTracer nodeTracers' + , dtLocalErrorPolicyTracer = localErrorPolicyTracer nodeTracers' , dtMuxTracer = muxTracer nodeTracers' , dtMuxLocalTracer = nullTracer , dtHandshakeTracer = nullTracer @@ -256,7 +262,7 @@ handleSimpleNode p trace nodeTracers npm onKernel = do createTracers :: NodeProtocolMode -> Tracer IO GHC.Base.String - -> Consensus.NodeConfig (BlockProtocol blk) + -> Consensus.TopLevelConfig blk -> IO () createTracers npm' tracer cfg = do case npm' of @@ -333,7 +339,7 @@ dbValidation (RealProtocolMode (NodeCLI _ _ _ _ dbval)) = dbval createDiffusionArguments :: [AddrInfo] - -> AddrInfo + -> FilePath -> IPSubscriptionTarget -> [DnsSubscriptionTarget] -> DiffusionArguments diff --git a/cardano-node/src/Cardano/Node/Submission.hs b/cardano-node/src/Cardano/Node/Submission.hs index 5e2b8dad5b1..2689d9a6c41 100644 --- a/cardano-node/src/Cardano/Node/Submission.hs +++ b/cardano-node/src/Cardano/Node/Submission.hs @@ -26,11 +26,10 @@ import Control.Monad.Class.MonadThrow (MonadThrow) import Control.Monad.Class.MonadTimer (MonadTimer) import Control.Tracer (Tracer, nullTracer, traceWith) -import Ouroboros.Consensus.Block (BlockProtocol) import Ouroboros.Consensus.Mempool (ApplyTxErr, GenTx) import Ouroboros.Consensus.Node.Run (RunNode) import qualified Ouroboros.Consensus.Node.Run as Node -import Ouroboros.Consensus.Protocol (NodeConfig) +import Ouroboros.Consensus.Config (TopLevelConfig) import Network.TypedProtocol.Driver (runPeer) import Ouroboros.Network.Codec (Codec, DeserialiseFailure) @@ -45,8 +44,10 @@ import Ouroboros.Network.Protocol.ChainSync.Client (chainSyncClientPee import Ouroboros.Network.Protocol.ChainSync.Codec (codecChainSync) import Ouroboros.Network.Protocol.Handshake.Version ( Versions , simpleSingletonVersions) -import Ouroboros.Network.NodeToClient (NetworkConnectTracers (..)) +import Ouroboros.Network.NodeToClient ( AssociateWithIOCP + , NetworkConnectTracers (..)) import qualified Ouroboros.Network.NodeToClient as NodeToClient +import Ouroboros.Network.Snocket (socketSnocket) import Cardano.BM.Data.Tracer (DefinePrivacyAnnotation (..), DefineSeverity (..), ToObject (..), TracingFormatting (..), @@ -101,20 +102,21 @@ instance (MonadIO m) => Transformable Text m TraceLowLevelSubmit where submitTx :: ( RunNode blk , Show (ApplyTxErr blk) ) - => SocketPath - -> NodeConfig (BlockProtocol blk) + => AssociateWithIOCP + -> SocketPath + -> TopLevelConfig blk -> GenTx blk -> Tracer IO TraceLowLevelSubmit -> IO () -submitTx targetSocketFp protoInfoConfig tx tracer = do - targetSocketFp' <- localSocketAddrInfo targetSocketFp +submitTx iocp targetSocketFp cfg tx tracer = do + targetSocketFp' <- localSocketPath targetSocketFp NodeToClient.connectTo + (socketSnocket iocp) NetworkConnectTracers { nctMuxTracer = nullTracer, nctHandshakeTracer = nullTracer } - (localInitiatorNetworkApplication tracer protoInfoConfig tx) - Nothing + (localInitiatorNetworkApplication tracer cfg tx) targetSocketFp' localInitiatorNetworkApplication @@ -126,16 +128,16 @@ localInitiatorNetworkApplication , Show (ApplyTxErr blk) ) => Tracer m TraceLowLevelSubmit - -> NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk -> GenTx blk -> Versions NodeToClient.NodeToClientVersion NodeToClient.DictVersion (OuroborosApplication 'InitiatorApp peer NodeToClient.NodeToClientProtocols m ByteString () Void) -localInitiatorNetworkApplication tracer protoInfoConfig tx = +localInitiatorNetworkApplication tracer cfg tx = simpleSingletonVersions NodeToClient.NodeToClientV_1 (NodeToClient.NodeToClientVersionData - { NodeToClient.networkMagic = Node.nodeNetworkMagic (Proxy @blk) protoInfoConfig }) + { NodeToClient.networkMagic = Node.nodeNetworkMagic (Proxy @blk) cfg }) (NodeToClient.DictVersion NodeToClient.nodeToClientCodecCBORTerm) $ OuroborosInitiatorApplication $ \_peer ptcl -> case ptcl of @@ -154,7 +156,7 @@ localInitiatorNetworkApplication tracer protoInfoConfig tx = NodeToClient.ChainSyncWithBlocksPtcl -> \channel -> runPeer nullTracer - (localChainSyncCodec @blk protoInfoConfig) + (localChainSyncCodec @blk cfg) channel (chainSyncClientPeer NodeToClient.chainSyncClientNull) @@ -183,13 +185,13 @@ localTxSubmissionCodec = localChainSyncCodec :: forall blk m. (RunNode blk, MonadST m) - => NodeConfig (BlockProtocol blk) + => TopLevelConfig blk -> Codec (ChainSync blk (Point blk)) DeserialiseFailure m ByteString -localChainSyncCodec protoInfoConfig = +localChainSyncCodec cfg = codecChainSync - (Block.wrapCBORinCBOR (Node.nodeEncodeBlock protoInfoConfig)) - (Block.unwrapCBORinCBOR (Node.nodeDecodeBlock protoInfoConfig)) + (Block.wrapCBORinCBOR (Node.nodeEncodeBlock cfg)) + (Block.unwrapCBORinCBOR (Node.nodeDecodeBlock cfg)) (Block.encodePoint (Node.nodeEncodeHeaderHash (Proxy @blk))) (Block.decodePoint (Node.nodeDecodeHeaderHash (Proxy @blk))) (Block.encodePoint (Node.nodeEncodeHeaderHash (Proxy @blk))) diff --git a/cardano-node/src/Cardano/Node/TUI/LiveView.hs b/cardano-node/src/Cardano/Node/TUI/LiveView.hs index 219f727bb8c..53a335a97b4 100644 --- a/cardano-node/src/Cardano/Node/TUI/LiveView.hs +++ b/cardano-node/src/Cardano/Node/TUI/LiveView.hs @@ -82,7 +82,7 @@ import Cardano.Slotting.Slot (unSlotNo) import qualified Ouroboros.Network.AnchoredFragment as Net import qualified Ouroboros.Network.Block as Net import Ouroboros.Consensus.Block (GetHeader(..)) -import Ouroboros.Consensus.Node (NodeKernel(..), ConnectionId(..)) +import Ouroboros.Consensus.Node (NodeKernel(..), RemoteConnectionId, remoteAddress) import Ouroboros.Consensus.NodeId import qualified Ouroboros.Network.BlockFetch.ClientState as Net import qualified Ouroboros.Network.BlockFetch.ClientRegistry as Net @@ -190,7 +190,7 @@ fromSMaybe x SNothing = x fromSMaybe _ (SJust x) = x data LVNodeKernel blk = LVNodeKernel - { getNodeKernel :: !(NodeKernel IO ConnectionId blk) } + { getNodeKernel :: !(NodeKernel IO RemoteConnectionId blk) } deriving (Generic) instance NoUnexpectedThunks (LVNodeKernel blk) where @@ -373,7 +373,7 @@ instance IsEffectuator (LiveViewBackend blk) Text where -> STM.STM IO (Map peer (Net.AnchoredFragment (Header blk))) getCandidates var = STM.readTVar var >>= traverse STM.readTVar - extractPeers :: NodeKernel IO ConnectionId blk -> IO [LVPeer blk] + extractPeers :: NodeKernel IO RemoteConnectionId blk -> IO [LVPeer blk] extractPeers kernel = do peerStates <- fmap tuple3pop <$> (atomically . (>>= traverse Net.readFetchClientState) . Net.readFetchClientsStateVars . getFetchClientRegistry $ kernel) candidates <- atomically . getCandidates . getNodeCandidates $ kernel @@ -562,7 +562,7 @@ setNodeThread lvbe nodeThr = modifyMVar_ (getbe lvbe) $ \lvs -> return $ lvs { lvsNodeThread = LiveViewThread $ Just nodeThr } -setNodeKernel :: NFData a => LiveViewBackend blk a -> NodeKernel IO ConnectionId blk -> IO () +setNodeKernel :: NFData a => LiveViewBackend blk a -> NodeKernel IO RemoteConnectionId blk -> IO () setNodeKernel lvbe nodeKern = modifyMVar_ (getbe lvbe) $ \lvs -> return $ lvs { lvsNodeKernel = SJust (LVNodeKernel nodeKern) } @@ -710,7 +710,7 @@ darkTheme = newTheme (V.white `on` darkMainBG) data LVPeer blk = LVPeer - !ConnectionId + !RemoteConnectionId !(Net.AnchoredFragment (Header blk)) !(Net.PeerFetchStatus (Header blk)) !(Net.PeerFetchInFlight (Header blk)) @@ -726,7 +726,7 @@ ppPeer :: LVPeer blk -> Text ppPeer (LVPeer cid _af status inflight) = pack $ printf "%-15s %-8s %s" (ppCid cid) (ppStatus status) (ppInFlight inflight) where - ppCid :: ConnectionId -> String + ppCid :: RemoteConnectionId -> String ppCid = takeWhile (/= ':') . show . remoteAddress ppInFlight :: Net.PeerFetchInFlight header -> String @@ -745,7 +745,7 @@ ppPeer (LVPeer cid _af status inflight) = ppStatus Net.PeerFetchStatusShutdown = "shutdown" ppStatus Net.PeerFetchStatusAberrant = "aberrant" ppStatus Net.PeerFetchStatusBusy = "fetching" - ppStatus (Net.PeerFetchStatusReady _blks) = "ready" + ppStatus (Net.PeerFetchStatusReady {}) = "ready" drawUI :: LiveViewState blk a -> [Widget ()] drawUI p = case lvsScreen p of diff --git a/cardano-node/src/Cardano/Tracing/MicroBenchmarking.hs b/cardano-node/src/Cardano/Tracing/MicroBenchmarking.hs index d4190200490..c90c267b4c8 100644 --- a/cardano-node/src/Cardano/Tracing/MicroBenchmarking.hs +++ b/cardano-node/src/Cardano/Tracing/MicroBenchmarking.hs @@ -38,7 +38,6 @@ import Control.Tracer.Transformers.ObserveOutcome import Ouroboros.Network.Block (SlotNo (..)) -import Ouroboros.Consensus.Ledger.Abstract (ProtocolLedgerView) import Ouroboros.Consensus.Mempool.API (ApplyTx (..), GenTx, GenTxId, HasTxId (..), MempoolSize (..), TraceEventMempool (..), txId) @@ -53,8 +52,8 @@ data MeasureTxs blk = MeasureTxsTimeStart (GenTx blk) !Word !Word !Time -- num txs, total size in bytes | MeasureTxsTimeStop !SlotNo blk [GenTx blk] !Time -deriving instance (ProtocolLedgerView blk, Eq blk, Eq (GenTx blk)) => Eq (MeasureTxs blk) -deriving instance (ProtocolLedgerView blk, Show blk, Show (GenTx blk)) => Show (MeasureTxs blk) +deriving instance (Eq blk, Eq (GenTx blk)) => Eq (MeasureTxs blk) +deriving instance (Show blk, Show (GenTx blk)) => Show (MeasureTxs blk) instance Transformable Text IO (MeasureTxs blk) where trTransformer _ verb tr = trStructured verb tr @@ -177,8 +176,8 @@ data MeasureBlockForging blk = MeasureBlockTimeStart !SlotNo !Time | MeasureBlockTimeStop !SlotNo blk !MempoolSize !Time -deriving instance (ProtocolLedgerView blk, Eq blk, Eq (GenTx blk)) => Eq (MeasureBlockForging blk) -deriving instance (ProtocolLedgerView blk, Show blk, Show (GenTx blk)) => Show (MeasureBlockForging blk) +deriving instance (Eq blk, Eq (GenTx blk)) => Eq (MeasureBlockForging blk) +deriving instance (Show blk, Show (GenTx blk)) => Show (MeasureBlockForging blk) instance Transformable Text IO (MeasureBlockForging blk) where trTransformer _ verb tr = trStructured verb tr diff --git a/cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs b/cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs index e9fe1a0e0b5..8cdbb1a8c10 100644 --- a/cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs +++ b/cardano-node/src/Cardano/Tracing/ToObjectOrphans.hs @@ -31,14 +31,15 @@ import Cardano.BM.Data.LogItem (LOContent (..), LogObject (..), import Cardano.BM.Tracing import Cardano.BM.Data.Tracer (trStructured, emptyObject, mkObject) -import Ouroboros.Consensus.Block (Header, SupportedBlock, headerPoint) +import Ouroboros.Consensus.Block (Header, headerPoint) import Ouroboros.Consensus.BlockFetchServer (TraceBlockFetchServerEvent) import Ouroboros.Consensus.ChainSyncClient (TraceChainSyncClientEvent (..)) import Ouroboros.Consensus.ChainSyncServer (TraceChainSyncServerEvent(..)) -import Ouroboros.Consensus.Ledger.Abstract +import Ouroboros.Consensus.Ledger.SupportsProtocol + (LedgerSupportsProtocol) import Ouroboros.Consensus.Mempool.API (GenTx, GenTxId, HasTxId, TraceEventMempool (..), TxId, txId) import Ouroboros.Consensus.Node.Tracers (TraceForgeEvent (..)) @@ -64,9 +65,9 @@ import Ouroboros.Network.TxSubmission.Inbound 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 +import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB +import Ouroboros.Consensus.Storage.Common (EpochNo (..)) +import qualified Ouroboros.Consensus.Storage.LedgerDB.OnDisk as LedgerDB -- | Tracing wrapper which includes current tip in the logs (thus it requires -- it from the context). @@ -237,7 +238,7 @@ defaultTextTransformer _ verb tr = instance ( DefinePrivacyAnnotation (ChainDB.TraceAddBlockEvent blk) , DefineSeverity (ChainDB.TraceAddBlockEvent blk) - , ProtocolLedgerView blk + , LedgerSupportsProtocol blk , Show (Ouroboros.Consensus.Block.Header blk) , ToObject (ChainDB.TraceAddBlockEvent blk)) => Transformable Text IO (ChainDB.TraceAddBlockEvent blk) where @@ -252,7 +253,8 @@ instance DefineSeverity (ChainDB.TraceEvent blk) where ChainDB.StoreButDontChange {} -> Debug ChainDB.TryAddToCurrentChain {} -> Debug ChainDB.TrySwitchToAFork {} -> Info - ChainDB.SwitchedToChain {} -> Notice + ChainDB.AddedToCurrentChain {} -> Notice + ChainDB.SwitchedToAFork {} -> Notice ChainDB.AddBlockValidation ev' -> case ev' of ChainDB.InvalidBlock {} -> Error ChainDB.InvalidCandidate {} -> Error @@ -373,7 +375,7 @@ instance DefineSeverity (TraceForgeEvent blk tx) where -- | instances of @Transformable@ -- transform @ChainSyncClient@ -instance (Condense (HeaderHash blk), ProtocolLedgerView blk, SupportedBlock blk) +instance (Condense (HeaderHash blk), LedgerSupportsProtocol blk) => Transformable Text IO (TraceChainSyncClientEvent blk) where trTransformer _ verb tr = trStructured verb tr @@ -404,14 +406,15 @@ instance Transformable Text IO (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk)) where trTransformer = defaultTextTransformer -instance Transformable Text IO (TraceTxSubmissionOutbound +instance (Show (GenTxId blk), Show (GenTx blk)) + => Transformable Text IO (TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk)) where trTransformer = defaultTextTransformer instance Transformable Text IO (TraceLocalTxSubmissionServerEvent blk) where trTransformer _ verb tr = trStructured verb tr -instance (Condense (HeaderHash blk), Show (TxId tx), HasTxId tx, Show blk, Show tx, ProtocolLedgerView blk) +instance (Condense (HeaderHash blk), Show (TxId tx), HasTxId tx, Show blk, Show tx, LedgerSupportsProtocol blk) => Transformable Text IO (TraceForgeEvent blk tx) where trTransformer = defaultTextTransformer @@ -441,7 +444,7 @@ instance (Show peer) trTransformer = defaultTextTransformer -- transform @TraceEvent@ -instance (Condense (HeaderHash blk), ProtocolLedgerView blk) +instance (Condense (HeaderHash blk), LedgerSupportsProtocol blk) => Transformable Text IO (WithTip blk (ChainDB.TraceEvent blk)) where -- structure required, will call 'toObject' trTransformer StructuredLogging verb tr = trStructured verb tr @@ -458,7 +461,7 @@ instance (Condense (HeaderHash blk), ProtocolLedgerView blk) -- human-readable trace messages. readableChainDBTracer :: forall m blk. - (Monad m, Condense (HeaderHash blk), ProtocolLedgerView blk) + (Monad m, Condense (HeaderHash blk), LedgerSupportsProtocol blk) => Tracer m String -> Tracer m (WithTip blk (ChainDB.TraceEvent blk)) readableChainDBTracer tracer = Tracer $ \case @@ -477,8 +480,10 @@ readableChainDBTracer tracer = Tracer $ \case "Block fits onto the current chain: " <> condense pt ChainDB.TrySwitchToAFork pt _ -> tr $ WithTip tip $ "Block fits onto some fork: " <> condense pt - ChainDB.SwitchedToChain _ c -> tr $ WithTip tip $ - "Chain changed, new tip: " <> condense (AF.headPoint c) + ChainDB.AddedToCurrentChain _ _ c -> tr $ WithTip tip $ + "Chain extended, new tip: " <> condense (AF.headPoint c) + ChainDB.SwitchedToAFork _ _ c -> tr $ WithTip tip $ + "Switched to a fork, new tip: " <> condense (AF.headPoint c) ChainDB.AddBlockValidation ev' -> case ev' of ChainDB.InvalidBlock err pt -> tr $ WithTip tip $ "Invalid block " <> condense pt <> ": " <> show err @@ -590,7 +595,7 @@ instance (Show peer) , "bearer" .= show b , "event" .= show ev ] -instance (Condense (HeaderHash blk), ProtocolLedgerView blk) +instance (Condense (HeaderHash blk), LedgerSupportsProtocol blk) => ToObject (WithTip blk (ChainDB.TraceEvent blk)) where -- example: turn off any tracing of @TraceEvent@s when minimal verbosity level is set -- toObject MinimalVerbosity _ = emptyObject -- no output @@ -609,14 +614,14 @@ instance ToObject SlotNo where mkObject [ "kind" .= String "SlotNo" , "slot" .= toJSON (unSlotNo slot) ] -instance (Condense (HeaderHash blk), ProtocolLedgerView blk) +instance Condense (HeaderHash blk) => ToObject (Point blk) where toObject MinimalVerbosity p = toObject NormalVerbosity p toObject verb p = mkObject [ "kind" .= String "Tip" , "tip" .= showPoint verb p ] -instance (Condense (HeaderHash blk), ProtocolLedgerView blk) +instance (Condense (HeaderHash blk), LedgerSupportsProtocol blk) => ToObject (ChainDB.TraceEvent blk) where toObject verb (ChainDB.TraceAddBlockEvent ev) = case ev of ChainDB.IgnoreBlockOlderThanK pt -> @@ -642,8 +647,11 @@ instance (Condense (HeaderHash blk), ProtocolLedgerView blk) ChainDB.TrySwitchToAFork pt _ -> mkObject [ "kind" .= String "TraceAddBlockEvent.TrySwitchToAFork" , "block" .= toObject verb pt ] - ChainDB.SwitchedToChain _ c -> - mkObject [ "kind" .= String "TraceAddBlockEvent.SwitchedToChain" + ChainDB.AddedToCurrentChain _ _ c -> + mkObject [ "kind" .= String "TraceAddBlockEvent.AddedToCurrentChain" + , "newtip" .= showPoint verb (AF.headPoint c) ] + ChainDB.SwitchedToAFork _ _ c -> + mkObject [ "kind" .= String "TraceAddBlockEvent.SwitchedToAFork" , "newtip" .= showPoint verb (AF.headPoint c) ] ChainDB.AddBlockValidation ev' -> case ev' of ChainDB.InvalidBlock err pt -> @@ -773,7 +781,7 @@ instance ToObject LedgerDB.DiskSnapshot where mkObject [ "kind" .= String "snapshot" , "snapshot" .= String (pack $ show snap) ] -instance (Condense (HeaderHash blk), ProtocolLedgerView blk, SupportedBlock blk) +instance (Condense (HeaderHash blk), LedgerSupportsProtocol blk) => ToObject (TraceChainSyncClientEvent blk) where toObject verb ev = case ev of TraceDownloadedHeader pt -> @@ -910,7 +918,7 @@ instance ToObject (TraceLocalTxSubmissionServerEvent blk) where toObject _verb _ = mkObject [ "kind" .= String "TraceLocalTxSubmissionServerEvent" ] -instance (HasTxId tx, ProtocolLedgerView blk, Condense (HeaderHash blk), Show (TxId tx)) +instance (HasTxId tx, LedgerSupportsProtocol blk, Condense (HeaderHash blk), Show (TxId tx)) => ToObject (TraceForgeEvent blk tx) where toObject MaximalVerbosity (TraceAdoptedBlock slotNo blk txs) = mkObject diff --git a/cardano-node/src/Cardano/Tracing/Tracers.hs b/cardano-node/src/Cardano/Tracing/Tracers.hs index 77874c150b3..f21e7e3a28b 100644 --- a/cardano-node/src/Cardano/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Tracing/Tracers.hs @@ -46,6 +46,7 @@ import Cardano.BM.Data.Transformers import Ouroboros.Consensus.Block (Header) import Ouroboros.Consensus.BlockchainTime (SystemStart (..), TraceBlockchainTimeEvent (..)) import Ouroboros.Consensus.Ledger.Abstract +import Ouroboros.Consensus.Ledger.SupportsProtocol (LedgerSupportsProtocol) import Ouroboros.Consensus.Mempool.API (GenTx, MempoolSize (..), TraceEventMempool (..)) import qualified Ouroboros.Consensus.Node.Tracers as Consensus @@ -63,8 +64,8 @@ import Ouroboros.Network.NodeToNode (WithAddr, ErrorPolicyTrace) import Ouroboros.Network.Point (fromWithOrigin) import Ouroboros.Network.Subscription -import qualified Ouroboros.Storage.ChainDB as ChainDB -import qualified Ouroboros.Storage.LedgerDB.OnDisk as LedgerDB +import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB +import qualified Ouroboros.Consensus.Storage.LedgerDB.OnDisk as LedgerDB import Cardano.Config.Protocol (TraceConstraints) import Cardano.Config.Types @@ -73,13 +74,13 @@ import Cardano.Tracing.ToObjectOrphans import Control.Tracer.Transformers -data Tracers peer blk = Tracers +data Tracers peer localPeer blk = Tracers { -- | Trace the ChainDB chainDBTracer :: Tracer IO (WithTip blk (ChainDB.TraceEvent blk)) -- | Consensus-specific tracers. , consensusTracers :: Consensus.Tracers IO peer blk -- | Tracers for the protocol messages. - , protocolTracers :: ProtocolTracers IO peer blk DeserialiseFailure + , protocolTracers :: ProtocolTracers IO peer localPeer blk DeserialiseFailure -- | Trace the IP subscription manager , ipSubscriptionTracer :: Tracer IO (WithIPList (SubscriptionTrace Socket.SockAddr)) -- | Trace the DNS subscription manager @@ -88,6 +89,8 @@ data Tracers peer blk = Tracers , dnsResolverTracer :: Tracer IO (WithDomainName DnsTrace) -- | Trace error policy resolution , errorPolicyTracer :: Tracer IO (WithAddr Socket.SockAddr ErrorPolicyTrace) + -- | Trace local error policy resolution + , localErrorPolicyTracer :: Tracer IO (WithAddr Socket.SockAddr ErrorPolicyTrace) -- | Trace the Mux , muxTracer :: Tracer IO (WithMuxBearer peer MuxTrace) } @@ -105,7 +108,7 @@ data ForgeTracers = ForgeTracers , ftTraceNodeIsLeader :: Trace IO Text } -nullTracers :: Tracers peer blk +nullTracers :: Tracers peer localPeer blk nullTracers = Tracers { chainDBTracer = nullTracer , consensusTracers = Consensus.nullTracers @@ -114,6 +117,7 @@ nullTracers = Tracers , dnsSubscriptionTracer = nullTracer , dnsResolverTracer = nullTracer , errorPolicyTracer = nullTracer + , localErrorPolicyTracer = nullTracer , muxTracer = nullTracer } @@ -151,15 +155,16 @@ instance ElidingTracer -- | Smart constructor of 'NodeTraces'. -- mkTracers - :: forall peer blk. - ( ProtocolLedgerView blk + :: forall peer localPeer blk. + ( LedgerSupportsProtocol blk , TraceConstraints blk , ShowQuery (Query blk) , Show peer + , Show localPeer ) => TraceOptions -> Trace IO Text - -> IO (Tracers peer blk) + -> IO (Tracers peer localPeer blk) mkTracers traceOptions tracer = do -- We probably don't want to pay the extra IO cost per-counter-increment. -- sk staticMetaCC <- mkLOMeta Critical Confidential @@ -216,6 +221,11 @@ mkTracers traceOptions tracer = do $ annotateSeverity $ toLogObject' StructuredLogging tracingVerbosity $ appendName "ErrorPolicy" tracer + , localErrorPolicyTracer + = tracerOnOff (traceLocalErrorPolicy traceOptions) + $ annotateSeverity + $ toLogObject' StructuredLogging tracingVerbosity + $ appendName "LocalErrorPolicy" tracer , muxTracer = tracerOnOff (traceMux traceOptions) $ annotateSeverity @@ -245,22 +255,34 @@ mkTracers traceOptions tracer = do -> Tracer IO (WithSeverity (WithTip blk (ChainDB.TraceEvent blk))) teeTraceChainTipElide = elideToLogObject + traceChainInformation :: Trace IO Text + -> ChainInformation + -> IO () + traceChainInformation tr ChainInformation { slots, blocks, density } = do + -- TODO this is executed each time the chain changes. How cheap is it? + meta <- mkLOMeta Critical Confidential + let tr' = appendName "metrics" tr + traceD :: Text -> Double -> IO () + traceD msg d = traceNamedObject tr' (meta, LogValue msg (PureD d)) + traceI :: Integral a => Text -> a -> IO () + traceI msg i = traceNamedObject tr' (meta, LogValue msg (PureI (fromIntegral i))) + + traceD "density" (fromRational density) + traceI "slotNum" slots + traceI "blockNum" blocks + traceI "slotInEpoch" (slots `rem` epochSlots) + traceI "epoch" (slots `div` epochSlots) + where + epochSlots :: Word64 = 21600 -- TODO + teeTraceChainTip' :: Trace IO Text -> Tracer IO (WithSeverity (WithTip blk (ChainDB.TraceEvent blk))) teeTraceChainTip' tr = Tracer $ \(WithSeverity _ (WithTip _tip ev')) -> case ev' of (ChainDB.TraceAddBlockEvent ev) -> case ev of - ChainDB.SwitchedToChain _ c -> do - meta <- mkLOMeta Critical Confidential - let tr' = appendName "metrics" tr - ChainInformation { slots, blocks, density } = chainInformation c - epochSlots :: Word64 = 21600 -- TODO - traceNamedObject tr' (meta, LogValue "density" . PureD $ fromRational density) - traceNamedObject tr' (meta, LogValue "slotNum" . PureI $ fromIntegral slots) - traceNamedObject tr' (meta, LogValue "blockNum" . PureI $ fromIntegral blocks) - traceNamedObject tr' (meta, LogValue "slotInEpoch" . PureI $ fromIntegral (slots `rem` epochSlots)) - traceNamedObject tr' (meta, LogValue "epoch" . PureI $ fromIntegral (slots `div` epochSlots)) + ChainDB.SwitchedToAFork _ _ c -> traceChainInformation tr (chainInformation c) + ChainDB.AddedToCurrentChain _ _ c -> traceChainInformation tr (chainInformation c) _ -> pure () _ -> pure () teeTraceBlockFetchDecision :: TracingFormatting @@ -446,7 +468,7 @@ mkTracers traceOptions tracer = do TraceStartTimeInTheFuture (SystemStart start) toWait -> "Waiting " <> show toWait <> " until genesis start time at " <> show start - mkProtocolTracers :: TraceOptions -> ProtocolTracers' peer blk DeserialiseFailure (Tracer IO) + mkProtocolTracers :: TraceOptions -> ProtocolTracers' peer localPeer blk DeserialiseFailure (Tracer IO) mkProtocolTracers traceOpts = ProtocolTracers { ptChainSyncTracer = tracerOnOff (traceChainSyncProtocol traceOpts) diff --git a/cardano-node/src/Cardano/Wallet/Client.hs b/cardano-node/src/Cardano/Wallet/Client.hs index dba0d33ab7f..7838edd26b9 100644 --- a/cardano-node/src/Cardano/Wallet/Client.hs +++ b/cardano-node/src/Cardano/Wallet/Client.hs @@ -26,11 +26,12 @@ import Control.Monad.Class.MonadThrow import Control.Monad.Class.MonadTimer import Control.Tracer +import Ouroboros.Consensus.Config (TopLevelConfig) import Ouroboros.Consensus.Block (BlockProtocol) import Ouroboros.Consensus.Mempool import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.Node.Run -import Ouroboros.Consensus.Protocol +import Ouroboros.Consensus.Cardano import Network.TypedProtocol.Driver import Ouroboros.Network.Codec @@ -45,6 +46,7 @@ import Ouroboros.Network.Protocol.ChainSync.Client import Ouroboros.Network.Protocol.ChainSync.Codec import Ouroboros.Network.Protocol.Handshake.Version import Ouroboros.Network.NodeToClient +import Ouroboros.Network.Snocket (socketSnocket) import Cardano.Common.LocalSocket import Cardano.Config.Types (SocketPath) @@ -54,20 +56,21 @@ runWalletClient :: forall blk. ( RunNode blk , TraceConstraints blk ) - => Protocol blk + => Protocol blk (BlockProtocol blk) -> SocketPath -> Tracer IO String -> IO () -runWalletClient ptcl sockFp tracer = do +runWalletClient ptcl sockFp tracer = withIOManager $ \iocp -> do - addr <- localSocketAddrInfo sockFp + path <- localSocketPath sockFp - let ProtocolInfo{pInfoConfig} = protocolInfo ptcl + let ProtocolInfo { pInfoConfig = cfg } = protocolInfo ptcl chainSyncTracer = contramap show tracer localTxSubmissionTracer = contramap show tracer connectTo + (socketSnocket iocp) NetworkConnectTracers { nctMuxTracer = nullTracer, nctHandshakeTracer = nullTracer @@ -76,9 +79,8 @@ runWalletClient ptcl sockFp tracer = do (Proxy :: Proxy blk) chainSyncTracer localTxSubmissionTracer - pInfoConfig) - Nothing - addr + cfg) + path localInitiatorNetworkApplication :: forall blk m peer. @@ -100,14 +102,14 @@ localInitiatorNetworkApplication -- ^ tracer which logs all local tx submission protocol messages send and -- received by the client (see 'Ouroboros.Network.Protocol.LocalTxSubmission.Type' -- in 'ouroboros-network' package). - -> NodeConfig (BlockProtocol blk) + -> TopLevelConfig blk -> Versions NodeToClientVersion DictVersion (OuroborosApplication 'InitiatorApp peer NodeToClientProtocols m ByteString Void Void) -localInitiatorNetworkApplication Proxy chainSyncTracer localTxSubmissionTracer pInfoConfig = +localInitiatorNetworkApplication Proxy chainSyncTracer localTxSubmissionTracer cfg = simpleSingletonVersions NodeToClientV_1 - (NodeToClientVersionData { networkMagic = nodeNetworkMagic (Proxy @blk) pInfoConfig }) + (NodeToClientVersionData { networkMagic = nodeNetworkMagic (Proxy @blk) cfg }) (DictVersion nodeToClientCodecCBORTerm) $ OuroborosInitiatorApplication $ \_peer ptcl -> case ptcl of @@ -123,7 +125,7 @@ localInitiatorNetworkApplication Proxy chainSyncTracer localTxSubmissionTracer p ChainSyncWithBlocksPtcl -> \channel -> runPeer chainSyncTracer - (localChainSyncCodec @blk pInfoConfig) + (localChainSyncCodec @blk cfg) channel (chainSyncClientPeer chainSyncClient) @@ -197,13 +199,13 @@ localTxSubmissionCodec = localChainSyncCodec :: forall blk m. (RunNode blk, MonadST m) - => NodeConfig (BlockProtocol blk) + => TopLevelConfig blk -> Codec (ChainSync blk (Tip blk)) DeserialiseFailure m ByteString -localChainSyncCodec pInfoConfig = +localChainSyncCodec cfg = codecChainSync - (Block.wrapCBORinCBOR (nodeEncodeBlock pInfoConfig)) - (Block.unwrapCBORinCBOR (nodeDecodeBlock pInfoConfig)) + (Block.wrapCBORinCBOR (nodeEncodeBlock cfg)) + (Block.unwrapCBORinCBOR (nodeDecodeBlock cfg)) (Block.encodePoint (nodeEncodeHeaderHash (Proxy @blk))) (Block.decodePoint (nodeDecodeHeaderHash (Proxy @blk))) (Block.encodeTip (nodeEncodeHeaderHash (Proxy @blk))) diff --git a/configuration/configuration-mainnet.yaml b/configuration/configuration-mainnet.yaml index ab599f6b2db..a7cccd190e9 100644 --- a/configuration/configuration-mainnet.yaml +++ b/configuration/configuration-mainnet.yaml @@ -143,6 +143,9 @@ TraceDNSSubscription: False # Trace error policy resolution. TraceErrorPolicy: False +# Trace local error policy resolution. +TraceLocalErrorPolicy: False + # Trace block forging. TraceForge: True diff --git a/stack.yaml b/stack.yaml index df2f5ca5ae4..b82e54fce24 100644 --- a/stack.yaml +++ b/stack.yaml @@ -121,13 +121,16 @@ extra-deps: #Ouroboros-network dependencies - git: https://github.com/input-output-hk/ouroboros-network - commit: 5f77e24c2263560ad58b9ba092c8cfed174675ae + commit: 36861a97272de1e4de448925dd9bb9c0fddd80f6 subdirs: - io-sim - io-sim-classes - network-mux - ouroboros-network - ouroboros-consensus + - ouroboros-consensus-byron + - ouroboros-consensus/ouroboros-consensus-mock + - ouroboros-consensus-cardano - typed-protocols - typed-protocols-examples - ouroboros-network-framework