Add LoE to the ChainDB QSM test
Closes #541
This PR adds a new instruction to the ChainDB q-s-m test, which updates the Limit on Eagerness (LoE) fragment and retriggers chain selection. This requires a model implementation of the LoE.
The test failure in
getChain_addChainmakes sense: The test is making sure that for every chainbc, adding its blocks to an empty model causes the selection to bebc. With the LoE enabled and at Genesis (as is the case in the counterexamples), this of course fails when the chain is sufficiently long.One way to fix this would be to discard these test cases, or even just disable the LoE completely for them.
The failure of
alwaysPickPreferredChainseems to be for a very similar reason.
Indeed, it was as simple as that. Fixed in 660b331b0126243c79a054a197596fb63a2e050d. Could you check it, and in particular tell me if the comment of alwaysPickPreferredChain is correct? (The one for getChain_addChain is exactly what you wrote.)
Now rebased on top of #1125.
After 14 hours of tests, I find a counter-example to this PR. Reproducible on branch niols/loe-chaindb-qsm at commit 2da9483a2947902df18b6da30f8ffbb7133a3ce5 with:
cabal run ouroboros-consensus:storage-test -- \
-p '/ChainDB q-s-m/' \
--quickcheck-tests 500_000 \
--quickcheck-replay="(SMGen 16524770743761658109 16657631389868279761,58)"
Actually, upon inspecting this bug, it turns out that this failure is not LoE-related. The LoE is very much disabled and it looks like this has to do with GCing or streaming. I don't exactly know what this should do, but the behaviour of the model looks wrong to me.
Yup, I can reproduce with the same seed on genesis/milestone-13 and main with an additional:
+source-repository-package
+ type: git
+ location: https://github.com/UnkindPartition/tasty
+ tag: dcbf32078133aa2b569774c417cc49a49f5c573b
+ subdir: quickcheck
+ --sha256: 0rwfcv0iq50ckzdgdssgkil6g9n76w1k6yxs0q4fdrkf5nlh4vv5
in cabal.project. I don't understand why I manage to reproduce when the code of the test changed so much, but oh well.
As noted by @amesgen, this is probably https://github.com/IntersectMBO/ouroboros-consensus/issues/299.