Skip to content

Commit ed92af2

Browse files
authored
db-analyser: document pitfall of --repro-mempool-and-forge 2 (#1169)
This PR documents a deficiency of `--repro-mempool-and-forge 2`. This mode is used to simulate larger mempools compared to `--repro-mempool-and-forge 1` by inserting the contents of more than one block into the mempool. However, Cardano transactions have a validity interval, so but the transactions in the mempool are always validated against the same slot at any given point, which can lead to failures. A concrete example occurs with the Cardano mainnet chain with `--analyse-from 100007913 --repro-mempool-and-forge 2 --num-blocks-to-process 3`, where the transaction with id `3cba8560cd6b2fee11d7813526cd2863e33db991796a2db5a052040cf572cf78` of block `9137142` will fail due to ```haskell OutsideValidityIntervalUTxO ( ValidityInterval { invalidBefore = SJust ( SlotNo 100008025 ) , invalidHereafter = SJust ( SlotNo 100009025 ) } ) ( SlotNo 100008021 ) ``` as block `9137140` is in slot `100008020`, and we increase the slot by one for validation: https://github.com/IntersectMBO/ouroboros-consensus/blob/126de8eb9669afb3220f57feb74da930f3b5dfa2/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Impl/Common.hs#L249 Follow-up work could include allowing to skip such transactions. Also, we now print the tx id of rejected transactions prominently as the first entry.
2 parents e70c228 + c9be7cf commit ed92af2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ouroboros-consensus-cardano/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ Lastly the user can provide the analysis that should be run on the chain:
166166
- time spent in the mutator in microseconds
167167
- time spent in GC in microseconds
168168

169+
Currently, only NUM=1 or NUM=2 are supported. Note that with NUM=2, even for a
170+
fully valid chain (like mainnet), you might get an error like this:
171+
172+
```
173+
Mempool rejected some of the on-chain txs: ... (OutsideValidityIntervalUTxO ...) ...
174+
```
175+
176+
Therefore, it is recommended to start with NUM=1, and only use NUM=2 when you
177+
want to test the performance impact of a more filled mempool.
178+
169179
* `--get-block-application-metrics NUM` computes different block application metrics every `NUM` blocks.
170180
It currently outputs block number, slot number, UTxO size in MB, and UTxO map size.
171181
In the [`scripts`](./scripts) directory we provide a `plot_utxo-growth.py` script that can be used to plot the these results.

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Analysis.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,19 @@ reproMempoolForge numBlks env = do
811811
-- add this block's transactions to the mempool
812812
do
813813
results <- Mempool.addTxs mempool $ LedgerSupportsMempool.extractTxs blk'
814-
let rejs = [ rej | rej@Mempool.MempoolTxRejected{} <- results ]
814+
let rejs =
815+
[ (LedgerSupportsMempool.txId tx, rej)
816+
| rej@(Mempool.MempoolTxRejected tx _) <- results
817+
]
815818
unless (null rejs) $ do
816-
fail $ "Mempool rejected some of the on-chain txs: " <> show rejs
819+
fail $ unlines $
820+
["Mempool rejected some of the on-chain txs: " <> show rejs]
821+
<> case howManyBlocks of
822+
ReproMempoolForgeOneBlk -> []
823+
ReproMempoolForgeTwoBlks ->
824+
[ "This might be expected, see the db-analyser README."
825+
, "Consider trying again with `--repro-mempool-and-forge 1`."
826+
]
817827

818828
let scrutinee = case howManyBlocks of
819829
ReproMempoolForgeOneBlk -> Just blk'

0 commit comments

Comments
 (0)