Skip to content
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

Reinstate PBFT VrF checks #1590

Merged
merged 3 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ vrfChecks eta0 bhb = do
(mkSeed seedL slot eta0)
(coerce $ bheaderL bhb)
)
(throwError $ VRFKeyBadLeaderValue seedEta slot eta0 (coerce $ bheaderL bhb))
(throwError $ VRFKeyBadLeaderValue seedL slot eta0 (coerce $ bheaderL bhb))
where
vrfK = bheaderVrfVk bhb
slot = bheaderSlotNo bhb
Expand Down Expand Up @@ -200,25 +200,25 @@ praosVrfChecks eta0 (PoolDistr pd) f bhb = do
hk = coerceKeyRole . hashKey $ bheaderVk bhb
vrfK = bheaderVrfVk bhb

-- pbftVrfChecks ::
-- forall crypto.
-- ( Crypto crypto,
-- VRF.Signable (VRF crypto) Seed,
-- VRF.ContextVRF (VRF crypto) ~ ()
-- ) =>
-- Hash crypto (VerKeyVRF crypto) ->
-- Nonce ->
-- BHBody crypto ->
-- Either (PredicateFailure (OVERLAY crypto)) ()
-- pbftVrfChecks vrfHK eta0 bhb = do
-- unless
-- (vrfHK == hashVerKeyVRF vrfK)
-- (throwError $ WrongGenesisVRFKeyOVERLAY hk vrfHK (hashVerKeyVRF vrfK))
-- vrfChecks eta0 bhb
-- pure ()
-- where
-- hk = coerceKeyRole . hashKey $ bheaderVk bhb
-- vrfK = bheaderVrfVk bhb
pbftVrfChecks ::
forall crypto.
( Crypto crypto,
VRF.Signable (VRF crypto) Seed,
VRF.ContextVRF (VRF crypto) ~ ()
) =>
Hash crypto (VerKeyVRF crypto) ->
Nonce ->
BHBody crypto ->
Either (PredicateFailure (OVERLAY crypto)) ()
pbftVrfChecks vrfHK eta0 bhb = do
unless
(vrfHK == hashVerKeyVRF vrfK)
(throwError $ WrongGenesisVRFKeyOVERLAY hk vrfHK (hashVerKeyVRF vrfK))
vrfChecks eta0 bhb
pure ()
where
hk = coerceKeyRole . hashKey $ bheaderVk bhb
vrfK = bheaderVrfVk bhb

overlayTransition ::
forall crypto.
Expand Down Expand Up @@ -250,9 +250,9 @@ overlayTransition =
case Map.lookup gkey genDelegs of
Nothing ->
failBecause $ UnknownGenesisKeyOVERLAY gkey
Just (GenDelegPair genDelegsKey _genesisVrfKH) -> do
Just (GenDelegPair genDelegsKey genesisVrfKH) -> do
vkh == coerceKeyRole genDelegsKey ?! WrongGenesisColdKeyOVERLAY vkh genDelegsKey
-- pbftVrfChecks genesisVrfKH eta0 bhb ?!: id
pbftVrfChecks genesisVrfKH eta0 bhb ?!: id

let oce =
OCertEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,6 @@ lastByronHeaderHash _ = HashHeader $ coerce (hash 0 :: Hash (ConcreteCrypto h) I
nonce0 :: HashAlgorithm h => proxy h -> Nonce
nonce0 p = hashHeaderToNonce (lastByronHeaderHash p)

mkSeqNonce :: HashAlgorithm h => proxy h -> Natural -> Nonce
mkSeqNonce p m =
foldl'
(\c x -> c ⭒ mkNonceFromNumber (fromIntegral x))
(nonce0 p)
[1 .. m]

carlPay :: KeyPair h 'Payment
carlPay = KeyPair vk sk
where
Expand Down Expand Up @@ -1332,7 +1325,9 @@ blockEx2E =
[]
(SlotNo 220)
(BlockNo 5)
((mkSeqNonce p 3) ⭒ (hashHeaderToNonce (blockEx2BHash p)))
( makeEvolvedNonce p (nonce0 p) [blockEx2A, blockEx2B, blockEx2C]
⭒ (hashHeaderToNonce (blockEx2BHash p))
)
(NatNonce 5)
zero
11
Expand Down Expand Up @@ -2637,7 +2632,7 @@ blockEx3D =
[]
(SlotNo 110)
(BlockNo 4)
(makeEvolvedNonce p (nonce0 p) [blockEx3A, blockEx3B, blockEx3C] ⭒ mkNonceFromNumber 123)
(makeEvolvedNonce p (nonce0 p) [blockEx3A, blockEx3B] ⭒ mkNonceFromNumber 123)
(NatNonce 4)
zero
5
Expand Down Expand Up @@ -3244,7 +3239,7 @@ blockEx5D' pot =
[txEx5D' pot]
(slot)
(BlockNo 2)
(mkSeqNonce p 1)
(makeEvolvedNonce p (nonce0 p) [blockEx5D pot])
(NatNonce 2)
zero
7
Expand Down Expand Up @@ -3342,6 +3337,7 @@ test5DTreasury :: HashAlgorithm h => proxy h -> Assertion
test5DTreasury p = test5D p TreasuryMIR

-- * Example 6A - apply CHAIN transition to re-register a stake pool late in the epoch

-- This example continues on from example 2A.

feeEx6A :: Coin
Expand Down Expand Up @@ -3493,6 +3489,7 @@ ex6A' p =
(Right $ expectedStEx6A lateSlotEx6 rewardUpdateEx6A' (candidateNonceEx6A' p))

-- * Example 6B - If The TICK rule is applied to the NewEpochState

-- in expectedStEx6A, then the future pool parameters should be adopted

ex6BExpectedNES :: forall h. HashAlgorithm h => NewEpochState h
Expand Down