Commit 17b9132
committed
Generate security parameter for ChainDB q-s-m test on the fly
After analysing the effect of varying the security parameter (`k`) of
the ChainDB state machine tests (currently hardcoded with 2), we have
observed a tension between:
1) generating enough tests exercising the new Peras behavior where the
chain selection mechanism switches to a shorter but heavier chain
(cert boost is derived from k and must be large enough to overcome
the weight of a longer chain), and
2) generating enough tests exercising the ImmutableDB logic (the chain
must have at least k blocks)
Here are some empirical results:
k -> P(switch to shorter chain), P(generate a chain with >= k blocks)
k=2 -> ~1.3%, ~40%
k=3 -> ~1.9%, ~20%
k=4 -> ~2.4%, ~9%
k=5 -> ~2.5%, ~3%
k=10 -> ~3%, ~0.05%
We believe that the sweet spot between both desiderata appears to be
around `k=2` and `k=4`.
This commit introduces a random generator for `k` using a geometric
distribution to bias the randomly generated `k`s to be relatively small,
while still allowing larger ones to appear from time to time.
Under the current parameters, roughly 75% of the tests use `k<=4`;
```
Security Parameter (k) (10000 in total):
50.82% 2
23.83% 3
12.62% 4
6.69% 5
3.08% 6
1.54% 7
0.74% 8
0.37% 9
0.16% 10
0.06% 11
0.05% 12
0.02% 13
0.01% 14
0.01% 17
```
Yielding the following distributions for 1) and 2), respectively:
```
Tags (5161 in total):
39.35% TagGetIsValidJust
29.22% TagChainSelReprocessKeptSelection
25.91% TagGetIsValidNothing
3.88% TagChainSelReprocessChangedSelection
1.65% TagSwitchedToShorterChain <- HERE
```
```
Chain length >= k (10000 in total):
73.25% False
26.75% True <- HERE
```1 parent 495247e commit 17b9132
File tree
3 files changed
+63
-31
lines changed- ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/ChainDB
- StateMachine/Utils
3 files changed
+63
-31
lines changedLines changed: 51 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
1709 | 1710 | | |
1710 | 1711 | | |
1711 | 1712 | | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
1712 | 1729 | | |
1713 | 1730 | | |
1714 | 1731 | | |
1715 | 1732 | | |
1716 | | - | |
1717 | | - | |
1718 | | - | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
1719 | 1736 | | |
1720 | 1737 | | |
1721 | 1738 | | |
1722 | 1739 | | |
1723 | 1740 | | |
1724 | 1741 | | |
| 1742 | + | |
1725 | 1743 | | |
1726 | 1744 | | |
1727 | | - | |
| 1745 | + | |
1728 | 1746 | | |
1729 | 1747 | | |
1730 | 1748 | | |
1731 | 1749 | | |
1732 | | - | |
| 1750 | + | |
1733 | 1751 | | |
1734 | 1752 | | |
1735 | 1753 | | |
1736 | 1754 | | |
1737 | | - | |
1738 | | - | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
1739 | 1758 | | |
1740 | 1759 | | |
1741 | 1760 | | |
| 1761 | + | |
1742 | 1762 | | |
1743 | 1763 | | |
1744 | 1764 | | |
1745 | | - | |
| 1765 | + | |
1746 | 1766 | | |
1747 | 1767 | | |
1748 | 1768 | | |
1749 | 1769 | | |
1750 | 1770 | | |
1751 | 1771 | | |
1752 | 1772 | | |
1753 | | - | |
| 1773 | + | |
1754 | 1774 | | |
1755 | 1775 | | |
1756 | | - | |
| 1776 | + | |
1757 | 1777 | | |
1758 | 1778 | | |
1759 | 1779 | | |
1760 | 1780 | | |
1761 | | - | |
| 1781 | + | |
1762 | 1782 | | |
1763 | 1783 | | |
1764 | 1784 | | |
| |||
1821 | 1841 | | |
1822 | 1842 | | |
1823 | 1843 | | |
| 1844 | + | |
1824 | 1845 | | |
1825 | 1846 | | |
1826 | 1847 | | |
1827 | 1848 | | |
1828 | 1849 | | |
1829 | | - | |
1830 | | - | |
1831 | | - | |
1832 | | - | |
1833 | | - | |
1834 | | - | |
1835 | | - | |
1836 | | - | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
1840 | | - | |
1841 | | - | |
1842 | | - | |
1843 | | - | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
1844 | 1868 | | |
1845 | 1869 | | |
1846 | 1870 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| 146 | + | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
148 | | - | |
149 | | - | |
| 150 | + | |
| 151 | + | |
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
243 | 247 | | |
244 | 248 | | |
245 | 249 | | |
| 250 | + | |
246 | 251 | | |
247 | | - | |
| 252 | + | |
248 | 253 | | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
254 | 259 | | |
255 | | - | |
| 260 | + | |
| 261 | + | |
256 | 262 | | |
257 | 263 | | |
258 | 264 | | |
| |||
0 commit comments