-
Notifications
You must be signed in to change notification settings - Fork 163
Disallow duplicate VRF keys for pool registration #5229
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
027d90b
Add some lenses for `PoolParams` and `StakePoolState` fields
teodanciu e8edba8
Add Imp spec to test pool (re)registration and retiring
teodanciu 7dcfc83
Add VRF keyhashes to `PState`
teodanciu 05e2559
Add `ShelleyPoolPredFailure` for duplicate VRF keys
teodanciu f119c14
Disallow duplicate VRF keys in stake pool registration starting with v11
teodanciu 553efb0
Add more test cases for reusing VRF keys
teodanciu ab60e15
Remove future VRFS from set of known VRFs on pool re-registration
teodanciu 3804cae
Remove dangling VRFs from set of known VRFs in `PoolReap`
teodanciu a5e8010
Implement suggested changes for predicate failure and state update
teodanciu 505717d
Extract drep delegation in HardFork rule in a separate function
teodanciu a5543c1
Update HardFork rule to populate VRF key hashes
teodanciu 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
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
77 changes: 77 additions & 0 deletions
77
eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/HardForkSpec.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,77 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE OverloadedLists #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module Test.Cardano.Ledger.Conway.Imp.HardForkSpec (spec) where | ||
|
||
import Cardano.Ledger.BaseTypes | ||
import Cardano.Ledger.Conway.Core | ||
import Cardano.Ledger.Conway.Governance | ||
import Cardano.Ledger.Conway.PParams | ||
import Cardano.Ledger.Conway.State | ||
import Cardano.Ledger.Shelley.LedgerState | ||
import qualified Data.Set as Set | ||
import Lens.Micro | ||
import Test.Cardano.Ledger.Conway.ImpTest | ||
import Test.Cardano.Ledger.Core.Rational | ||
import Test.Cardano.Ledger.Imp.Common | ||
|
||
spec :: | ||
forall era. | ||
ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era)) | ||
spec = do | ||
it "VRF Keyhashes get populated at v11 HardFork" $ do | ||
-- Since we're testing the HardFork to 11, the test only makes sense for protocol version 10 | ||
whenMajorVersion @10 $ do | ||
(kh1, vrf1) <- (,) <$> freshKeyHash <*> freshKeyHashVRF | ||
registerStakePool kh1 vrf1 | ||
(kh2, vrf2) <- (,) <$> freshKeyHash <*> freshKeyHashVRF | ||
registerStakePool kh2 vrf2 | ||
vrf3 <- freshKeyHashVRF | ||
-- re-register with a new key, so vrf1 should not be present after the hard fork | ||
registerStakePool kh1 vrf3 | ||
-- register a new pool with an existing vrf | ||
kh3 <- freshKeyHash | ||
registerStakePool kh3 vrf2 | ||
-- register and retire a pool before the hard fork, so vrf4 should not be present after the hard fork | ||
(kh4, vrf4) <- (,) <$> freshKeyHash <*> freshKeyHashVRF | ||
registerStakePool kh4 vrf4 | ||
retireStakePool kh4 (EpochInterval 1) | ||
-- register and schedule retirement for after the hard fork, so vrf5 should be present after the hard fork | ||
(kh5, vrf5) <- (,) <$> freshKeyHash <*> freshKeyHashVRF | ||
registerStakePool kh5 vrf5 | ||
retireStakePool kh5 (EpochInterval 5) | ||
|
||
expectVRFs [] -- VRF keyhashes in PState is not yet populated | ||
enactHardForkV11 | ||
expectVRFs [vrf2, vrf3, vrf5] | ||
where | ||
enactHardForkV11 = do | ||
modifyPParams $ \pp -> | ||
pp | ||
& ppDRepVotingThresholdsL . dvtHardForkInitiationL .~ 0 %! 1 | ||
& ppPoolVotingThresholdsL . pvtHardForkInitiationL .~ 0 %! 1 | ||
let pv11 = ProtVer (natVersion @11) 0 | ||
committee <- registerInitialCommittee | ||
govActionId <- submitGovAction $ HardForkInitiation SNothing pv11 | ||
submitYesVoteCCs_ committee govActionId | ||
passNEpochs 2 | ||
getProtVer `shouldReturn` pv11 | ||
registerStakePool kh vrf = do | ||
pps <- registerRewardAccount >>= freshPoolParams kh | ||
submitTx_ $ | ||
mkBasicTx mkBasicTxBody | ||
& bodyTxL . certsTxBodyL .~ [RegPoolTxCert $ pps & ppVrfL .~ vrf] | ||
retireStakePool kh retirementInterval = do | ||
curEpochNo <- getsNES nesELL | ||
let retirement = addEpochInterval curEpochNo retirementInterval | ||
submitTx_ $ | ||
mkBasicTx mkBasicTxBody | ||
& bodyTxL . certsTxBodyL .~ [RetirePoolTxCert kh retirement] | ||
expectVRFs vrfs = | ||
psVRFKeyHashes <$> getPState `shouldReturn` Set.fromList vrfs | ||
getPState = getsNES @era $ nesEsL . esLStateL . lsCertStateL . certPStateL |
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
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
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.