Skip to content

Commit 5ff9f4f

Browse files
committed
Remove heapwords from cardano-ledger-core
1 parent 855f74e commit 5ff9f4f

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

libs/cardano-ledger-core/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## 1.18.0.0
44

5+
* Remove `HeapWords` instances for: #5001
6+
- `Coin`
7+
- `DeltaCoin`
8+
- `CompactFormCoin`
9+
- `CompactFormDeltaCoin`
10+
- `SafeHash`
11+
- `StrictMaybe DataHash`
12+
- `TxId`
13+
- `TxIn`
514
* Add `addCompactCoin` to `Cardano.Ledger.Coin` and deprecate `Cardano.Ledger.UMap.addCompact`
615
in its favor
716
* Move `sumCompactCoin` to `Cardano.Ledger.Coin`

libs/cardano-ledger-core/cardano-ledger-core.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ library
118118
data-default >=0.8,
119119
deepseq,
120120
groups,
121-
heapwords,
122121
iproute,
123122
measures,
124123
mempack,

libs/cardano-ledger-core/src/Cardano/Ledger/Coin.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ module Cardano.Ledger.Coin (
3535
)
3636
where
3737

38-
import Cardano.HeapWords (HeapWords)
3938
import Cardano.Ledger.BaseTypes (
4039
HasZero (..),
4140
Inject (..),
@@ -83,15 +82,15 @@ newtype Coin = Coin {unCoin :: Integer}
8382
)
8483
deriving (Show) via Quiet Coin
8584
deriving (Semigroup, Monoid, Group, Abelian) via Sum Integer
86-
deriving newtype (PartialOrd, ToCBOR, EncCBOR, HeapWords)
85+
deriving newtype (PartialOrd, ToCBOR, EncCBOR)
8786

8887
instance FromCBOR Coin where
8988
fromCBOR = Coin . toInteger <$> Plain.decodeWord64
9089

9190
instance DecCBOR Coin
9291

9392
newtype DeltaCoin = DeltaCoin Integer
94-
deriving (Eq, Ord, Generic, Enum, NoThunks, HeapWords)
93+
deriving (Eq, Ord, Generic, Enum, NoThunks)
9594
deriving (Show) via Quiet DeltaCoin
9695
deriving (Semigroup, Monoid, Group, Abelian) via Sum Integer
9796
deriving newtype (PartialOrd, NFData, ToCBOR, DecCBOR, EncCBOR, ToJSON, FromJSON)
@@ -124,7 +123,7 @@ rationalToCoinViaCeiling = Coin . ceiling
124123

125124
instance Compactible Coin where
126125
newtype CompactForm Coin = CompactCoin {unCompactCoin :: Word64}
127-
deriving (Eq, Show, NoThunks, NFData, HeapWords, Prim, Ord, ToCBOR, ToJSON, FromJSON)
126+
deriving (Eq, Show, NoThunks, NFData, Prim, Ord, ToCBOR, ToJSON, FromJSON)
128127
deriving (Semigroup, Monoid, Group, Abelian) via Sum Word64
129128

130129
toCompact (Coin c) = CompactCoin <$> integerToWord64 c
@@ -145,7 +144,7 @@ instance MemPack (CompactForm Coin) where
145144

146145
instance Compactible DeltaCoin where
147146
newtype CompactForm DeltaCoin = CompactDeltaCoin Word64
148-
deriving (Eq, Show, NoThunks, NFData, HeapWords, ToJSON, Prim)
147+
deriving (Eq, Show, NoThunks, NFData, ToJSON, Prim)
149148

150149
toCompact (DeltaCoin dc) = CompactDeltaCoin <$> integerToWord64 dc
151150
fromCompact (CompactDeltaCoin cdc) = DeltaCoin (unCoin (word64ToCoin cdc))

libs/cardano-ledger-core/src/Cardano/Ledger/Hashes.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ where
8282
import qualified Cardano.Crypto.DSIGN as DSIGN
8383
import qualified Cardano.Crypto.Hash as Hash
8484
import qualified Cardano.Crypto.VRF as VRF
85-
import Cardano.HeapWords (HeapWords (..))
8685
import Cardano.Ledger.Binary (
8786
DecCBOR (..),
8887
EncCBOR (..),
@@ -332,7 +331,6 @@ newtype SafeHash i = SafeHash (Hash.Hash HASH i)
332331
, NoThunks
333332
, NFData
334333
, SafeToHash
335-
, HeapWords
336334
, ToCBOR
337335
, FromCBOR
338336
, EncCBOR

libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/Data.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
{-# LANGUAGE TypeFamilies #-}
1717
{-# LANGUAGE UndecidableInstances #-}
1818
{-# LANGUAGE ViewPatterns #-}
19-
-- This is needed for the `HeapWords (StrictMaybe (DataHash c))` instance
20-
{-# OPTIONS_GHC -fno-warn-orphans #-}
2119

2220
module Cardano.Ledger.Plutus.Data (
2321
PlutusData (..),
@@ -39,7 +37,6 @@ module Cardano.Ledger.Plutus.Data (
3937
)
4038
where
4139

42-
import Cardano.HeapWords (HeapWords (..), heapWords0, heapWords1)
4340
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
4441
import Cardano.Ledger.Binary (
4542
DecCBOR (..),
@@ -189,10 +186,6 @@ dataHashSize :: StrictMaybe DataHash -> Integer
189186
dataHashSize SNothing = 0
190187
dataHashSize (SJust _) = 10
191188

192-
instance HeapWords (StrictMaybe DataHash) where
193-
heapWords SNothing = heapWords0
194-
heapWords (SJust a) = heapWords1 a
195-
196189
-- ============================================================================
197190
-- Datum
198191

libs/cardano-ledger-core/src/Cardano/Ledger/TxIn.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ module Cardano.Ledger.TxIn (
2424
where
2525

2626
import Cardano.Crypto.Hash.Class (hashToTextAsHex)
27-
import Cardano.HeapWords (HeapWords (..))
28-
import qualified Cardano.HeapWords as HW
2927
import Cardano.Ledger.BaseTypes (TxIx (..), mkTxIxPartial)
3028
import Cardano.Ledger.Binary (
3129
DecCBOR (..),
@@ -61,11 +59,7 @@ import NoThunks.Class (NoThunks (..))
6159
-- | A unique ID of a transaction, which is computable from the transaction.
6260
newtype TxId = TxId {unTxId :: SafeHash EraIndependentTxBody}
6361
deriving (Show, Eq, Ord, Generic)
64-
deriving newtype (NoThunks, ToJSON, FromJSON, HeapWords, EncCBOR, DecCBOR, NFData, MemPack)
65-
66-
instance HeapWords TxIn where
67-
heapWords (TxIn txId _) =
68-
2 + HW.heapWords txId + 1 {- txIx -}
62+
deriving newtype (NoThunks, ToJSON, FromJSON, EncCBOR, DecCBOR, NFData, MemPack)
6963

7064
instance ToJSON TxIn where
7165
toJSON = toJSON . txInToText

0 commit comments

Comments
 (0)