-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrained generators for EPOCH
rule
#4740
Conversation
@Soupstraw here is a WIP approach to getting |
bc129f0
to
f27fa1a
Compare
@Soupstraw I would appreciate some eyes on this. There are still things to do here but the generators used in |
d9d392c
to
19b9577
Compare
libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Epoch.hs
Show resolved
Hide resolved
b90d053
to
8c55c3d
Compare
@Soupstraw I don't get how this can compile on my machine? There is a function called |
|
6c371bb
to
6e93503
Compare
@Soupstraw how do we turn on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things look reasonable to me.
libs/cardano-ledger-test/src/Test/Cardano/Ledger/Constrained/Conway/Epoch.hs
Outdated
Show resolved
Hide resolved
r <- genFromSpecT spec | ||
unsafePerformIO $ | ||
r `seq` | ||
pure (pure r) `catch` \(e :: SomeException) -> pure (fatalError (pure $ show e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just calls to error that we are trying to catch, or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calls to error yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a horrible piece of code that is totally incorrect:
-
It will catch all exceptions, including async exceptions. It should have been catching the
ErrorCall
exception instead ofSomeException
, if it needs to catch error calls. -
Moreover this code will not even catch error calls because
seq
happens outside ofcatch
:
ghci> let x = undefined in x `seq` pure x `catch` \e -> putStrLn ("WTH " <> show (e :: SomeException))
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
undefined, called at <interactive>:8:9 in interactive:Ghci2
ghci> let x = undefined in (x `seq` pure x) `catch` \e -> putStrLn ("WTH ==============\n" <> show (e :: SomeException))
WTH ==============
Prelude.undefined
CallStack (from HasCallStack):
undefined, called at <interactive>:10:9 in interactive:Ghci3
- Moreover, using
unsafePerformIO
to catch an exception will lead to non-deterministic execution, which can break referential transparency. In other words it is never safe to catch exceptions in pure code withunsafePerformIO
e578934
to
6767b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok just a few comments about adding comments to make things clearer.
libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Conformance/ExecSpecRule/Conway/Base.hs
Outdated
Show resolved
Hide resolved
6767b04
to
4632489
Compare
e159fc4
to
5c0d20c
Compare
weird problems Make things compile minor Don't need a concrete CertState in proposalsSpec Start on EPOCH state generator spec Add variant of stsProperty where the spec for the post state can depend on the signal Start constraining DRepPulsingState in EpochState generator Use conformsToSpecProp to get more feed back when sts property fails try to just get the property passing Add missing instance fmt WIP insanity WIP approach to shrinking wip Make compile again More constraints comment Get the epoch rule closer to being right fmt Fix build error wip Correct lens version Fix Fix build issue
Description
closes #4669
Checklist
CHANGELOG.md
for the affected packages.New section is never added with the code changes. (See RELEASING.md)
.cabal
andCHANGELOG.md
files according to theversioning process.
.cabal
files for all affected packages are updated.If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
fourmolu
(usescripts/fourmolize.sh
)scripts/cabal-format.sh
)hie.yaml
has been updated (usescripts/gen-hie.sh
)