Commit 6973759
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 87.5% 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 41af8e4 commit 6973759
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 | | |
| |||
1720 | 1721 | | |
1721 | 1722 | | |
1722 | 1723 | | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1723 | 1740 | | |
1724 | 1741 | | |
1725 | 1742 | | |
1726 | 1743 | | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
1730 | 1747 | | |
1731 | 1748 | | |
1732 | 1749 | | |
1733 | 1750 | | |
1734 | 1751 | | |
1735 | 1752 | | |
| 1753 | + | |
1736 | 1754 | | |
1737 | 1755 | | |
1738 | | - | |
| 1756 | + | |
1739 | 1757 | | |
1740 | 1758 | | |
1741 | 1759 | | |
1742 | 1760 | | |
1743 | | - | |
| 1761 | + | |
1744 | 1762 | | |
1745 | 1763 | | |
1746 | 1764 | | |
1747 | 1765 | | |
1748 | | - | |
1749 | | - | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
1750 | 1769 | | |
1751 | 1770 | | |
1752 | 1771 | | |
| 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 | + | |
1765 | 1785 | | |
1766 | 1786 | | |
1767 | | - | |
| 1787 | + | |
1768 | 1788 | | |
1769 | 1789 | | |
1770 | 1790 | | |
1771 | 1791 | | |
1772 | | - | |
| 1792 | + | |
1773 | 1793 | | |
1774 | 1794 | | |
1775 | 1795 | | |
| |||
1832 | 1852 | | |
1833 | 1853 | | |
1834 | 1854 | | |
| 1855 | + | |
1835 | 1856 | | |
1836 | 1857 | | |
1837 | 1858 | | |
1838 | 1859 | | |
1839 | 1860 | | |
1840 | | - | |
1841 | | - | |
1842 | | - | |
1843 | | - | |
1844 | | - | |
1845 | | - | |
1846 | | - | |
1847 | | - | |
1848 | | - | |
1849 | | - | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
1854 | | - | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
1855 | 1879 | | |
1856 | 1880 | | |
1857 | 1881 | | |
| |||
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