-
Notifications
You must be signed in to change notification settings - Fork 86
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
Remove MonadRandom from consensus #2372
Conversation
UPDATE: after some help from @nfrisby, this is no longer needed, as |
e44a77e
to
bc04263
Compare
Fixes #2036. Update the dependencies on `cardano-base` and `cardano-ledger-specs`, bringing in IntersectMBO/cardano-base#139 and IntersectMBO/cardano-ledger#1621, which remove `MonadRandom` from the VRF Crypto class. This means we can remove `MonadRandom` from `checkIsLeader`. The implementation code no longer mentions `MonadRandom`, but the `TxGen` used in the ThreadNet tests still does.
5356faa
to
af8a3ec
Compare
af8a3ec
to
92ae175
Compare
ouroboros-consensus/ouroboros-consensus-mock/test/Test/ThreadNet/Praos.hs
Outdated
Show resolved
Hide resolved
where | ||
go :: KESEvolution | ||
-> KESEvolution | ||
-> SignKeyKES (KES c) | ||
-> Maybe (SignKeyKES (KES c)) | ||
-> m (Maybe (SignKeyKES (KES c))) |
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.
Make non-monadic again, return a list of keys to forget.
| Just targetEvolution <- toEvolution hk targetPeriod | ||
= go targetEvolution (hkEvolution hk) (hkKey hk) >>= \case | ||
Nothing -> return Nothing | ||
Just key' -> return $ Just HotKey { |
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.
Forget the returned old keys before returning.
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.
Important: we never want to have a dangling pointer to a key that is forgotten. Accessing that key might result in a segfault (?) 😱
, hkKey = key' | ||
} | ||
| otherwise | ||
= return Nothing | ||
where |
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.
| targetEvolution < curEvolution | ||
= Nothing | ||
= forgetSignKeyKES key >> return Nothing |
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.
Nope
Replace `Test.Util.Random` with `Test.ThreadNet.Util.Seed`, which uses QuickCheck instead of `MonadRandom`. Remove all mentions of `MonadRandom` from the testsuite and thus from the repository. This means the seeds mentioned in the regression tests are no longer the ones that produced the original failures. However, the seed is mainly used to generate transactions, so the regression tests that don't mention transactions are left in place with `Seed 0`. As we don't have a transaction generator for Byron, we can leave *all* those regression tests in place. A few tests for the mock protocols that relied on transactions were removed.
Take advantage of IntersectMBO/cardano-ledger#1630.
92ae175
to
9f14b95
Compare
bors merge |
👎 Rejected by too few approved reviews |
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.
Good riddance 😏
bors merge |
WARNING: I believe the changes in
cardano-ledger-specs
break compatibility with deployed testnets.Remove MonadRandom from consensus
Fixes #2036.
Update the dependencies on
cardano-base
andcardano-ledger-specs
, bringingin IntersectMBO/cardano-base#139 and
IntersectMBO/cardano-ledger#1621, which
remove
MonadRandom
from the VRF Crypto class.This means we can remove
MonadRandom
fromcheckIsLeader
.The implementation code no longer mentions
MonadRandom
, but theTxGen
usedin the ThreadNet tests still does.
test-infra: use Gen instead of MonadRandom in TxGen class
Replace
Test.Util.Random
withTest.ThreadNet.Util.Seed
, which usesQuickCheck instead of
MonadRandom
.Remove all mentions of
MonadRandom
from the testsuite and thus from therepository.
This means the seeds mentioned in the regression tests are no longer the ones
that produced the original failures. However, the seed is mainly used to
generate transactions, so the regression tests that don't mention transactions
are left in place with
Seed 0
. As we don't have a transaction generator forByron, we can leave all those regression tests in place. A few tests for the
mock protocols that relied on transactions were removed.
Shelley: more efficient reapplyLedgerBlock
Take advantage of IntersectMBO/cardano-ledger#1630.