From 2be89c4beb6e0affc259548edfcbc64f34ce2ec7 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Tue, 17 Sep 2024 11:47:48 -0400 Subject: [PATCH 1/3] Create `Internal` modules for `TxBody`, `MemoBytes` and others --- .../Allegra/{TxBody.hs => TxBody/Internal.hs} | 0 .../Alonzo/{TxBody.hs => TxBody/Internal.hs} | 0 .../Alonzo/{TxSeq.hs => TxSeq/Internal.hs} | 0 .../Babbage/{TxBody.hs => TxBody/Internal.hs} | 0 .../Conway/{TxBody.hs => TxBody/Internal.hs} | 0 .../Mary/{TxBody.hs => TxBody/Internal.hs} | 0 .../shelley/impl/cardano-ledger-shelley.cabal | 1 + .../Ledger/Shelley/{Tx.hs => Tx/Internal.hs} | 0 .../{MemoBytes.hs => MemoBytes/Internal.hs} | 21 ++++++++++++------- 9 files changed, 15 insertions(+), 7 deletions(-) rename eras/allegra/impl/src/Cardano/Ledger/Allegra/{TxBody.hs => TxBody/Internal.hs} (100%) rename eras/alonzo/impl/src/Cardano/Ledger/Alonzo/{TxBody.hs => TxBody/Internal.hs} (100%) rename eras/alonzo/impl/src/Cardano/Ledger/Alonzo/{TxSeq.hs => TxSeq/Internal.hs} (100%) rename eras/babbage/impl/src/Cardano/Ledger/Babbage/{TxBody.hs => TxBody/Internal.hs} (100%) rename eras/conway/impl/src/Cardano/Ledger/Conway/{TxBody.hs => TxBody/Internal.hs} (100%) rename eras/mary/impl/src/Cardano/Ledger/Mary/{TxBody.hs => TxBody/Internal.hs} (100%) rename eras/shelley/impl/src/Cardano/Ledger/Shelley/{Tx.hs => Tx/Internal.hs} (100%) rename libs/cardano-ledger-core/src/Cardano/Ledger/{MemoBytes.hs => MemoBytes/Internal.hs} (94%) diff --git a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs similarity index 100% rename from eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs rename to eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs similarity index 100% rename from eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs rename to eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs similarity index 100% rename from eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs rename to eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs similarity index 100% rename from eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs rename to eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs similarity index 100% rename from eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs rename to eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs similarity index 100% rename from eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs rename to eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs diff --git a/eras/shelley/impl/cardano-ledger-shelley.cabal b/eras/shelley/impl/cardano-ledger-shelley.cabal index 980b1d8bf45..a4aa34627c9 100644 --- a/eras/shelley/impl/cardano-ledger-shelley.cabal +++ b/eras/shelley/impl/cardano-ledger-shelley.cabal @@ -53,6 +53,7 @@ library Cardano.Ledger.Shelley.Transition Cardano.Ledger.Shelley.Translation Cardano.Ledger.Shelley.Tx + Cardano.Ledger.Shelley.Tx.Internal Cardano.Ledger.Shelley.TxAuxData Cardano.Ledger.Shelley.TxBody Cardano.Ledger.Shelley.TxCert diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs similarity index 100% rename from eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs rename to eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs similarity index 94% rename from libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs rename to libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs index b2f8c5b972a..91de6696163 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs @@ -18,13 +18,20 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} --- | MemoBytes is an abstraction for a data type that encodes its own serialization. --- The idea is to use a newtype around a MemoBytes applied to a non-memoizing type. --- For example: newtype Foo = Foo (`MemoBytes` NonMemoizingFoo) --- This way all the instances for @Foo (`Eq`, `Show`, `EncCBOR`, `DecCBOR`, `NoThunks`, Generic`)@ --- can be derived for free. MemoBytes plays an important role in the 'SafeToHash' class --- introduced in the module 'Cardano.Ledger.SafeHash' -module Cardano.Ledger.MemoBytes ( +{-# OPTIONS_HADDOCK not-home #-} + +-- | Provides MemoBytes internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +-- +-- Authors importing this module are expected to track development +-- closely. +module Cardano.Ledger.MemoBytes.Internal ( MemoBytes (Memo), MemoHashIndex, Mem, From f49975b1f3738c8704eae9911bdf8482dd85c72a Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Tue, 17 Sep 2024 12:02:01 -0400 Subject: [PATCH 2/3] Add back top-level modules for `TxBody`, `MemoBytes`, and others --- .../allegra/impl/cardano-ledger-allegra.cabal | 1 + .../impl/src/Cardano/Ledger/Allegra/TxBody.hs | 21 +++++++ .../Cardano/Ledger/Allegra/TxBody/Internal.hs | 13 +++- eras/alonzo/impl/cardano-ledger-alonzo.cabal | 2 + .../impl/src/Cardano/Ledger/Alonzo/TxBody.hs | 59 +++++++++++++++++++ .../Cardano/Ledger/Alonzo/TxBody/Internal.hs | 13 +++- .../impl/src/Cardano/Ledger/Alonzo/TxSeq.hs | 11 ++++ .../Cardano/Ledger/Alonzo/TxSeq/Internal.hs | 13 +++- .../babbage/impl/cardano-ledger-babbage.cabal | 1 + .../impl/src/Cardano/Ledger/Babbage/TxBody.hs | 59 +++++++++++++++++++ .../Cardano/Ledger/Babbage/TxBody/Internal.hs | 13 +++- eras/conway/impl/cardano-ledger-conway.cabal | 1 + .../impl/src/Cardano/Ledger/Conway/TxBody.hs | 30 ++++++++++ .../Cardano/Ledger/Conway/TxBody/Internal.hs | 11 +++- eras/mary/impl/cardano-ledger-mary.cabal | 1 + .../impl/src/Cardano/Ledger/Mary/TxBody.hs | 19 ++++++ .../Cardano/Ledger/Mary/TxBody/Internal.hs | 13 +++- .../impl/src/Cardano/Ledger/Shelley/Tx.hs | 27 +++++++++ .../src/Cardano/Ledger/Shelley/Tx/Internal.hs | 11 +++- .../cardano-ledger-core.cabal | 1 + .../src/Cardano/Ledger/MemoBytes.hs | 37 ++++++++++++ .../src/Cardano/Ledger/MemoBytes/Internal.hs | 3 - 22 files changed, 344 insertions(+), 16 deletions(-) create mode 100644 eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs create mode 100644 eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs create mode 100644 eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs create mode 100644 eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs create mode 100644 eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs create mode 100644 eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs create mode 100644 eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs create mode 100644 libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs diff --git a/eras/allegra/impl/cardano-ledger-allegra.cabal b/eras/allegra/impl/cardano-ledger-allegra.cabal index 87f90997b23..e72f5684bcb 100644 --- a/eras/allegra/impl/cardano-ledger-allegra.cabal +++ b/eras/allegra/impl/cardano-ledger-allegra.cabal @@ -34,6 +34,7 @@ library Cardano.Ledger.Allegra.Tx Cardano.Ledger.Allegra.TxAuxData Cardano.Ledger.Allegra.TxBody + Cardano.Ledger.Allegra.TxBody.Internal hs-source-dirs: src other-modules: diff --git a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs new file mode 100644 index 00000000000..80e136f9535 --- /dev/null +++ b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody.hs @@ -0,0 +1,21 @@ +module Cardano.Ledger.Allegra.TxBody ( + AllegraEraTxBody (..), + AllegraTxBody ( + AllegraTxBody, + atbAuxDataHash, + atbCerts, + atbInputs, + atbOutputs, + atbTxFee, + atbUpdate, + atbValidityInterval, + atbWithdrawals + ), + emptyAllegraTxBodyRaw, + AllegraTxBodyRaw (..), + StrictMaybe (..), + ValidityInterval (..), +) +where + +import Cardano.Ledger.Allegra.TxBody.Internal diff --git a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs index dc86fb1989c..4e929971333 100644 --- a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs +++ b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs @@ -17,8 +17,17 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} - -module Cardano.Ledger.Allegra.TxBody ( +{-# OPTIONS_HADDOCK not-home #-} + +-- | Provides Allegra TxBody internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Allegra.TxBody.Internal ( AllegraEraTxBody (..), AllegraTxBody ( AllegraTxBody, diff --git a/eras/alonzo/impl/cardano-ledger-alonzo.cabal b/eras/alonzo/impl/cardano-ledger-alonzo.cabal index befa926064c..e25cddfd988 100644 --- a/eras/alonzo/impl/cardano-ledger-alonzo.cabal +++ b/eras/alonzo/impl/cardano-ledger-alonzo.cabal @@ -44,8 +44,10 @@ library Cardano.Ledger.Alonzo.Tx Cardano.Ledger.Alonzo.TxAuxData Cardano.Ledger.Alonzo.TxBody + Cardano.Ledger.Alonzo.TxBody.Internal Cardano.Ledger.Alonzo.TxOut Cardano.Ledger.Alonzo.TxSeq + Cardano.Ledger.Alonzo.TxSeq.Internal Cardano.Ledger.Alonzo.TxWits Cardano.Ledger.Alonzo.UTxO diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs new file mode 100644 index 00000000000..9048a44c89f --- /dev/null +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs @@ -0,0 +1,59 @@ +module Cardano.Ledger.Alonzo.TxBody ( + AlonzoTxOut (..), + AlonzoEraTxOut (..), + -- Constructors are not exported for safety: + Addr28Extra, + DataHash32, + AlonzoTxBody ( + AlonzoTxBody, + atbInputs, + atbCollateral, + atbOutputs, + atbCerts, + atbWithdrawals, + atbTxFee, + atbValidityInterval, + atbUpdate, + atbReqSignerHashes, + atbMint, + atbScriptIntegrityHash, + atbAuxDataHash, + atbTxNetworkId + ), + AlonzoTxBodyRaw, + AlonzoTxBodyUpgradeError (..), + AlonzoEraTxBody (..), + ShelleyEraTxBody (..), + AllegraEraTxBody (..), + MaryEraTxBody (..), + Indexable (..), + inputs', + collateral', + outputs', + certs', + withdrawals', + txfee', + vldt', + update', + reqSignerHashes', + mint', + scriptIntegrityHash', + adHash', + txnetworkid', + getAdaOnly, + decodeDataHash32, + encodeDataHash32, + encodeAddress28, + decodeAddress28, + viewCompactTxOut, + viewTxOut, + EraIndependentScriptIntegrity, + ScriptIntegrityHash, + getAlonzoTxOutEitherAddr, + utxoEntrySize, + alonzoRedeemerPointer, + alonzoRedeemerPointerInverse, +) +where + +import Cardano.Ledger.Alonzo.TxBody.Internal diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs index 0cd630af704..5afa31c35ed 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs @@ -21,8 +21,17 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} - -module Cardano.Ledger.Alonzo.TxBody ( +{-# OPTIONS_HADDOCK not-home #-} + +-- | Provides Alonzo TxBody internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Alonzo.TxBody.Internal ( AlonzoTxOut (..), AlonzoEraTxOut (..), -- Constructors are not exported for safety: diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs new file mode 100644 index 00000000000..a5e21a708e8 --- /dev/null +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq.hs @@ -0,0 +1,11 @@ +-- | TxSeq. This is effectively the block body, which consists of a sequence of +-- transactions with segregated witness and metadata information. +module Cardano.Ledger.Alonzo.TxSeq ( + AlonzoTxSeq (AlonzoTxSeq, txSeqTxns), + TxSeq, + hashTxSeq, + hashAlonzoTxSeq, +) +where + +import Cardano.Ledger.Alonzo.TxSeq.Internal diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs index d0ab86e57df..eac5020a7e5 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs @@ -12,10 +12,17 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} +{-# OPTIONS_HADDOCK not-home #-} --- | TxSeq. This is effectively the block body, which consists of a sequence of --- transactions with segregated witness and metadata information. -module Cardano.Ledger.Alonzo.TxSeq ( +-- | Provides TxSeq internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Alonzo.TxSeq.Internal ( AlonzoTxSeq (AlonzoTxSeq, txSeqTxns), TxSeq, hashTxSeq, diff --git a/eras/babbage/impl/cardano-ledger-babbage.cabal b/eras/babbage/impl/cardano-ledger-babbage.cabal index b63ac9c63cd..41195f5ef80 100644 --- a/eras/babbage/impl/cardano-ledger-babbage.cabal +++ b/eras/babbage/impl/cardano-ledger-babbage.cabal @@ -37,6 +37,7 @@ library Cardano.Ledger.Babbage.Scripts Cardano.Ledger.Babbage.Tx Cardano.Ledger.Babbage.TxBody + Cardano.Ledger.Babbage.TxBody.Internal Cardano.Ledger.Babbage.TxOut Cardano.Ledger.Babbage.TxInfo Cardano.Ledger.Babbage.TxWits diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs new file mode 100644 index 00000000000..865ccdc2045 --- /dev/null +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody.hs @@ -0,0 +1,59 @@ +module Cardano.Ledger.Babbage.TxBody ( + BabbageTxOut ( + BabbageTxOut, + TxOutCompact, + TxOutCompactDH, + TxOutCompactDatum, + TxOutCompactRefScript + ), + allSizedOutputsBabbageTxBodyF, + babbageMinUTxOValue, + BabbageTxBody ( + BabbageTxBody, + btbInputs, + btbCollateral, + btbReferenceInputs, + btbOutputs, + btbCollateralReturn, + btbTotalCollateral, + btbCerts, + btbWithdrawals, + btbTxFee, + btbValidityInterval, + btbUpdate, + btbReqSignerHashes, + btbMint, + btbScriptIntegrityHash, + btbAuxDataHash, + btbTxNetworkId + ), + BabbageTxBodyRaw, + BabbageTxBodyUpgradeError (..), + babbageAllInputsTxBodyF, + babbageSpendableInputsTxBodyF, + BabbageEraTxBody (..), + spendInputs', + collateralInputs', + referenceInputs', + outputs', + collateralReturn', + totalCollateral', + certs', + withdrawals', + txfee', + vldt', + update', + reqSignerHashes', + mint', + scriptIntegrityHash', + adHash', + txnetworkid', + getEitherAddrBabbageTxOut, + EraIndependentScriptIntegrity, + ScriptIntegrityHash, + txOutData, + txOutDataHash, + txOutScript, +) where + +import Cardano.Ledger.Babbage.TxBody.Internal diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs index 1bbc1eb24d2..472bdcfbc47 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs @@ -18,8 +18,17 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} - -module Cardano.Ledger.Babbage.TxBody ( +{-# OPTIONS_HADDOCK not-home #-} + +-- | Provides Babbage TxBody internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Babbage.TxBody.Internal ( BabbageTxOut ( BabbageTxOut, TxOutCompact, diff --git a/eras/conway/impl/cardano-ledger-conway.cabal b/eras/conway/impl/cardano-ledger-conway.cabal index 37679658939..ff85b0953e7 100644 --- a/eras/conway/impl/cardano-ledger-conway.cabal +++ b/eras/conway/impl/cardano-ledger-conway.cabal @@ -35,6 +35,7 @@ library Cardano.Ledger.Conway.PParams Cardano.Ledger.Conway.Tx Cardano.Ledger.Conway.TxBody + Cardano.Ledger.Conway.TxBody.Internal Cardano.Ledger.Conway.TxInfo Cardano.Ledger.Conway.TxWits Cardano.Ledger.Conway.Transition diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs new file mode 100644 index 00000000000..0d35edb371d --- /dev/null +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody.hs @@ -0,0 +1,30 @@ +module Cardano.Ledger.Conway.TxBody ( + ConwayEraTxBody (..), + ConwayTxBody ( + ConwayTxBody, + ctbSpendInputs, + ctbCollateralInputs, + ctbReferenceInputs, + ctbOutputs, + ctbCollateralReturn, + ctbTotalCollateral, + ctbCerts, + ctbWithdrawals, + ctbTxfee, + ctbVldt, + ctbReqSignerHashes, + ctbMint, + ctbScriptIntegrityHash, + ctbAdHash, + ctbTxNetworkId, + ctbVotingProcedures, + ctbProposalProcedures, + ctbCurrentTreasuryValue, + ctbTreasuryDonation + ), + ConwayTxBodyRaw, + conwayTotalDepositsTxBody, + conwayProposalsDeposits, +) where + +import Cardano.Ledger.Conway.TxBody.Internal diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs index c57a43c0468..787ec578558 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs @@ -20,8 +20,17 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} +{-# OPTIONS_HADDOCK not-home #-} -module Cardano.Ledger.Conway.TxBody ( +-- | Provides Conway TxBody internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Conway.TxBody.Internal ( ConwayEraTxBody (..), ConwayTxBody ( ConwayTxBody, diff --git a/eras/mary/impl/cardano-ledger-mary.cabal b/eras/mary/impl/cardano-ledger-mary.cabal index 11f3809c728..8c06470c833 100644 --- a/eras/mary/impl/cardano-ledger-mary.cabal +++ b/eras/mary/impl/cardano-ledger-mary.cabal @@ -35,6 +35,7 @@ library Cardano.Ledger.Mary.Transition Cardano.Ledger.Mary.Translation Cardano.Ledger.Mary.TxBody + Cardano.Ledger.Mary.TxBody.Internal Cardano.Ledger.Mary.TxOut Cardano.Ledger.Mary.UTxO Cardano.Ledger.Mary.Value diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs new file mode 100644 index 00000000000..1fd9f5256f2 --- /dev/null +++ b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody.hs @@ -0,0 +1,19 @@ +module Cardano.Ledger.Mary.TxBody ( + MaryEraTxBody (..), + MaryTxBody ( + MaryTxBody, + mtbAuxDataHash, + mtbCerts, + mtbInputs, + mtbOutputs, + mtbTxFee, + mtbUpdate, + mtbValidityInterval, + mtbWithdrawals, + mtbMint + ), + MaryTxBodyRaw, +) +where + +import Cardano.Ledger.Mary.TxBody.Internal diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs index 89dc4d6e5b8..c448d81221d 100644 --- a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs +++ b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs @@ -16,8 +16,17 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} - -module Cardano.Ledger.Mary.TxBody ( +{-# OPTIONS_HADDOCK not-home #-} + +-- | Provides Mary TxBody internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Mary.TxBody.Internal ( MaryEraTxBody (..), MaryTxBody ( MaryTxBody, diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs new file mode 100644 index 00000000000..4132710162a --- /dev/null +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx.hs @@ -0,0 +1,27 @@ +module Cardano.Ledger.Shelley.Tx ( + -- * Transaction + ShelleyTx ( + ShelleyTx, + body, + wits, + auxiliaryData + ), + ShelleyTxRaw, + bodyShelleyTxL, + witsShelleyTxL, + auxDataShelleyTxL, + sizeShelleyTxF, + wireSizeShelleyTxF, + segwitTx, + mkBasicShelleyTx, + shelleyMinFeeTx, + witsFromTxWitnesses, + shelleyEqTxRaw, + + -- * Deprecated + txwitsScript, + hashMultiSigScript, +) +where + +import Cardano.Ledger.Shelley.Tx.Internal diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs index c61af5a8f75..1e67014cfa0 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs @@ -14,8 +14,17 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} +{-# OPTIONS_HADDOCK not-home #-} -module Cardano.Ledger.Shelley.Tx ( +-- | Provides Shelley Tx internals +-- +-- = Warning +-- +-- This module is considered __internal__. +-- +-- The contents of this module may change __in any way whatsoever__ +-- and __without any warning__ between minor versions of this package. +module Cardano.Ledger.Shelley.Tx.Internal ( -- * Transaction ShelleyTx ( ShelleyTx, diff --git a/libs/cardano-ledger-core/cardano-ledger-core.cabal b/libs/cardano-ledger-core/cardano-ledger-core.cabal index 1b239a67f22..1ff932901ea 100644 --- a/libs/cardano-ledger-core/cardano-ledger-core.cabal +++ b/libs/cardano-ledger-core/cardano-ledger-core.cabal @@ -49,6 +49,7 @@ library Cardano.Ledger.Keys.WitVKey Cardano.Ledger.Language Cardano.Ledger.MemoBytes + Cardano.Ledger.MemoBytes.Internal Cardano.Ledger.Metadata Cardano.Ledger.Orphans Cardano.Ledger.PoolDistr diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs new file mode 100644 index 00000000000..00473bb5c9e --- /dev/null +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes.hs @@ -0,0 +1,37 @@ +-- | MemoBytes is an abstraction for a data type that encodes its own serialization. +-- The idea is to use a newtype around a MemoBytes applied to a non-memoizing type. +-- For example: newtype Foo = Foo (`MemoBytes` NonMemoizingFoo) +-- This way all the instances for @Foo (`Eq`, `Show`, `EncCBOR`, `DecCBOR`, `NoThunks`, Generic`)@ +-- can be derived for free. MemoBytes plays an important role in the 'SafeToHash' class +-- introduced in the module 'Cardano.Ledger.SafeHash' +module Cardano.Ledger.MemoBytes ( + MemoBytes (Memo), + MemoHashIndex, + Mem, + mkMemoBytes, + getMemoBytesType, + getMemoBytesHash, + memoBytes, + shorten, + showMemo, + printMemo, + shortToLazy, + contentsEq, + + -- * Memoized + Memoized (RawType), + mkMemoized, + getMemoSafeHash, + getMemoRawType, + zipMemoRawType, + eqRawType, + getMemoRawBytes, + lensMemoRawType, + getterMemoRawType, + + -- * Raw equality + EqRaw (..), +) +where + +import Cardano.Ledger.MemoBytes.Internal diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs index 91de6696163..a4830adf9b9 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs @@ -28,9 +28,6 @@ -- -- The contents of this module may change __in any way whatsoever__ -- and __without any warning__ between minor versions of this package. --- --- Authors importing this module are expected to track development --- closely. module Cardano.Ledger.MemoBytes.Internal ( MemoBytes (Memo), MemoHashIndex, From 28abc8e197cbcc5ab6201239a87cfb5899f336f7 Mon Sep 17 00:00:00 2001 From: Sean D Gillespie Date: Thu, 26 Sep 2024 11:51:38 -0400 Subject: [PATCH 3/3] Export unsafe constructors from Internal modules --- .../allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs | 1 + eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs | 3 ++- eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs | 2 +- .../babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs | 3 ++- eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs | 3 ++- eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs | 3 ++- eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs | 3 ++- .../src/Cardano/Ledger/MemoBytes/Internal.hs | 3 +-- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs index 4e929971333..277d8a1dab3 100644 --- a/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs +++ b/eras/allegra/impl/src/Cardano/Ledger/Allegra/TxBody/Internal.hs @@ -30,6 +30,7 @@ module Cardano.Ledger.Allegra.TxBody.Internal ( AllegraEraTxBody (..), AllegraTxBody ( + .., AllegraTxBody, atbAuxDataHash, atbCerts, diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs index 5afa31c35ed..a53c2c79b6a 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody/Internal.hs @@ -38,6 +38,7 @@ module Cardano.Ledger.Alonzo.TxBody.Internal ( Addr28Extra, DataHash32, AlonzoTxBody ( + .., AlonzoTxBody, atbInputs, atbCollateral, @@ -53,7 +54,7 @@ module Cardano.Ledger.Alonzo.TxBody.Internal ( atbAuxDataHash, atbTxNetworkId ), - AlonzoTxBodyRaw, + AlonzoTxBodyRaw (..), AlonzoTxBodyUpgradeError (..), AlonzoEraTxBody (..), ShelleyEraTxBody (..), diff --git a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs index eac5020a7e5..ec6f1c2a36e 100644 --- a/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs +++ b/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxSeq/Internal.hs @@ -23,7 +23,7 @@ -- The contents of this module may change __in any way whatsoever__ -- and __without any warning__ between minor versions of this package. module Cardano.Ledger.Alonzo.TxSeq.Internal ( - AlonzoTxSeq (AlonzoTxSeq, txSeqTxns), + AlonzoTxSeq (.., AlonzoTxSeq), TxSeq, hashTxSeq, hashAlonzoTxSeq, diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs index 472bdcfbc47..ac0bc5a9cea 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/TxBody/Internal.hs @@ -39,6 +39,7 @@ module Cardano.Ledger.Babbage.TxBody.Internal ( allSizedOutputsBabbageTxBodyF, babbageMinUTxOValue, BabbageTxBody ( + .., BabbageTxBody, btbInputs, btbCollateral, @@ -57,7 +58,7 @@ module Cardano.Ledger.Babbage.TxBody.Internal ( btbAuxDataHash, btbTxNetworkId ), - BabbageTxBodyRaw, + BabbageTxBodyRaw (..), BabbageTxBodyUpgradeError (..), babbageAllInputsTxBodyF, babbageSpendableInputsTxBodyF, diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs index 787ec578558..1dcf1b6e925 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/TxBody/Internal.hs @@ -33,6 +33,7 @@ module Cardano.Ledger.Conway.TxBody.Internal ( ConwayEraTxBody (..), ConwayTxBody ( + .., ConwayTxBody, ctbSpendInputs, ctbCollateralInputs, @@ -54,7 +55,7 @@ module Cardano.Ledger.Conway.TxBody.Internal ( ctbCurrentTreasuryValue, ctbTreasuryDonation ), - ConwayTxBodyRaw, + ConwayTxBodyRaw (..), conwayTotalDepositsTxBody, conwayProposalsDeposits, ) where diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs index c448d81221d..474cf452654 100644 --- a/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs +++ b/eras/mary/impl/src/Cardano/Ledger/Mary/TxBody/Internal.hs @@ -29,6 +29,7 @@ module Cardano.Ledger.Mary.TxBody.Internal ( MaryEraTxBody (..), MaryTxBody ( + .., MaryTxBody, mtbAuxDataHash, mtbCerts, @@ -40,7 +41,7 @@ module Cardano.Ledger.Mary.TxBody.Internal ( mtbWithdrawals, mtbMint ), - MaryTxBodyRaw, + MaryTxBodyRaw (..), ) where diff --git a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs index 1e67014cfa0..3290acae49a 100644 --- a/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs +++ b/eras/shelley/impl/src/Cardano/Ledger/Shelley/Tx/Internal.hs @@ -27,12 +27,13 @@ module Cardano.Ledger.Shelley.Tx.Internal ( -- * Transaction ShelleyTx ( + .., ShelleyTx, body, wits, auxiliaryData ), - ShelleyTxRaw, + ShelleyTxRaw (..), bodyShelleyTxL, witsShelleyTxL, auxDataShelleyTxL, diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs index a4830adf9b9..eeb12d0c9c0 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/MemoBytes/Internal.hs @@ -17,7 +17,6 @@ {-# LANGUAGE TypeFamilyDependencies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} - {-# OPTIONS_HADDOCK not-home #-} -- | Provides MemoBytes internals @@ -29,7 +28,7 @@ -- The contents of this module may change __in any way whatsoever__ -- and __without any warning__ between minor versions of this package. module Cardano.Ledger.MemoBytes.Internal ( - MemoBytes (Memo), + MemoBytes (.., Memo), MemoHashIndex, Mem, mkMemoBytes,