Skip to content

Commit

Permalink
consensus: track EBBs in PBFT chain state
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrisby committed Dec 5, 2019
1 parent b70d08e commit f2a050b
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 131 deletions.
17 changes: 13 additions & 4 deletions ouroboros-consensus/src/Ouroboros/Consensus/Protocol/PBFT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ instance ( PBftCrypto c

applyChainState cfg@PBftNodeConfig{..} lv@(PBftLedgerView dms) (b :: hdr) chainState =
case headerPBftFields pbftExtConfig b of
Nothing ->
-- EBB. Nothing to do
return chainState
Nothing -> do
return $! appendEBB cfg params (blockSlot b) chainState
Just (PBftFields{..}, signed) -> do
-- Check that the issuer signature verifies, and that it's a delegate of a
-- genesis key, and that genesis key hasn't voted too many times.
Expand All @@ -255,7 +254,7 @@ instance ( PBftCrypto c
-- FIXME confirm that non-strict inequality is ok in general.
-- It's here because EBBs have the same slot as the first block of their
-- epoch.
unless (At (blockSlot b) >= CS.lastSlot chainState)
unless (At (blockSlot b) >= CS.lastSignedSlot chainState)
$ throwError PBftInvalidSlot

case Bimap.lookupR (hashVerKey pbftIssuer) dms of
Expand Down Expand Up @@ -334,6 +333,16 @@ append PBftNodeConfig{..} PBftWindowParams{..} =
where
PBftParams{..} = pbftParams

appendEBB :: PBftCrypto c
=> NodeConfig (PBft cfg c)
-> PBftWindowParams
-> SlotNo
-> PBftChainState c -> PBftChainState c
appendEBB PBftNodeConfig{..} PBftWindowParams{..} =
CS.appendEBB pbftSecurityParam windowSize
where
PBftParams{..} = pbftParams

rewind :: PBftCrypto c
=> NodeConfig (PBft cfg c)
-> PBftWindowParams
Expand Down
Loading

0 comments on commit f2a050b

Please sign in to comment.