Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
489: Assert that `ChainValidationState` is in normal form in `epochValid` prop r=ruhatch a=intricate I've added an option to `Test.Cardano.Chain.Block.Validation.tests` which either enables or disables an assertion to ensure that the `ChainValidationState` is always in normal form after validating each epoch. - In our existing `cardano-ledger-test` test-suite, we specify **not** to assert that the `ChainValidationState` is in normal form (`NoAssertNF`). - Added a new test executable, `epoch-validation-normal-form-test`, in which we specify to assert that the `ChainValidationState` is in normal form (`AssertNF`). I've also added a new CI job which builds and executes this without `hpc` coverage. The new test executable and CI job was added as a means of circumventing an "issue" which was encountered in our existing CI job. Because our existing CI job builds with `hpc` (`ghc -fhpc`/`stack --coverage`), thunks are introduced throughout our program for `hpc`'s program coverage measurement purposes and this prevents us from accurately determining whether a given expression is in normal form. So, following @erikd's advice, I've introduced this new test executable (which will be built without `hpc`) which basically just calls upon `Test.Cardano.Chain.Block.Validation.tests` and provides it with an argument of `AssertNF`. This way, we can still build and test our normal test-suite with code coverage and also test this new normal form assertion in a separate CI job. ### Notes The function [`heap_view_closurePtrs`](https://gitlab.haskell.org/ghc/ghc/blob/3bdf0d01ff47977830ada30ce85f174098486e23/rts/Heap.c#L79) in [`ghc/rts/Heap.c`](https://gitlab.haskell.org/ghc/ghc/blob/3bdf0d01ff47977830ada30ce85f174098486e23/rts/Heap.c) currently does not handle closures of type `CONSTR_NOCAF` and, as a result, it `fprintf`s a message to `stderr` every time it encounters one: `"closurePtrs: Cannot handle type CONSTR_NOCAF yet"`. Since the `isNormalForm` function utilizes this function it could get a bit "spammy" if we run into `CONSTR_NOCAF`s when running the test-suite. However, I've only seen that `CompactTxInUtxo`s are allocated as `CONSTR_NOCAF`s when we compile with `-O2`. In our CI jobs, we tend to use `stack --fast` (`-O0`) so we don't see this sort of spammy output to `stderr` in the logs. It's also worth noting that [Joachim Breitner has recently raised a PR with `ghc` for specifically handling `CONSTR_NOCAF` objects in `heap_view_closurePtrs`](https://gitlab.haskell.org/ghc/ghc/merge_requests/867) Co-authored-by: Luke Nadur <19835357+intricate@users.noreply.github.com> Co-authored-by: Rupert Horlick <rupert.horlick@iohk.io>
- Loading branch information
Showing
23 changed files
with
247 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-| | ||
This module basically just runs the mainnet epoch validation tests from | ||
"Test.Cardano.Chain.Block.Validation" but provided a 'ShouldAssertNF' value of | ||
'AssertNF'. | ||
We've created a separate test executable for this as, in our typical CI jobs, | ||
we utilize @hpc@ (i.e. building with @ghc -fhpc@ or @stack --coverage@) for | ||
providing code coverage. @hpc@ appears to introduce thunks around our Haskell | ||
expressions for its program coverage measurement purposes which prevents us | ||
from accurately determining whether a given expression is in normal form. As a | ||
result, we have another CI job which will build and run this test executable | ||
without @hpc@. | ||
-} | ||
|
||
module Main | ||
( main | ||
) | ||
where | ||
|
||
import Cardano.Prelude | ||
|
||
import System.IO.Silently (hSilence) | ||
|
||
import Test.Options (ShouldAssertNF (..), mainWithTestScenario, tsGroupToTree) | ||
|
||
import qualified Test.Cardano.Chain.Block.Validation | ||
|
||
|
||
main :: IO () | ||
main = | ||
hSilence [stderr] | ||
. mainWithTestScenario | ||
. tsGroupToTree | ||
$ Test.Cardano.Chain.Block.Validation.tests AssertNF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.