-
Notifications
You must be signed in to change notification settings - Fork 87
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
Use the IO instance of MonadRandom #1677
Merged
Merged
Conversation
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
e05dd06
to
49a35f6
Compare
mrBliss
commented
Feb 20, 2020
ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Protocol/Praos.hs
Outdated
Show resolved
Hide resolved
This was referenced Feb 20, 2020
edsko
approved these changes
Feb 20, 2020
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.
Thank god somebody who actually knows what they're doing took over this PR 🙄
ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Protocol/Praos.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Protocol/Praos.hs
Outdated
Show resolved
Hide resolved
Previously, block production had to live in STM, but this is no longer the case as of #1445. This means that we no longer need to run `MonadRandom` computations in STM. To do that, we stored a DRG in a TVar. Now, we can simply use IO's instance of `MonadRandom`. In the tests we still use the DRG-in-a-TVar trick, but we split it whenever we get a DRG. We use the `RunMonadRandom` record for this purpose. In addition, this removes all notion of state from `ConsensusProtocol`, and instead makes this part of the `RunNode` interface. This also fixes and re-enables the praos tests. Closes #1616 Closes #1678 Closes #1545 Co-authored-by: Thomas Winant <thomas@well-typed.com>
aa2ac8b
to
e7cfaab
Compare
bors r+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1616.
Previously, block production had to live in STM, but this is no longer the
case as of #1445. This means that we no longer need to run
MonadRandom
computations in STM. To do that, we stored a DRG in a TVar.
Now, we can simply use IO's instance of
MonadRandom
. In the tests we stilluse the DRG-in-a-TVar trick, but we split it whenever we get a DRG.
We use the
RunMonadRandom
record for this purpose.Replace NodeState with MonadState
Previously, we need a separate
HasNodeState
class andNodeStateT
monadtransformer because there was already a
StateT
in our stack, i.e., the onecontaining the DRG. As that is gone, we can switch back to a regular
MonadState
+StateT
.The cost is an orphan instance:
MonadRandom (StateT s m)