Skip to content

Commit

Permalink
Add tTxSubmissionTracer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaro committed May 13, 2021
1 parent 15a0da0 commit 26b45b2
Show file tree
Hide file tree
Showing 4 changed files with 578 additions and 187 deletions.
99 changes: 96 additions & 3 deletions cardano-node/src/Cardano/TraceDispatcher/Network/Combinators.hs
Expand Up @@ -21,6 +21,12 @@ module Cardano.TraceDispatcher.Network.Combinators
, severityTBlockFetch
, namesForTBlockFetch

, severityTBlockFetchSerialised
, namesForTBlockFetchSerialised

, severityTxSubmissionTracerNode
, namesForTxSubmissionTracerNode

) where


Expand All @@ -38,9 +44,11 @@ import Ouroboros.Network.Protocol.ChainSync.Type (ChainSync (..),
Message (..))
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LSQ
import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Type as LTS
import qualified Ouroboros.Network.Protocol.TxSubmission.Type as TXS

import Ouroboros.Consensus.Block (Header)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx,
GenTxId)
import Ouroboros.Consensus.Storage.Serialisation (SerialisedHeader)


Expand Down Expand Up @@ -261,7 +269,7 @@ severityTBlockFetch (BlockFetch.TraceLabelPeer _ v) = severityTBlockFetch' v

severityTBlockFetch'' (AnyMessageAndAgency _agency msg) = severityTBlockFetch''' msg

severityTBlockFetch''' :: Message (BlockFetch blk (Point blk)) from to
severityTBlockFetch''' :: Message (BlockFetch x (Point blk)) from to
-> SeverityS
severityTBlockFetch''' MsgRequestRange {} = Info
severityTBlockFetch''' MsgStartBatch {} = Info
Expand All @@ -273,18 +281,103 @@ severityTBlockFetch (BlockFetch.TraceLabelPeer _ v) = severityTBlockFetch' v
namesForTBlockFetch :: BlockFetch.TraceLabelPeer peer
(TraceSendRecv (BlockFetch blk (Point blk))) -> [Text]
namesForTBlockFetch (BlockFetch.TraceLabelPeer _ v) =
"NodeToNode" : namesTBlockFetch v
where
namesTBlockFetch (TraceSendMsg msg) = "Send" : namesTBlockFetch' msg
namesTBlockFetch (TraceRecvMsg msg) = "Recieve" : namesTBlockFetch' msg

namesTBlockFetch' (AnyMessageAndAgency _agency msg) = namesTBlockFetch'' msg

namesTBlockFetch'' :: Message (BlockFetch x (Point blk)) from to
-> [Text]
namesTBlockFetch'' MsgRequestRange {} = ["RequestRange"]
namesTBlockFetch'' MsgStartBatch {} = ["StartBatch"]
namesTBlockFetch'' MsgNoBlocks {} = ["NoBlocks"]
namesTBlockFetch'' MsgBlock {} = ["Block"]
namesTBlockFetch'' MsgBatchDone {} = ["BatchDone"]
namesTBlockFetch'' MsgClientDone {} = ["ClientDone"]

severityTBlockFetchSerialised :: BlockFetch.TraceLabelPeer peer
(TraceSendRecv (BlockFetch (Serialised blk) (Point blk))) -> SeverityS
severityTBlockFetchSerialised (BlockFetch.TraceLabelPeer _ v) = severityTBlockFetch' v
where
severityTBlockFetch' (TraceSendMsg msg) = severityTBlockFetch'' msg
severityTBlockFetch' (TraceRecvMsg msg) = severityTBlockFetch'' msg

severityTBlockFetch'' (AnyMessageAndAgency _agency msg) = severityTBlockFetch''' msg

severityTBlockFetch''' :: Message (BlockFetch x (Point blk)) from to
-> SeverityS
severityTBlockFetch''' MsgRequestRange {} = Info
severityTBlockFetch''' MsgStartBatch {} = Info
severityTBlockFetch''' MsgNoBlocks {} = Info
severityTBlockFetch''' MsgBlock {} = Info
severityTBlockFetch''' MsgBatchDone {} = Info
severityTBlockFetch''' MsgClientDone {} = Info

namesForTBlockFetchSerialised :: BlockFetch.TraceLabelPeer peer
(TraceSendRecv (BlockFetch (Serialised blk) (Point blk))) -> [Text]
namesForTBlockFetchSerialised (BlockFetch.TraceLabelPeer _ v) =
"NodeToNode" : "Serialised" : namesTBlockFetch v
where
namesTBlockFetch (TraceSendMsg msg) = "Send" : namesTBlockFetch' msg
namesTBlockFetch (TraceRecvMsg msg) = "Recieve" : namesTBlockFetch' msg

namesTBlockFetch' (AnyMessageAndAgency _agency msg) = namesTBlockFetch'' msg

namesTBlockFetch'' :: Message (BlockFetch blk (Point blk)) from to
namesTBlockFetch'' :: Message (BlockFetch x (Point blk)) from to
-> [Text]
namesTBlockFetch'' MsgRequestRange {} = ["RequestRange"]
namesTBlockFetch'' MsgStartBatch {} = ["StartBatch"]
namesTBlockFetch'' MsgNoBlocks {} = ["NoBlocks"]
namesTBlockFetch'' MsgBlock {} = ["Block"]
namesTBlockFetch'' MsgBatchDone {} = ["BatchDone"]
namesTBlockFetch'' MsgClientDone {} = ["ClientDone"]

severityTxSubmissionTracerNode :: BlockFetch.TraceLabelPeer peer
(TraceSendRecv (TXS.TxSubmission (GenTxId blk) (GenTx blk))) -> SeverityS
severityTxSubmissionTracerNode (BlockFetch.TraceLabelPeer _ v) = severityTxSubNode' v
where
severityTxSubNode' (TraceSendMsg msg) = severityTxSubNode'' msg
severityTxSubNode' (TraceRecvMsg msg) = severityTxSubNode'' msg

severityTxSubNode'' (AnyMessageAndAgency _agency msg) = severityTxSubNode''' msg

severityTxSubNode''' ::
Message
(TXS.TxSubmission (GenTxId blk) (GenTx blk))
from
to
-> SeverityS
severityTxSubNode''' TXS.MsgRequestTxIds {} = Info
severityTxSubNode''' TXS.MsgReplyTxIds {} = Info
severityTxSubNode''' TXS.MsgRequestTxs {} = Info
severityTxSubNode''' TXS.MsgReplyTxs {} = Info
severityTxSubNode''' TXS.MsgDone {} = Info
severityTxSubNode''' _ = Info
-- TODO: Can't use 'MsgKThxBye' because NodeToNodeV_2 is not introduced yet.


namesForTxSubmissionTracerNode :: BlockFetch.TraceLabelPeer peer
(TraceSendRecv (TXS.TxSubmission (GenTxId blk) (GenTx blk))) -> [Text]
namesForTxSubmissionTracerNode (BlockFetch.TraceLabelPeer _ v) =
"NodeToNode" : "Serialised" : namesTxSubNode v
where
namesTxSubNode (TraceSendMsg msg) = "Send" : namesTxSubNode' msg
namesTxSubNode (TraceRecvMsg msg) = "Recieve" : namesTxSubNode' msg

namesTxSubNode' (AnyMessageAndAgency _agency msg) = namesTxSubNode'' msg

namesTxSubNode'' ::
Message
(TXS.TxSubmission (GenTxId blk) (GenTx blk))
from
to
-> [Text]
namesTxSubNode'' TXS.MsgRequestTxIds {} = ["RequestTxIds"]
namesTxSubNode'' TXS.MsgReplyTxIds {} = ["ReplyTxIds"]
namesTxSubNode'' TXS.MsgRequestTxs {} = ["RequestTxs"]
namesTxSubNode'' TXS.MsgReplyTxs {} = ["ReplyTxs"]
namesTxSubNode'' TXS.MsgDone {} = ["Done"]
namesTxSubNode'' _ = ["KThxBye"]
-- TODO: Can't use 'MsgKThxBye' because NodeToNodeV_2 is not introduced yet.
179 changes: 175 additions & 4 deletions cardano-node/src/Cardano/TraceDispatcher/Network/Docu.hs
Expand Up @@ -10,12 +10,14 @@ module Cardano.TraceDispatcher.Network.Docu
, docTTxSubmission
, docTStateQuery
, docTBlockFetch
, docTTxSubmissionNode
) where

import Cardano.Logging
import Cardano.Prelude

import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx,
GenTxId)

import Ouroboros.Network.Block (Point, Tip)
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
Expand All @@ -26,6 +28,7 @@ import Ouroboros.Network.Protocol.ChainSync.Type (ChainSync (..),
Message (..))
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LSQ
import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Type as LTS
import qualified Ouroboros.Network.Protocol.TxSubmission.Type as TXS


protoHeader :: header
Expand All @@ -49,6 +52,20 @@ protoTx = undefined
protoAcquireFailure :: LSQ.AcquireFailure
protoAcquireFailure = undefined

protoChainRange :: ChainRange point
protoChainRange = undefined

protoTokBlockingStyle :: TXS.TokBlockingStyle blocking
protoTokBlockingStyle = undefined

protoBlockingReplyList :: TXS.BlockingReplyList blocking (txid, TXS.TxSizeInBytes)
protoBlockingReplyList = undefined

protoTxId :: txid
protoTxId = undefined

------------------------------------

docTChainSync :: Documented (BlockFetch.TraceLabelPeer peer (TraceSendRecv
(ChainSync x (Point blk) (Tip blk))))
docTChainSync = Documented [
Expand Down Expand Up @@ -238,7 +255,161 @@ docTStateQuery = Documented [
docTBlockFetch :: Documented
(BlockFetch.TraceLabelPeer peer
(TraceSendRecv
(BlockFetch blk (Point blk))))
(BlockFetch x (Point blk))))
docTBlockFetch = Documented [
]
--DocMsg
DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(MsgRequestRange protoChainRange))))
[]
"Request range of blocks."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
MsgStartBatch)))
[]
"Start block streaming."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
MsgNoBlocks)))
[]
"Respond that there are no blocks."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(MsgBlock undefined))))
[]
"Stream a single block."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
MsgBatchDone)))
[]
"End of block streaming."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
MsgClientDone)))
[]
"Client termination message."
]

docTTxSubmissionNode :: Documented
(BlockFetch.TraceLabelPeer peer
(TraceSendRecv
(TXS.TxSubmission (GenTxId blk) (GenTx blk))))
docTTxSubmissionNode = Documented [
DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(TXS.MsgRequestTxIds protoTokBlockingStyle 1 1))))
[]
"Request a non-empty list of transaction identifiers from the client,\
\and confirm a number of outstanding transaction identifiers.\
\\
\With 'TokBlocking' this is a a blocking operation: the response will\
\always have at least one transaction identifier, and it does not expect\
\a prompt response: there is no timeout. This covers the case when there\
\is nothing else to do but wait. For example this covers leaf nodes that\
\rarely, if ever, create and submit a transaction.\
\\
\With 'TokNonBlocking' this is a non-blocking operation: the response\
\may be an empty list and this does expect a prompt response. This\
\covers high throughput use cases where we wish to pipeline, by\
\interleaving requests for additional transaction identifiers with\
\requests for transactions, which requires these requests not block.\
\\
\The request gives the maximum number of transaction identifiers that\
\can be accepted in the response. This must be greater than zero in the\
\'TokBlocking' case. In the 'TokNonBlocking' case either the numbers\
\acknowledged or the number requested must be non-zero. In either case,\
\the number requested must not put the total outstanding over the fixed\
\protocol limit.\
\\
\The request also gives the number of outstanding transaction\
\identifiers that can now be acknowledged. The actual transactions\
\to acknowledge are known to the peer based on the FIFO order in which\
\they were provided.\
\\
\There is no choice about when to use the blocking case versus the\
\non-blocking case, it depends on whether there are any remaining\
\unacknowledged transactions (after taking into account the ones\
\acknowledged in this message):\
\\
\* The blocking case must be used when there are zero remaining\
\ unacknowledged transactions.\
\\
\* The non-blocking case must be used when there are non-zero remaining\
\ unacknowledged transactions."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(TXS.MsgReplyTxIds protoBlockingReplyList))))
[]
"Reply with a list of transaction identifiers for available\
\transactions, along with the size of each transaction.\
\\
\The list must not be longer than the maximum number requested.\
\\
\In the 'StTxIds' 'StBlocking' state the list must be non-empty while\
\in the 'StTxIds' 'StNonBlocking' state the list may be empty.\
\\
\These transactions are added to the notional FIFO of outstanding\
\transaction identifiers for the protocol.\
\\
\The order in which these transaction identifiers are returned must be\
\the order in which they are submitted to the mempool, to preserve\
\dependent transactions."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(TXS.MsgRequestTxs [protoTxId]))))
[]
"Request one or more transactions corresponding to the given\
\transaction identifiers.\
\\
\While it is the responsibility of the replying peer to keep within\
\pipelining in-flight limits, the sender must also cooperate by keeping\
\the total requested across all in-flight requests within the limits.\
\\
\It is an error to ask for transaction identifiers that were not\
\previously announced (via 'MsgReplyTxIds').\
\\
\It is an error to ask for transaction identifiers that are not\
\outstanding or that were already asked for."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
(TXS.MsgReplyTxs [protoTx]))))
[]
"Reply with the requested transactions, or implicitly discard.\
\\
\Transactions can become invalid between the time the transaction\
\identifier was sent and the transaction being requested. Invalid\
\(including committed) transactions do not need to be sent.\
\\
\Any transaction identifiers requested but not provided in this reply\
\should be considered as if this peer had never announced them. (Note\
\that this is no guarantee that the transaction is invalid, it may still\
\be valid and available from another peer)."
, DocMsg
(BlockFetch.TraceLabelPeer protoPeer
(TraceSendMsg
(AnyMessageAndAgency protoStok
TXS.MsgDone)))
[]
"Termination message, initiated by the client when the server is\
\making a blocking call for more transaction identifiers."
--TODO: Can't use 'MsgKThxBye' because NodeToNodeV_2 is not introduced yet.
]

0 comments on commit 26b45b2

Please sign in to comment.