forked from kadena-io/chainweb-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Extend ForkHeight to manage Fork numbers #20
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
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d02e2a
Extend ForkHeight to manage by ForkNumber
kdafriend 489728f
Apply suggestions from code review
kdafriend 92fff2a
Add comments
kdafriend dd5a906
maxBlockGasLimit, minimumBlockHeaderHistory, verifiersAt use ForkNumber
kdafriend 4e7fb56
Headers compaction height depends on the ForkNumber + Rename some va…
kdafriend e0f4b5f
Validate that no fork or rules application happens by height after Ch…
kdafriend e64444c
Apply suggestions from code review
kdafriend 52c1a46
Check that no fork use fork number of 0
kdafriend 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,8 +78,8 @@ unregisterVersion v = do | |
| then error "You cannot unregister mainnet or testnet04 versions" | ||
| else atomicModifyIORef' versionMap $ \m -> (HM.delete (_versionCode v) m, ()) | ||
|
|
||
| validateNoHeightAfterChainweb31' :: ChainwebVersion -> ForkHeight -> Either String () | ||
| validateNoHeightAfterChainweb31' v fh = | ||
| validateNoHeightAfterChainweb31 :: ChainwebVersion -> ForkHeight -> Either String () | ||
| validateNoHeightAfterChainweb31 v fh = | ||
| case (fork31Height, fh) of | ||
| (Just (ForkAtBlockHeight refAth), ForkAtBlockHeight ath) -> | ||
| if ath > (refAth + 1) | ||
|
|
@@ -89,12 +89,21 @@ validateNoHeightAfterChainweb31' v fh = | |
| where | ||
| fork31Height = v ^? versionForks . at Chainweb31 . _Just . atChain (unsafeChainId 0) | ||
|
|
||
| validateNoHeightAfterChainweb31 :: ChainwebVersion -> Either String () | ||
| validateNoHeightAfterChainweb31 v = | ||
| (mapM_ (mapM_ (validateNoHeightAfterChainweb31' v)) (v ^. versionForks)) | ||
| >> (mapM_ (validateNoHeightAfterChainweb31' v . fst) $ ruleElems $ v ^. versionMaxBlockGasLimit) | ||
| >> (mapM_ (validateNoHeightAfterChainweb31' v . fst) $ ruleElems $ v ^. versionSpvProofRootValidWindow) | ||
| >> (mapM_ (mapM_ (validateNoHeightAfterChainweb31' v . fst) . ruleElems) $ v ^. versionVerifierPluginNames) | ||
| validateNoForkAtZero :: ForkHeight -> Either String () | ||
| validateNoForkAtZero (ForkAtForkNumber atn) | ||
| | atn == 0 = Left ("ValidateSting: Fork Numbers can't be 0 ") | ||
| | otherwise = Right () | ||
| validateNoForkAtZero _ = Right () | ||
|
|
||
|
|
||
| validateForkHeights :: ChainwebVersion -> Either String () | ||
| validateForkHeights v = | ||
| (mapM_ (mapM_ doValidation) (v ^. versionForks)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be made a bit nicer in a follow-up with |
||
| >> (mapM_ (doValidation . fst) $ ruleElems $ v ^. versionMaxBlockGasLimit) | ||
| >> (mapM_ (doValidation . fst) $ ruleElems $ v ^. versionSpvProofRootValidWindow) | ||
| >> (mapM_ (mapM_ (doValidation . fst) . ruleElems) $ v ^. versionVerifierPluginNames) | ||
| where | ||
| doValidation fh = validateNoHeightAfterChainweb31 v fh >> validateNoForkAtZero fh | ||
|
|
||
| validateVersion :: HasCallStack => ChainwebVersion -> IO () | ||
| validateVersion v = do | ||
|
|
@@ -125,7 +134,7 @@ validateVersion v = do | |
| , [ "validateVersion: some pact upgrade has no transactions" | ||
| | any (any isUpgradeEmpty) (_versionUpgrades v) ] | ||
| , [ err | ||
| | Left err <- [validateNoHeightAfterChainweb31 v] ] | ||
| | Left err <- [validateForkHeights v] ] | ||
| -- TODO: check that pact 4/5 upgrades are only enabled when pact 4/5 is enabled | ||
| ] | ||
| unless (null errors) $ | ||
|
|
||
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.
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.
You can delete this case.