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

Fix benchmarks #2669

Merged
merged 2 commits into from
Mar 2, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install libsodium23 libsodium-dev
sudo apt-get -y install libsodium23 libsodium-dev libsecp256k1-dev
lehins marked this conversation as resolved.
Show resolved Hide resolved
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove

Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ test-show-details: streaming
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 41545ba3ac6b3095966316a99883d678b5ab8da8
--sha256: 0icq9y3nnl42fz536da84414av36g37894qnyw4rk3qkalksqwir
tag: fa42b562b514b895231b8710e4f228438a5cbd3a
--sha256: 0pqkrsynamaa2y69g68f07ghpqkynsi58xlrdgl5mqhc37607pb9
subdir:
base-deriving-via
binary
Expand Down
1 change: 0 additions & 1 deletion eras/alonzo/test

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Codec.CBOR.Decoding
TypeMapLenIndef
),
)
import Control.DeepSeq
import Data.Coders
import Data.Map.Strict (Map)
import Data.MemoBytes
Expand Down Expand Up @@ -67,6 +68,8 @@ deriving instance
(Core.ChainData (Core.Script era)) =>
NoThunks (AuxiliaryDataRaw era)

instance NFData (Core.Script era) => NFData (AuxiliaryDataRaw era)

newtype AuxiliaryData era = AuxiliaryDataWithBytes (MemoBytes (AuxiliaryDataRaw era))
deriving (Generic, Typeable)
deriving newtype (ToCBOR, SafeToHash)
Expand All @@ -85,6 +88,8 @@ deriving newtype instance
(Era era, Core.ChainData (Core.Script era)) =>
NoThunks (AuxiliaryData era)

deriving newtype instance NFData (Core.Script era) => NFData (AuxiliaryData era)

pattern AuxiliaryData ::
( Core.AnnotatedData (Core.Script era),
Ord (Core.Script era)
Expand Down
1 change: 0 additions & 1 deletion eras/shelley-ma/shelley-ma-test

This file was deleted.

1 change: 0 additions & 1 deletion eras/shelley/chain-and-ledger/formal-spec

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Ledger.Shelley.Address.Bootstrap
( BootstrapWitness
Expand Down Expand Up @@ -56,6 +57,7 @@ import Cardano.Ledger.Keys
import qualified Cardano.Ledger.Keys as Keys
import Cardano.Ledger.Serialization (decodeRecordNamed)
import Cardano.Prelude (panic)
import Control.DeepSeq (NFData)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as LBS
import Data.Coerce (coerce)
Expand All @@ -69,7 +71,7 @@ import Quiet
newtype ChainCode = ChainCode {unChainCode :: ByteString}
deriving (Eq, Generic)
deriving (Show) via Quiet ChainCode
deriving newtype (NoThunks, ToCBOR, FromCBOR)
deriving newtype (NoThunks, ToCBOR, FromCBOR, NFData)

data BootstrapWitness crypto = BootstrapWitness'
{ bwKey' :: !(VKey 'Witness crypto),
Expand All @@ -88,6 +90,13 @@ deriving instance CC.Crypto crypto => Show (BootstrapWitness crypto)

deriving instance CC.Crypto crypto => Eq (BootstrapWitness crypto)

instance
( CC.Crypto era,
NFData (DSIGN.VerKeyDSIGN (DSIGN era)),
NFData (DSIGN.SigDSIGN (DSIGN era))
) =>
NFData (BootstrapWitness era)

deriving via
(AllowThunksIn '["bwBytes"] (BootstrapWitness crypto))
instance
Expand Down
18 changes: 15 additions & 3 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
Expand Down Expand Up @@ -40,6 +41,7 @@ import Cardano.Prelude (cborError)
import Codec.CBOR.Decoding (Decoder)
import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Encoding as CBOR
import Control.DeepSeq (NFData (rnf), deepseq)
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
Expand All @@ -53,23 +55,33 @@ import NoThunks.Class (AllowThunksIn (..), NoThunks (..))

-- | A generic metadatum type.
data Metadatum
= -- TODO make strict:
Map [(Metadatum, Metadatum)]
| List [Metadatum]
= Map ![(Metadatum, Metadatum)]
| List ![Metadatum]
| I !Integer
| B !BS.ByteString
| S !T.Text
deriving stock (Show, Eq, Ord, Generic)

instance NoThunks Metadatum

instance NFData Metadatum where
rnf = \case
Map m -> rnf m
List l -> rnf l
I _ -> ()
B _ -> ()
S _ -> ()

data Metadata era = Metadata'
{ mdMap :: Map Word64 Metadatum,
mdBytes :: LBS.ByteString
}
deriving (Eq, Show, Ord, Generic)
deriving (NoThunks) via AllowThunksIn '["mdBytes"] (Metadata era)

instance NFData (Metadata era) where
rnf m = mdMap m `deepseq` rnf (mdBytes m)

-- Usually we derive SafetToHash instances, but since Metadata preserves its serialisation
-- bytes we can just extract them here, and make an explicit SafeToHash instance.

Expand Down
29 changes: 1 addition & 28 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

module Cardano.Ledger.Shelley.Orphans where

import Cardano.Binary (FromCBOR, ToCBOR)
import Cardano.Crypto.Hash (Hash (..))
import qualified Cardano.Crypto.Hash as Hash
import qualified Cardano.Crypto.Hash.Class as HS
Expand All @@ -15,19 +14,15 @@ import qualified Cardano.Crypto.Wallet as WC
import Cardano.Ledger.BaseTypes (Network (..))
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Keys (KeyHash (..))
import Cardano.Ledger.Slot (EpochNo)
import Cardano.Prelude (readEither)
import Cardano.Slotting.Slot (EpochSize (..), WithOrigin (..))
import Control.DeepSeq (NFData (rnf))
import Control.DeepSeq (NFData)
import Data.Aeson
import qualified Data.ByteString as Long (ByteString, empty)
import qualified Data.ByteString.Lazy as Lazy (ByteString, empty)
import qualified Data.ByteString.Short as Short (ShortByteString, empty, pack)
import Data.Default.Class (Default (..))
import Data.Foldable
import Data.IP (IPv4, IPv6)
import Data.Proxy
import Data.Sequence.Strict (StrictSeq, fromList, fromStrict)
import qualified Data.Sequence.Strict as SS
import qualified Data.Text as Text
import NoThunks.Class (NoThunks (..))
Expand All @@ -50,12 +45,6 @@ instance FromJSON IPv6 where
instance ToJSON IPv6 where
toJSON = toJSON . show

instance FromJSON a => FromJSON (StrictSeq a) where
parseJSON = fmap fromList . parseJSON

instance ToJSON a => ToJSON (StrictSeq a) where
toJSON = toJSON . toList

instance NoThunks IPv4

instance NoThunks IPv6
Expand All @@ -64,16 +53,6 @@ instance NFData IPv4

instance NFData IPv6

{- The following NFData instances probably belong in base -}
instance NFData EpochNo

instance NFData (StrictSeq a) where
rnf x = case fromStrict x of _any -> ()

-- By defintion it is strict, so as long as the (hidden) constructor is evident, it is in normal form

instance NFData a => NFData (WithOrigin a)

instance NoThunks WC.XSignature where
wNoThunks ctxt s = wNoThunks ctxt (WC.unXSignature s)
showTypeOf _proxy = "XSignature"
Expand Down Expand Up @@ -109,9 +88,3 @@ instance HS.HashAlgorithm h => Default (Hash h b) where

instance Default Bool where
def = False

deriving newtype instance ToCBOR EpochSize

deriving newtype instance NFData EpochSize

deriving newtype instance FromCBOR EpochSize
5 changes: 5 additions & 0 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Scripts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Cardano.Ledger.Hashes (ScriptHash (..))
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (Witness))
import Cardano.Ledger.SafeHash (SafeToHash (..))
import Cardano.Ledger.Serialization (decodeList, decodeRecordSum, encodeFoldable)
import Control.DeepSeq (NFData)
import Data.ByteString.Short (ShortByteString)
import Data.Coders (Encode (..), (!>))
import Data.MemoBytes
Expand Down Expand Up @@ -72,10 +73,14 @@ data MultiSigRaw crypto
deriving (Show, Eq, Ord, Generic)
deriving anyclass (NoThunks)

instance NFData (MultiSigRaw era)

newtype MultiSig crypto = MultiSigConstr (MemoBytes (MultiSigRaw crypto))
deriving (Eq, Ord, Show, Generic)
deriving newtype (ToCBOR, NoThunks, SafeToHash)

deriving newtype instance NFData (MultiSig era)

getMultiSigBytes :: MultiSig crypto -> ShortByteString
getMultiSigBytes (MultiSigConstr (Memo _ bytes)) = bytes

Expand Down
23 changes: 23 additions & 0 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import Cardano.Ledger.Shelley.TxBody
witKeyHash,
)
import Cardano.Ledger.TxIn (TxId (..), TxIn (..))
import Control.DeepSeq (NFData)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Short as SBS
import Data.Coders
Expand Down Expand Up @@ -116,6 +117,13 @@ data TxRaw era = TxRaw
}
deriving (Generic, Typeable)

instance
( NFData (Core.TxBody era),
NFData (Core.Witnesses era),
NFData (Core.AuxiliaryData era)
) =>
NFData (TxRaw era)

deriving instance
( Era era,
Eq (Core.AuxiliaryData era),
Expand Down Expand Up @@ -143,6 +151,13 @@ instance
newtype Tx era = TxConstr (MemoBytes (TxRaw era))
deriving newtype (SafeToHash, ToCBOR)

deriving newtype instance
( NFData (Core.TxBody era),
NFData (Core.Witnesses era),
NFData (Core.AuxiliaryData era)
) =>
NFData (Tx era)

deriving newtype instance Eq (Tx era)

deriving newtype instance
Expand Down Expand Up @@ -297,6 +312,14 @@ deriving instance

deriving instance Era era => Generic (WitnessSetHKD Identity era)

instance
( Era era,
NFData (Core.Script era),
NFData (WitVKey 'Witness (Crypto era)),
NFData (BootstrapWitness (Crypto era))
) =>
NFData (WitnessSetHKD Identity era)

deriving via
AllowThunksIn
'[ "txWitsBytes"
Expand Down
7 changes: 5 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ type TransTxBody (c :: Type -> Constraint) era =
)

deriving instance
(CC.Crypto (Crypto era), NFData (Core.PParamsDelta era)) =>
(NFData (Core.TxOut era), CC.Crypto (Crypto era), NFData (Core.PParamsDelta era)) =>
NFData (TxBodyRaw era)

deriving instance (Era era, TransTxBody Eq era) => Eq (TxBodyRaw era)
Expand Down Expand Up @@ -732,7 +732,7 @@ deriving newtype instance
(TransTxBody NoThunks era, Typeable era) => NoThunks (TxBody era)

deriving newtype instance
(CC.Crypto (Crypto era), NFData (Core.PParamsDelta era)) =>
(NFData (Core.TxOut era), CC.Crypto (Crypto era), NFData (Core.PParamsDelta era)) =>
NFData (TxBody era)

deriving instance (Era era, TransTxBody Show era) => Show (TxBody era)
Expand Down Expand Up @@ -843,6 +843,9 @@ deriving instance CC.Crypto crypto => Show (WitVKey kr crypto)

deriving instance CC.Crypto crypto => Eq (WitVKey kr crypto)

instance NFData (WitVKey kr crypto) where
rnf (WitVKey' _ _ _ bytes) = rnf bytes

deriving via
(AllowThunksIn '["wvkBytes"] (WitVKey kr crypto))
instance
Expand Down
1 change: 0 additions & 1 deletion eras/shelley/pool-ranking

This file was deleted.

Loading