-
Notifications
You must be signed in to change notification settings - Fork 33
New criterion for transitioning to CaughtUp #1669
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
Merged
Parent:
Peras staging ground
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3170661
Break Idling into its own module
agustinmista df386c5
Introduce O.C.MiniProtocol.ObjectDiffusion.Inbound.State
agustinmista 46451bb
Introduce PerasCertDiffusion type synonyms
agustinmista 587c566
Generalize chainSyncState to peerState in the GSM
agustinmista 78f7e5c
Store NodeToNodeVersion in GSM peer state components
agustinmista 7ca058f
Introduce O.C.Node.GSM.PeerState
agustinmista 4e3115c
Enhance GSM view with PerasCertDiffusion information
agustinmista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
78 changes: 78 additions & 0 deletions
78
...sus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node/GSM/PeerState.hs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| module Ouroboros.Consensus.Node.GSM.PeerState | ||
| ( GsmPeerState (..) | ||
| , maybeChainSyncState | ||
| , maybePerasCertDiffusionState | ||
| , mkGsmPeerStates | ||
| , gsmPeerIsIdle | ||
| ) | ||
| where | ||
|
|
||
| import Cardano.Base.FeatureFlags (CardanoFeatureFlag (..)) | ||
| import Data.Align (Semialign (..)) | ||
| import Data.Map.Strict (Map) | ||
| import Data.Set (Set) | ||
| import Data.These (These (..)) | ||
| import Ouroboros.Consensus.MiniProtocol.ChainSync.Client.State | ||
| ( ChainSyncClientHandle (..) | ||
| , ChainSyncClientHandleCollection (..) | ||
| , ChainSyncState (..) | ||
| ) | ||
| import Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.Inbound.State | ||
| ( ObjectDiffusionInboundHandle (..) | ||
| , ObjectDiffusionInboundHandleCollection (..) | ||
| , ObjectDiffusionInboundState (..) | ||
| ) | ||
| import Ouroboros.Consensus.MiniProtocol.ObjectDiffusion.PerasCert (PerasCertDiffusionInboundState) | ||
| import Ouroboros.Consensus.Util.IOLike (MonadSTM (..), readTVar) | ||
| import Ouroboros.Network.NodeToNode.Version (isPerasEnabled) | ||
|
|
||
| -- | State about peers we are connected to during initialization. | ||
| newtype GsmPeerState blk = GsmPeerState | ||
| { unGsmPeerState :: | ||
| These | ||
| (ChainSyncState blk) | ||
| (PerasCertDiffusionInboundState blk) | ||
| } | ||
|
|
||
| -- | Retrieve the 'ChainSync' state of this peer, if such a connection is established. | ||
| maybeChainSyncState :: GsmPeerState blk -> Maybe (ChainSyncState blk) | ||
| maybeChainSyncState (GsmPeerState these) = | ||
| case these of | ||
| This csState -> Just csState | ||
| That _ -> Nothing | ||
| These csState _ -> Just csState | ||
|
|
||
| -- | Retrieve the 'PerasCertDiffusion' state of this peer, if such a connection is established. | ||
| maybePerasCertDiffusionState :: GsmPeerState blk -> Maybe (PerasCertDiffusionInboundState blk) | ||
| maybePerasCertDiffusionState (GsmPeerState these) = | ||
| case these of | ||
| This _ -> Nothing | ||
| That pcdState -> Just pcdState | ||
| These _ pcdState -> Just pcdState | ||
|
|
||
| -- | Construct a 'GsmPeerState' for all peers we are connected to. | ||
| mkGsmPeerStates :: | ||
| (Ord peer, MonadSTM m) => | ||
| ChainSyncClientHandleCollection peer m blk -> | ||
| ObjectDiffusionInboundHandleCollection peer m blk -> | ||
| STM m (Map peer (GsmPeerState blk)) | ||
| mkGsmPeerStates csHandles pcdHandles = do | ||
| csPeerStates <- traverse (readTVar . cschState) =<< cschcMap csHandles | ||
| pcdPeerStates <- traverse (readTVar . odihState) =<< odihcMap pcdHandles | ||
| pure (GsmPeerState <$> align csPeerStates pcdPeerStates) | ||
|
|
||
| -- | Determine whether our connections to this peer are idle. | ||
| gsmPeerIsIdle :: Set CardanoFeatureFlag -> GsmPeerState blk -> Bool | ||
| gsmPeerIsIdle featureFlags (GsmPeerState these) = | ||
| case these of | ||
| -- We have both ChainSync and PerasCertDiffusion connections => idle if both are idling | ||
| These csState pcdState -> csIdling csState && odisIdling pcdState | ||
| -- Only a ChainSync connection is available => idle if the ChainSync connection is idling | ||
| This csState | not (perasIsEnabled csState) -> csIdling csState | ||
| -- We will soon establish a PerasCertDiffusion connection => not idling | ||
| This _ -> False | ||
| -- We will soon establish a ChainSync connection => not idling | ||
| That _ -> False | ||
| where | ||
| -- Is the Peras feature flag enabled and the peer is compatible with it? | ||
| perasIsEnabled csState = isPerasEnabled featureFlags (csNodeToNodeVersion csState) |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.