Commit d707a2a
authored
Mempool test: generate txs larger than the entire mempool (#1230)
Closes #1226
In addition to the previously valid/invalid txs (purely based on the
UTxO ledger rules), we add an optional per-tx limit to the mock block.
As a second step, we generate very large txs that are larger than an
entire mempool, in order to test that we do *not* block when adding them
(just like the other txs), which is important as explained in #1226.
---
One way to validate this PR is to introduce a bug that would cause us to
block on such transactions, and observe that the test now indeed catches
that.
For example, retrying when the per-tx limited is not satisfied (this is
basically what happened in #1168 and was fixed by #1225) via
```diff
diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs
index 372ea15..31abe25fbf 100644
--- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs
+++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs
@@ -170,25 +170,8 @@ pureTryAddTx ::
-> TryAddTx blk
pureTryAddTx cfg wti tx is =
case runExcept $ txMeasure cfg (isLedgerState is) tx of
- Left err ->
- -- The transaction does not have a valid measure (eg its ExUnits is
- -- greater than what this ledger state allows for a single transaction).
- --
- -- It might seem simpler to remove the failure case from 'txMeasure' and
- -- simply fully validate the tx before determining whether it'd fit in
- -- the mempool; that way we could reject invalid txs ASAP. However, for a
- -- valid tx, we'd pay that validation cost every time the node's
- -- selection changed, even if the tx wouldn't fit. So it'd very much be
- -- as if the mempool were effectively over capacity! What's worse, each
- -- attempt would not be using 'extendVRPrevApplied'.
- TryAddTx
- Nothing
- (MempoolTxRejected tx err)
- (TraceMempoolRejectedTx
- tx
- err
- (isMempoolSize is)
- )
+ Left _err ->
+ NotEnoughSpaceLeft
Right txsz
-- Check for overflow
--
```
or here
```diff
diff --git a/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Ledger/Block.hs b/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Ledger/Block.hs
index 743e11b..e01d8cfe5a 100644
--- a/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Ledger/Block.hs
+++ b/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Ledger/Block.hs
@@ -452,10 +452,7 @@ instance TxLimits (SimpleBlock c ext) where
-- But not 'maxbound'!, since the mempool sometimes holds multiple blocks worth.
blockCapacityTxMeasure _cfg _st = IgnoringOverflow simpleBlockCapacity
- txMeasure cfg _st =
- fmap IgnoringOverflow
- . checkTxSize (simpleLedgerMockConfig cfg)
- . simpleGenTx
+ txMeasure _cfg _st = pure . IgnoringOverflow . txSize . simpleGenTx
simpleBlockCapacity :: ByteSize32
simpleBlockCapacity = ByteSize32 512
```
will cause many test failures with `FailureDeadlock [Labelled (ThreadId
[]) (Just "main")]'` via `io-sim`'s nice deadlock detection.
---
Stacked on top of #1175 to avoid boring rebase workFile tree
10 files changed
+222
-80
lines changed- ouroboros-consensus
- changelog.d
- src
- ouroboros-consensus/Ouroboros/Consensus/Ledger
- unstable-mock-block/Ouroboros/Consensus/Mock
- Ledger
- Node
- test/consensus-test/Test/Consensus
10 files changed
+222
-80
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| 547 | + | |
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| |||
Lines changed: 28 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | | - | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
| 332 | + | |
331 | 333 | | |
332 | 334 | | |
333 | 335 | | |
| |||
353 | 355 | | |
354 | 356 | | |
355 | 357 | | |
356 | | - | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
380 | | - | |
| 382 | + | |
| 383 | + | |
381 | 384 | | |
382 | 385 | | |
383 | 386 | | |
384 | | - | |
385 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
386 | 391 | | |
387 | 392 | | |
388 | | - | |
| 393 | + | |
| 394 | + | |
389 | 395 | | |
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
393 | | - | |
394 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
395 | 403 | | |
396 | 404 | | |
397 | 405 | | |
| |||
427 | 435 | | |
428 | 436 | | |
429 | 437 | | |
430 | | - | |
431 | | - | |
| 438 | + | |
| 439 | + | |
432 | 440 | | |
433 | | - | |
434 | | - | |
| 441 | + | |
| 442 | + | |
435 | 443 | | |
436 | 444 | | |
437 | 445 | | |
| |||
443 | 451 | | |
444 | 452 | | |
445 | 453 | | |
446 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
447 | 459 | | |
448 | 460 | | |
449 | 461 | | |
| |||
490 | 502 | | |
491 | 503 | | |
492 | 504 | | |
493 | | - | |
494 | | - | |
| 505 | + | |
| 506 | + | |
495 | 507 | | |
496 | 508 | | |
497 | 509 | | |
| |||
Lines changed: 56 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | | - | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
21 | | - | |
| 28 | + | |
22 | 29 | | |
23 | 30 | | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
33 | 59 | | |
34 | 60 | | |
35 | 61 | | |
| |||
50 | 76 | | |
51 | 77 | | |
52 | 78 | | |
| 79 | + | |
53 | 80 | | |
54 | 81 | | |
55 | 82 | | |
| |||
59 | 86 | | |
60 | 87 | | |
61 | 88 | | |
62 | | - | |
| 89 | + | |
| 90 | + | |
63 | 91 | | |
64 | 92 | | |
65 | | - | |
| 93 | + | |
66 | 94 | | |
67 | 95 | | |
68 | | - | |
| 96 | + | |
69 | 97 | | |
70 | 98 | | |
71 | 99 | | |
| |||
78 | 106 | | |
79 | 107 | | |
80 | 108 | | |
81 | | - | |
| 109 | + | |
| 110 | + | |
82 | 111 | | |
83 | 112 | | |
84 | 113 | | |
85 | | - | |
| 114 | + | |
86 | 115 | | |
87 | 116 | | |
88 | | - | |
| 117 | + | |
| 118 | + | |
89 | 119 | | |
90 | 120 | | |
91 | 121 | | |
92 | | - | |
| 122 | + | |
93 | 123 | | |
94 | 124 | | |
| 125 | + | |
95 | 126 | | |
96 | 127 | | |
97 | 128 | | |
| |||
104 | 135 | | |
105 | 136 | | |
106 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
107 | 154 | | |
108 | 155 | | |
109 | 156 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
0 commit comments