@@ -20,8 +20,6 @@ module Cardano.Node.Tracing.Tracers.Consensus
2020 , servedBlockLatest
2121 , ClientMetrics
2222 , txsMempoolTimeoutSoftCounterName
23- , MempoolTimeoutSoftPredicate (.. )
24- , EraMempoolTimeoutSoftPredicate (.. )
2523 , impliesMempoolTimeoutSoft
2624 ) where
2725
@@ -48,7 +46,8 @@ import Ouroboros.Consensus.Ledger.Inspect (LedgerEvent (..), LedgerUpd
4846import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr , ByteSize32 (.. ), GenTxId ,
4947 HasTxId , LedgerSupportsMempool , txForgetValidated , txId )
5048import Ouroboros.Consensus.Ledger.SupportsProtocol
51- import Ouroboros.Consensus.Mempool (MempoolSize (.. ), TraceEventMempool (.. ))
49+ import Ouroboros.Consensus.Mempool (MempoolRejectionDetails (.. ), MempoolSize (.. ),
50+ TraceEventMempool (.. ), jsonMempoolRejectionDetails )
5251import Ouroboros.Consensus.MiniProtocol.BlockFetch.Server
5352 (TraceBlockFetchServerEvent (.. ))
5453import Ouroboros.Consensus.MiniProtocol.ChainSync.Client
@@ -83,23 +82,11 @@ import Data.Int (Int64)
8382import Data.IntPSQ (IntPSQ )
8483import qualified Data.IntPSQ as Pq
8584import qualified Data.List as List
86- import qualified Data.List.NonEmpty as NE
8785import qualified Data.Text as Text
8886import Data.Time (NominalDiffTime )
8987import Data.Word (Word32 , Word64 )
9088import Network.TypedProtocol.Core
9189
92-
93- -- all for MempoolTimeoutSoftPredicate
94- import qualified Cardano.Ledger.Conway.Rules as Conway
95- import qualified Cardano.Ledger.Core as SL (EraRule )
96- import qualified Cardano.Ledger.Shelley.API as SL (ApplyTxError (.. ))
97- import qualified Data.SOP as SOP
98- import Ouroboros.Consensus.Byron.Ledger.Block as Consensus
99- import Ouroboros.Consensus.HardFork.Combinator as Consensus
100- import Ouroboros.Consensus.Shelley.Ledger.Block as Consensus
101- import Ouroboros.Consensus.TypeFamilyWrappers as Consensus
102-
10390instance (LogFormatting adr , Show adr ) => LogFormatting (ConnectionId adr ) where
10491 forMachine _dtal (ConnectionId local' remote) =
10592 mconcat [ " connectionId" .= String (showT local'
@@ -1260,71 +1247,36 @@ instance MetaTrace (TraceLocalTxSubmissionServerEvent blk) where
12601247txsMempoolTimeoutSoftCounterName :: Text. Text
12611248txsMempoolTimeoutSoftCounterName = " txsMempoolTimeoutSoft"
12621249
1263- impliesMempoolTimeoutSoft ::
1264- forall blk . MempoolTimeoutSoftPredicate blk => TraceEventMempool blk -> Bool
1250+ impliesMempoolTimeoutSoft :: TraceEventMempool blk -> Bool
12651251impliesMempoolTimeoutSoft = \ case
1266- TraceMempoolRejectedTx _tx txApplyErr _mpSz ->
1267- errImpliesMempoolTimeoutSoft (Proxy @ blk ) txApplyErr
1252+ TraceMempoolRejectedTx _tx _txApplyErr details _mpSz ->
1253+ case details of
1254+ MempoolRejectedByTimeoutSoft {} -> True
1255+ MempoolRejectedByLedger -> False
12681256 _ -> False
12691257
1270- class MempoolTimeoutSoftPredicate blk where
1271- -- | Does the error indicate a mempool timeout
1272- errImpliesMempoolTimeoutSoft :: proxy blk -> ApplyTxErr blk -> Bool
1273-
1274- instance SOP. All MempoolTimeoutSoftPredicate xs => MempoolTimeoutSoftPredicate (Consensus. HardForkBlock xs ) where
1275- errImpliesMempoolTimeoutSoft _prx = \ case
1276- Consensus. HardForkApplyTxErrWrongEra {} -> False
1277- Consensus. HardForkApplyTxErrFromEra (Consensus. OneEraApplyTxErr ns) ->
1278- SOP. hcollapse $ SOP. hcmap (Proxy @ MempoolTimeoutSoftPredicate ) f ns
1279- where
1280- f :: forall x . MempoolTimeoutSoftPredicate x => Consensus. WrapApplyTxErr x -> SOP. K Bool x
1281- f (Consensus. WrapApplyTxErr err) = SOP. K $ errImpliesMempoolTimeoutSoft (Proxy @ x ) err
1282-
1283- instance MempoolTimeoutSoftPredicate Consensus. ByronBlock where
1284- errImpliesMempoolTimeoutSoft = \ _prx _err -> False
1285-
1286- instance EraMempoolTimeoutSoftPredicate era => MempoolTimeoutSoftPredicate (Consensus. ShelleyBlock proto era ) where
1287- errImpliesMempoolTimeoutSoft _prx = \ case
1288- SL. ApplyTxError (err NE. :| errs) ->
1289- null errs && eraImpliesMempoolTimeoutSoft (Proxy @ era ) err
1290-
1291- class EraMempoolTimeoutSoftPredicate era where
1292- -- | Does the error indicate a mempool timeout
1293- eraImpliesMempoolTimeoutSoft :: proxy era -> Conway. PredicateFailure (SL. EraRule " LEDGER" era ) -> Bool
1294-
1295- instance EraMempoolTimeoutSoftPredicate ShelleyEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1296- instance EraMempoolTimeoutSoftPredicate AllegraEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1297- instance EraMempoolTimeoutSoftPredicate MaryEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1298- instance EraMempoolTimeoutSoftPredicate AlonzoEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1299- instance EraMempoolTimeoutSoftPredicate BabbageEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1300- instance EraMempoolTimeoutSoftPredicate ConwayEra where
1301- eraImpliesMempoolTimeoutSoft _prx = \ case
1302- Conway. ConwayMempoolFailure txt -> Text. pack " MempoolTxTooSlow" `Text.isPrefixOf` txt
1303- _ -> False
1304- instance EraMempoolTimeoutSoftPredicate DijkstraEra where eraImpliesMempoolTimeoutSoft _prx _err = False
1305-
13061258instance
13071259 ( LogFormatting (ApplyTxErr blk )
13081260 , LogFormatting (GenTx blk )
13091261 , ToJSON (GenTxId blk )
13101262 , LedgerSupportsMempool blk
13111263 , ConvertRawHash blk
1312- , MempoolTimeoutSoftPredicate blk
13131264 ) => LogFormatting (TraceEventMempool blk ) where
13141265 forMachine dtal (TraceMempoolAddedTx tx _mpSzBefore mpSzAfter) =
13151266 mconcat
13161267 [ " kind" .= String " TraceMempoolAddedTx"
13171268 , " tx" .= forMachine dtal (txForgetValidated tx)
13181269 , " mempoolSize" .= forMachine dtal mpSzAfter
13191270 ]
1320- forMachine dtal (TraceMempoolRejectedTx tx txApplyErr _ mpSz) =
1271+ forMachine dtal (TraceMempoolRejectedTx tx txApplyErr details mpSz) =
13211272 mconcat $
13221273 [ " kind" .= String " TraceMempoolRejectedTx"
13231274 , " tx" .= forMachine dtal tx
13241275 , " mempoolSize" .= forMachine dtal mpSz
13251276 ] <>
1277+ if dtal < DDetailed then [] else
13261278 [ " err" .= forMachine dtal txApplyErr
1327- | dtal >= DDetailed
1279+ , " errdetails " .= jsonMempoolRejectionDetails details
13281280 ]
13291281 forMachine dtal (TraceMempoolRemoveTxs txs mpSz) =
13301282 mconcat
@@ -1374,7 +1326,7 @@ instance
13741326 [ IntM " txsInMempool" (fromIntegral $ msNumTxs mpSz)
13751327 , IntM " mempoolBytes" (fromIntegral . unByteSize32 . msNumBytes $ mpSz)
13761328 ]
1377- asMetrics ev@ (TraceMempoolRejectedTx _tx _txApplyErr mpSz) =
1329+ asMetrics ev@ (TraceMempoolRejectedTx _tx _txApplyErr _details mpSz) =
13781330 [ IntM " txsInMempool" (fromIntegral $ msNumTxs mpSz)
13791331 , IntM " mempoolBytes" (fromIntegral . unByteSize32 . msNumBytes $ mpSz)
13801332 ]
0 commit comments