Skip to content

Commit

Permalink
Directly use Hash type when defining Header Hash for Shelley
Browse files Browse the repository at this point in the history
This removes one layer of indirection through Ledger code and seems to
slightly simplify some things
  • Loading branch information
abailly-iohk committed Mar 16, 2023
1 parent 4b7c9b6 commit c7ea146
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Expand Up @@ -53,7 +53,6 @@ import Codec.Serialise (decode, encode)
import Control.Arrow (left)
import qualified Control.Exception as Exception
import Control.Monad.Except
import Data.Coerce (coerce)
import Data.Functor ((<&>))
import Data.Functor.Identity
import qualified Data.Text as Text
Expand Down Expand Up @@ -82,8 +81,8 @@ import Ouroboros.Consensus.Util.CBOR (decodeWithOrigin,
encodeWithOrigin)
import Ouroboros.Consensus.Util.Versioned

import qualified Cardano.Ledger.BaseTypes as SL (epochInfoPure)
import qualified Cardano.Ledger.BHeaderView as SL (BHeaderView)
import qualified Cardano.Ledger.BaseTypes as SL (epochInfoPure)
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Shelley.API as SL
import qualified Control.State.Transition.Extended as STS
Expand Down Expand Up @@ -194,7 +193,7 @@ castShelleyTip ::
castShelleyTip (ShelleyTip sn bn hh) = ShelleyTip {
shelleyTipSlotNo = sn
, shelleyTipBlockNo = bn
, shelleyTipHash = coerce hh
, shelleyTipHash = hh
}

data instance LedgerState (ShelleyBlock proto era) = ShelleyLedgerState {
Expand Down
Expand Up @@ -27,14 +27,14 @@ module Ouroboros.Consensus.Shelley.Protocol.Abstract (
) where

import Cardano.Binary (FromCBOR (fromCBOR), ToCBOR (toCBOR))
import Cardano.Crypto.Hash (Hash)
import Cardano.Crypto.VRF (OutputVRF)
import Cardano.Ledger.BaseTypes (ProtVer)
import Cardano.Ledger.BHeaderView (BHeaderView)
import Cardano.Ledger.Crypto (Crypto, VRF)
import Cardano.Ledger.BaseTypes (ProtVer)
import Cardano.Ledger.Crypto (Crypto, HASH, VRF)
import Cardano.Ledger.Hashes (EraIndependentBlockBody,
EraIndependentBlockHeader)
import Cardano.Ledger.Keys (Hash, KeyRole (BlockIssuer), VKey)
import qualified Cardano.Ledger.Keys as SL (Hash)
import Cardano.Ledger.Keys (KeyRole (BlockIssuer), VKey)
import Cardano.Protocol.TPraos.BHeader (PrevHash)
import Cardano.Slotting.Block (BlockNo)
import Cardano.Slotting.Slot (SlotNo)
Expand Down Expand Up @@ -65,7 +65,7 @@ type family ProtoCrypto proto :: Type
-------------------------------------------------------------------------------}

newtype ShelleyHash crypto = ShelleyHash
{ unShelleyHash :: SL.Hash crypto EraIndependentBlockHeader
{ unShelleyHash :: Hash (HASH crypto) EraIndependentBlockHeader
}
deriving stock (Eq, Ord, Show, Generic)
deriving anyclass (NoThunks)
Expand Down Expand Up @@ -105,7 +105,7 @@ class
where
pHeaderHash :: ShelleyProtocolHeader proto -> ShelleyHash (ProtoCrypto proto)
pHeaderPrevHash :: ShelleyProtocolHeader proto -> PrevHash (ProtoCrypto proto)
pHeaderBodyHash :: ShelleyProtocolHeader proto -> Hash (ProtoCrypto proto) EraIndependentBlockBody
pHeaderBodyHash :: ShelleyProtocolHeader proto -> Hash (HASH (ProtoCrypto proto)) EraIndependentBlockBody
pHeaderSlot :: ShelleyProtocolHeader proto -> SlotNo
pHeaderBlock :: ShelleyProtocolHeader proto -> BlockNo
pHeaderSize :: ShelleyProtocolHeader proto -> Natural
Expand Down Expand Up @@ -154,7 +154,7 @@ class ProtocolHeaderSupportsKES proto where
-- | Hash of the previous block
PrevHash crypto ->
-- | Hash of the block body to include in the header
Hash crypto EraIndependentBlockBody ->
Hash (HASH crypto) EraIndependentBlockBody ->
-- | Size of the block body
Int ->
-- | Protocol version
Expand Down

0 comments on commit c7ea146

Please sign in to comment.