Skip to content

Commit 9326941

Browse files
authored
Merge pull request #5332 from IntersectMBO/lehins/remove-size-from-enc-cbor
Remove size estimation from `EncCBOR` and `EncCBORGroup`
2 parents fd38306 + 2b8d0a6 commit 9326941

File tree

111 files changed

+338
-1427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+338
-1427
lines changed

eras/alonzo/impl/cardano-ledger-alonzo.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ library
8686
cardano-crypto-class,
8787
cardano-data ^>=1.2.1,
8888
cardano-ledger-allegra ^>=1.9,
89-
cardano-ledger-binary ^>=1.7,
89+
cardano-ledger-binary ^>=1.8,
9090
cardano-ledger-core:{cardano-ledger-core, internal} ^>=1.19,
9191
cardano-ledger-mary ^>=1.9,
9292
cardano-ledger-shelley ^>=1.17,

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/BlockBody/Internal.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import Cardano.Ledger.Binary (
4242
encodeFoldableEncoder,
4343
encodeFoldableMapEncoder,
4444
encodePreEncoded,
45-
encodedSizeExpr,
4645
serialize,
4746
withSlice,
4847
)
@@ -54,7 +53,6 @@ import Data.ByteString.Builder (Builder, shortByteString, toLazyByteString)
5453
import qualified Data.ByteString.Lazy as BSL
5554
import Data.Coerce (coerce)
5655
import Data.Maybe.Strict (maybeToStrictMaybe, strictMaybeToMaybe)
57-
import Data.Proxy (Proxy (..))
5856
import qualified Data.Sequence as Seq
5957
import Data.Sequence.Strict (StrictSeq)
6058
import qualified Data.Sequence.Strict as StrictSeq
@@ -178,11 +176,6 @@ instance Era era => EncCBORGroup (AlonzoBlockBody era) where
178176
encodePreEncoded $
179177
BSL.toStrict $
180178
bodyBytes <> witsBytes <> metadataBytes <> invalidBytes
181-
encodedGroupSizeExpr size _proxy =
182-
encodedSizeExpr size (Proxy :: Proxy ByteString)
183-
+ encodedSizeExpr size (Proxy :: Proxy ByteString)
184-
+ encodedSizeExpr size (Proxy :: Proxy ByteString)
185-
+ encodedSizeExpr size (Proxy :: Proxy ByteString)
186179
listLen _ = 4
187180
listLenBound _ = 4
188181

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Bbody.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,7 @@ deriving anyclass instance
146146
(Era era, NoThunks (PredicateFailure (EraRule "LEDGERS" era))) =>
147147
NoThunks (AlonzoBbodyPredFailure era)
148148

149-
instance
150-
( Typeable era
151-
, EncCBOR (ShelleyBbodyPredFailure era)
152-
) =>
153-
EncCBOR (AlonzoBbodyPredFailure era)
154-
where
149+
instance EncCBOR (ShelleyBbodyPredFailure era) => EncCBOR (AlonzoBbodyPredFailure era) where
155150
encCBOR (ShelleyInAlonzoBbodyPredFailure x) = encode (Sum ShelleyInAlonzoBbodyPredFailure 0 !> To x)
156151
encCBOR (TooManyExUnits m) = encode (Sum TooManyExUnits 1 !> To m)
157152

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ instance
180180

181181
instance
182182
( AlonzoEraScript era
183-
, EncCBOR (TxCert era)
184183
, EncCBOR (PredicateFailure (EraRule "UTXO" era))
185-
, Typeable (TxAuxData era)
186184
) =>
187185
EncCBOR (AlonzoUtxowPredFailure era)
188186
where

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ import qualified Data.Map.Strict as Map
116116
import Data.Maybe (fromJust, isJust)
117117
import Data.MemPack
118118
import Data.Typeable
119-
import Data.Word (Word16, Word32, Word8)
119+
import Data.Word (Word32)
120120
import GHC.Generics (Generic)
121121
import GHC.Stack
122122
import NoThunks.Class (NoThunks (..))
@@ -331,7 +331,6 @@ instance
331331
instance
332332
( forall a b. (EncCBOR a, EncCBOR b) => EncCBOR (f a b)
333333
, Era era
334-
, Typeable f
335334
, EncCBOR (TxCert era)
336335
) =>
337336
EncCBORGroup (AlonzoPlutusPurpose f era)
@@ -343,9 +342,6 @@ instance
343342
AlonzoMinting p -> encodeWord8 1 <> encCBOR p
344343
AlonzoCertifying p -> encodeWord8 2 <> encCBOR p
345344
AlonzoRewarding p -> encodeWord8 3 <> encCBOR p
346-
encodedGroupSizeExpr size_ _proxy =
347-
encodedSizeExpr size_ (Proxy :: Proxy Word8)
348-
+ encodedSizeExpr size_ (Proxy :: Proxy Word16)
349345

350346
instance
351347
( forall a b. (DecCBOR a, DecCBOR b) => DecCBOR (f a b)
@@ -368,7 +364,6 @@ deriving via
368364
instance
369365
( forall a b. (EncCBOR a, EncCBOR b) => EncCBOR (f a b)
370366
, Era era
371-
, Typeable f
372367
, EncCBOR (TxCert era)
373368
) =>
374369
EncCBOR (AlonzoPlutusPurpose f era)

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxWits.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ import qualified Data.MapExtras as Map (fromElems)
135135
import Data.Maybe (mapMaybe)
136136
import Data.Set (Set)
137137
import qualified Data.Set as Set
138-
import Data.Typeable (Typeable)
139138
import GHC.Generics (Generic)
140139
import Lens.Micro
141140
import NoThunks.Class (NoThunks)
@@ -312,7 +311,7 @@ newtype TxDatsRaw era = TxDatsRaw {unTxDatsRaw :: Map DataHash (Data era)}
312311

313312
deriving instance Show (TxDatsRaw era)
314313

315-
instance (Typeable era, EncCBOR (Data era)) => EncCBOR (TxDatsRaw era) where
314+
instance EncCBOR (Data era) => EncCBOR (TxDatsRaw era) where
316315
encCBOR = encodeWithSetTag . Map.elems . unTxDatsRaw
317316

318317
pattern TxDats' :: Map DataHash (Data era) -> TxDats era

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/Twiddle.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Cardano.Ledger.TxIn (TxIn)
2121
import Cardano.Ledger.Val (Val)
2222
import Codec.CBOR.Term (Term (..))
2323
import Data.Maybe (catMaybes)
24-
import Data.Typeable (Typeable)
2524
import Test.Cardano.Ledger.Alonzo.Arbitrary ()
2625
import Test.Cardano.Ledger.Binary.Twiddle
2726
import Test.Cardano.Ledger.Common
@@ -50,7 +49,7 @@ instance Twiddle MultiAsset where
5049
instance Twiddle ScriptIntegrityHash where
5150
twiddle v = twiddle v . toTerm v
5251

53-
instance Typeable t => Twiddle (KeyHash t) where
52+
instance Twiddle (KeyHash t) where
5453
twiddle v = twiddle v . toTerm v
5554

5655
instance Twiddle Network where

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Translation/TranslationInstance.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ instance DecCBOR VersionedTxInfo where
177177

178178
instance
179179
( Era era
180-
, EncCBOR (PParams era)
181180
, EncCBOR (UTxO era)
182181
, EncCBOR (Core.Tx era)
183182
) =>

eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,7 @@ instance
498498
, EncCBOR (TxOut era)
499499
, EncCBOR (Value era)
500500
, EncCBOR (PredicateFailure (EraRule "UTXOS" era))
501-
, EncCBOR (PredicateFailure (EraRule "UTXO" era))
502-
, EncCBOR (Script era)
503501
, EncCBOR TxIn
504-
, Typeable (TxAuxData era)
505502
) =>
506503
EncCBOR (BabbageUtxoPredFailure era)
507504
where

eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxow.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ deriving instance
157157

158158
instance
159159
( AlonzoEraScript era
160-
, EncCBOR (TxOut era)
161-
, EncCBOR (TxCert era)
162-
, EncCBOR (Value era)
163-
, EncCBOR (PredicateFailure (EraRule "UTXOS" era))
164160
, EncCBOR (PredicateFailure (EraRule "UTXO" era))
165-
, Typeable (TxAuxData era)
166161
) =>
167162
EncCBOR (BabbageUtxowPredFailure era)
168163
where

0 commit comments

Comments
 (0)