Skip to content

Commit

Permalink
Merge #875
Browse files Browse the repository at this point in the history
875: [#595] Implement and utilize byronBlockOrEBBMatchesHeader r=intricate a=intricate

Closes #595 

Co-authored-by: Luke Nadur <[email protected]>
  • Loading branch information
iohk-bors[bot] and intricate committed Aug 5, 2019
2 parents 5c25acf + 76c3742 commit 9198067
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions ouroboros-consensus/src/Ouroboros/Consensus/Ledger/Byron.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module Ouroboros.Consensus.Ledger.Byron
, GenTx (..)
, GenTxId (..)
, mkByronTx
-- * Block Fetch integration
, byronBlockOrEBBMatchesHeader
-- * Ledger
, LedgerState (..)
, LedgerConfig (..)
Expand Down Expand Up @@ -69,6 +71,7 @@ import qualified Data.Bimap as Bimap
import qualified Data.ByteString as Strict
import qualified Data.ByteString.Lazy as Lazy
import Data.Coerce (coerce)
import Data.Either (isRight)
import Data.FingerTree (Measured (..))
import Data.Foldable (find, foldl')
import Data.Reflection (Given (..))
Expand Down Expand Up @@ -869,6 +872,29 @@ mkByronTx tx = ByronTx
-- cardano-ledger#581
}

{-------------------------------------------------------------------------------
Block Fetch integration
-------------------------------------------------------------------------------}

byronBlockOrEBBMatchesHeader :: Header (ByronBlockOrEBB cfg)
-> ByronBlockOrEBB cfg
-> Bool
byronBlockOrEBBMatchesHeader blkOrEbbHdr blkOrEbb =
case unByronHeaderOrEBB blkOrEbbHdr of
-- For EBBs, we're currently being more permissive here and not
-- performing any header-body validation but only checking whether an
-- EBB header and EBB block were provided. This seems to be fine as it
-- won't cause any loss of consensus with the old `cardano-sl` nodes.
Left _ebbHdr -> isEbb (unByronBlockOrEBB blkOrEbb)
Right hdr -> isBlockAndHeaderMatchesBody (unByronBlockOrEBB blkOrEbb) hdr
where
isEbb (CC.Block.ABOBBoundary _) = True
isEbb (CC.Block.ABOBBlock _) = False
--
isBlockAndHeaderMatchesBody (CC.Block.ABOBBoundary _) _ = False
isBlockAndHeaderMatchesBody (CC.Block.ABOBBlock blk) hdr = isRight $
CC.Block.validateHeaderMatchesBody hdr (CC.Block.blockBody blk)

{-------------------------------------------------------------------------------
PBFT integration
-------------------------------------------------------------------------------}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Ouroboros.Consensus.Ledger.Byron.Forge

instance ByronGiven => RunNode (ByronBlockOrEBB ByronConfig) where
nodeForgeBlock = forgeBlockOrEBB
nodeBlockMatchesHeader = \_hdr _blk -> True -- TODO #595
nodeBlockMatchesHeader = byronBlockOrEBBMatchesHeader
nodeBlockFetchSize = const 2000 -- TODO #593
nodeIsEBB = \blk -> case unByronBlockOrEBB blk of
Cardano.Block.ABOBBlock _ -> False
Expand Down

0 comments on commit 9198067

Please sign in to comment.