From ba003e005bbb211f3e73f0476679c0751b8d4df3 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Fri, 17 Jan 2025 20:18:58 -0700 Subject: [PATCH] Drop dependency on `cardano-prelude` Reflect usage of `unsafeIndex` with the bounds of `bytestring`. `bytestring-0.11.3.0` was accidentally released with `unsafeIndex` hidden from the export list. This issues was promptly fixed in `bytestring-0.11.4.0`. So, we just need to exclude the affected version in cabal file instead of rely on some custom implementation of the function in a package that we don't normally use in ledger. --- libs/cardano-ledger-core/cardano-ledger-core.cabal | 3 +-- libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/cardano-ledger-core/cardano-ledger-core.cabal b/libs/cardano-ledger-core/cardano-ledger-core.cabal index 8c4566b48ca..4af07250ca9 100644 --- a/libs/cardano-ledger-core/cardano-ledger-core.cabal +++ b/libs/cardano-ledger-core/cardano-ledger-core.cabal @@ -96,7 +96,7 @@ library base16-bytestring, base64-bytestring, binary, - bytestring, + bytestring >=0.10 && <0.11.3 || >=0.11.4, cardano-crypto, cardano-crypto-class ^>=2.2, cardano-crypto-praos ^>=2.2, @@ -104,7 +104,6 @@ library cardano-data ^>=1.2, cardano-ledger-binary ^>=1.6, cardano-ledger-byron, - cardano-prelude, cardano-slotting, cardano-strict-containers, containers, diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs index e6702a1ebf3..c6fb48293d2 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs @@ -90,7 +90,6 @@ import Cardano.Ledger.Credential ( ) import Cardano.Ledger.Hashes (ScriptHash (..)) import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..)) -import Cardano.Prelude (unsafeShortByteStringIndex) import Control.DeepSeq (NFData) import Control.Monad (guard, unless, when) import Control.Monad.Trans.Fail (FailT (..), runFail) @@ -109,6 +108,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Lazy as BSL import Data.ByteString.Short as SBS (ShortByteString, fromShort, index, length, toShort) +import Data.ByteString.Short.Internal as SBS (unsafeIndex) import qualified Data.ByteString.Unsafe as BS (unsafeDrop, unsafeIndex, unsafeTake) import Data.Default (Default (..)) import Data.Function (fix) @@ -466,7 +466,7 @@ class AddressBuffer b where instance AddressBuffer ShortByteString where bufLength = SBS.length {-# INLINE bufLength #-} - bufUnsafeIndex = unsafeShortByteStringIndex + bufUnsafeIndex = SBS.unsafeIndex {-# INLINE bufUnsafeIndex #-} bufToByteString = SBS.fromShort {-# INLINE bufToByteString #-}