Skip to content
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

Merged
merged 4 commits into from
Jul 9, 2020
Merged

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Jul 8, 2020

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 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.


test-infra: use Gen instead of MonadRandom in TxGen class

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.


Shelley: more efficient reapplyLedgerBlock

Take advantage of IntersectMBO/cardano-ledger#1630.

@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Jul 8, 2020
@mrBliss mrBliss requested a review from edsko July 8, 2020 16:03
@mrBliss
Copy link
Contributor Author

mrBliss commented Jul 8, 2020

Maybe we should create a ticket about the remaining use of MonadRandom in TxGen.

UPDATE: after some help from @nfrisby, this is no longer needed, as MonadRandom is now gone entirely 🎉.

@mrBliss mrBliss force-pushed the mrBliss/update-deps-20200708 branch 2 times, most recently from e44a77e to bc04263 Compare July 9, 2020 06:16
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.
@mrBliss mrBliss force-pushed the mrBliss/update-deps-20200708 branch 2 times, most recently from 5356faa to af8a3ec Compare July 9, 2020 09:22
@mrBliss mrBliss requested a review from nfrisby July 9, 2020 09:24
@mrBliss mrBliss force-pushed the mrBliss/update-deps-20200708 branch from af8a3ec to 92ae175 Compare July 9, 2020 10:27
where
go :: KESEvolution
-> KESEvolution
-> SignKeyKES (KES c)
-> Maybe (SignKeyKES (KES c))
-> m (Maybe (SignKeyKES (KES c)))
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope

nfrisby and others added 2 commits July 9, 2020 13:26
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.
@mrBliss mrBliss force-pushed the mrBliss/update-deps-20200708 branch from 92ae175 to 9f14b95 Compare July 9, 2020 11:27
@mrBliss mrBliss changed the title Remove MonadRandom from consensus & securely forget the signing key Remove MonadRandom from consensus Jul 9, 2020
@mrBliss
Copy link
Contributor Author

mrBliss commented Jul 9, 2020

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 9, 2020

👎 Rejected by too few approved reviews

Copy link
Contributor

@edsko edsko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good riddance 😏

@mrBliss
Copy link
Contributor Author

mrBliss commented Jul 9, 2020

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 9, 2020

@iohk-bors iohk-bors bot merged commit 8ca6cd8 into master Jul 9, 2020
@iohk-bors iohk-bors bot deleted the mrBliss/update-deps-20200708 branch July 9, 2020 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove MonadRandom constraints from consensus
3 participants