-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip 3: rename checkSecurityParamConsistency to configAllSecurityParam…
…s but add a checkSecurityParamConsistency that actually checks security params are consistent
- Loading branch information
1 parent
438121b
commit ff8db93
Showing
16 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
24 changes: 24 additions & 0 deletions
24
...us-diffusion/changelog.d/20240207_130158_fraser.murray_startup_sanity_checks.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
|
||
<!-- | ||
### Patch | ||
- A bullet item for the Patch category. | ||
--> | ||
|
||
### Non-Breaking | ||
|
||
- Adds a Tracer for startup sanity check warnings in Ouroboros.Consensus.Node.Tracers (see BlockSupportsSanityCheck in ouroboros-consensus) | ||
|
||
|
||
<!-- | ||
### Breaking | ||
- A bullet item for the Breaking category. | ||
--> |
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
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
12 changes: 0 additions & 12 deletions
12
...ensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node/SanityCheck.hs
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...us-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/Node/StartupWarning.hs
This file was deleted.
Oops, something went wrong.
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
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
22 changes: 22 additions & 0 deletions
22
...os-consensus/changelog.d/20240207_130158_fraser.murray_startup_sanity_checks.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
|
||
<!-- | ||
### Patch | ||
- A bullet item for the Patch category. | ||
--> | ||
### Non-Breaking | ||
|
||
- Add BlockSupportsSanityCheck to check for common configuration issues which may manifest themselves in unusual but not necessarily immediately obvious ways | ||
|
||
<!-- | ||
### Breaking | ||
- A bullet item for the Breaking category. | ||
--> |
37 changes: 34 additions & 3 deletions
37
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Block/SupportsSanityCheck.hs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,48 @@ | ||
module Ouroboros.Consensus.Block.SupportsSanityCheck | ||
( BlockSupportsSanityCheck(..) | ||
( SanityCheckIssue(..) | ||
, BlockSupportsSanityCheck(..) | ||
, checkSecurityParamConsistency | ||
, sanityCheckConfig | ||
, ProtocolConfigHasSecurityParam(..) | ||
) where | ||
|
||
import Control.Exception | ||
import Data.Maybe (catMaybes) | ||
import Ouroboros.Consensus.Config (TopLevelConfig) | ||
import Data.List.NonEmpty (NonEmpty) | ||
import Data.List.NonEmpty (NonEmpty(..)) | ||
import Ouroboros.Consensus.Config.SecurityParam | ||
import Ouroboros.Consensus.Protocol.Abstract | ||
|
||
data SanityCheckIssue | ||
= InconsistentSecurityParam (NonEmpty SecurityParam) | ||
deriving (Show, Eq) | ||
|
||
instance Exception SanityCheckIssue | ||
|
||
class BlockSupportsSanityCheck blk where | ||
checkSecurityParamConsistency | ||
configAllSecurityParams | ||
:: TopLevelConfig blk | ||
-> NonEmpty SecurityParam | ||
|
||
checkSecurityParamConsistency | ||
:: BlockSupportsSanityCheck blk | ||
=> TopLevelConfig blk | ||
-> Maybe SanityCheckIssue | ||
checkSecurityParamConsistency cfg = do | ||
let allParams = configAllSecurityParams cfg | ||
if allSame allParams | ||
then Nothing | ||
else Just (InconsistentSecurityParam allParams) | ||
|
||
allSame :: Eq a => NonEmpty a -> Bool | ||
allSame (x :| xs) = all (x ==) xs | ||
|
||
sanityCheckConfig | ||
:: BlockSupportsSanityCheck blk | ||
=> TopLevelConfig blk | ||
-> [SanityCheckIssue] | ||
sanityCheckConfig cfg = | ||
catMaybes [checkSecurityParamConsistency cfg] | ||
|
||
class ProtocolConfigHasSecurityParam p where | ||
protocolConfigSecurityParam :: ConsensusConfig p -> SecurityParam |
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
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
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
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