-
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
Evolve ForgeState eagerly and trace it #2160
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
After all, we should not need to keep any state at all if we're not producing blocks.
This is stateful, which requires an additional @m@ parameter in various places, which is why this commit is a bit larger. Not much happening though.
We used to have ``` checkIfCanBeLeader :: ConsensusConfig p -> Bool ``` But this leads to boolean blindness, and moreover meant that we needed to somehow be able to represent within the config that we may or may not be a leader. This was getting in the way of the refactoring we require for this PR, so I've now introduced ``` -- | Evidence that we /can/ be a leader type family CanBeLeader p :: * ``` This removes a bunch of error cases, and means that in `protocolInfo`, we can now express that we only need to provide a `MaintainForgeState` instance if and only if we are a leader: we bundle it in a single `Maybe` together with the `CanBeLeader` proof.
It's now backed by a `StrictMVar` rather than a `TVar`, which means we can use `modifyMVar`. This makes it possible to avoid the awkward "evolving key" dance that was needed for `TPraos`. Had to change `ChaChaT` to be `ReaderT` (of a `TVar` containing the DRG) based rather than `StateT`, because the latter does not support `MonadCatch`/`MonadMask`, required for `modifyMVar`.
edsko
commented
May 28, 2020
ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/ouroboros-consensus-test-infra/src/Test/ThreadNet/General.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/src/Ouroboros/Consensus/Node/ProtocolInfo.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Protocol/Praos.hs
Outdated
Show resolved
Hide resolved
mrBliss
approved these changes
May 28, 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.
Nice, much better than before!
bors merge |
iohk-bors bot
added a commit
that referenced
this pull request
May 28, 2020
2160: Evolve ForgeState eagerly and trace it r=edsko a=edsko This actually required some refactoring, getting rid of the boolean blindness introduced in #1927. Now if a node is not a leader, its config does not even need to contain _any_ info anymore that is required for block production, and conversely, if we _are_ a leader, then we don't need to deal with the case that we might lack this information in `checkIsLeader`. Co-authored-by: Edsko de Vries <edsko@well-typed.com>
Canceled |
bors merge |
coot
pushed a commit
that referenced
this pull request
May 16, 2022
2160: Evolve ForgeState eagerly and trace it r=edsko a=edsko This actually required some refactoring, getting rid of the boolean blindness introduced in #1927. Now if a node is not a leader, its config does not even need to contain _any_ info anymore that is required for block production, and conversely, if we _are_ a leader, then we don't need to deal with the case that we might lack this information in `checkIsLeader`. Co-authored-by: Edsko de Vries <edsko@well-typed.com>
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.
This actually required some refactoring, getting rid of the boolean blindness introduced in #1927. Now if a node is not a leader, its config does not even need to contain any info anymore that is required for block production, and conversely, if we are a leader, then we don't need to deal with the case that we might lack this information in
checkIsLeader
.