Skip to content

Commit 83219ea

Browse files
committed
WIP Ledger: introduce Core.Tx levels
1 parent a4bb75e commit 83219ea

File tree

10 files changed

+30
-28
lines changed

10 files changed

+30
-28
lines changed

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ class
123123
SL.LedgerEnv era ->
124124
SL.LedgerState era ->
125125
WhetherToIntervene ->
126-
Core.Tx era ->
126+
Core.Tx TopTx era ->
127127
Except
128128
(SL.ApplyTxError era)
129129
( SL.LedgerState era
130-
, SL.Validated (Core.Tx era)
130+
, SL.Validated (Core.Tx TopTx era)
131131
)
132132

133133
-- | Whether the era has an instance of 'CG.ConwayEraGov'
@@ -148,11 +148,11 @@ defaultApplyShelleyBasedTx ::
148148
SL.LedgerEnv era ->
149149
SL.LedgerState era ->
150150
WhetherToIntervene ->
151-
Core.Tx era ->
151+
Core.Tx TopTx era ->
152152
Except
153153
(SL.ApplyTxError era)
154154
( SL.LedgerState era
155-
, SL.Validated (Core.Tx era)
155+
, SL.Validated (Core.Tx TopTx era)
156156
)
157157
defaultApplyShelleyBasedTx globals ledgerEnv mempoolState _wti tx =
158158
liftEither $
@@ -210,11 +210,11 @@ applyAlonzoBasedTx ::
210210
SL.LedgerEnv era ->
211211
SL.LedgerState era ->
212212
WhetherToIntervene ->
213-
Core.Tx era ->
213+
Core.Tx TopTx era ->
214214
Except
215215
(SL.ApplyTxError era)
216216
( SL.LedgerState era
217-
, SL.Validated (Core.Tx era)
217+
, SL.Validated (Core.Tx TopTx era)
218218
)
219219
applyAlonzoBasedTx globals ledgerEnv mempoolState wti tx = do
220220
(mempoolState', vtx) <-

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Forge.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
module Ouroboros.Consensus.Shelley.Ledger.Forge (forgeShelleyBlock) where
88

9-
import qualified Cardano.Ledger.Core as Core (Tx)
9+
import qualified Cardano.Ledger.Core as Core (TopTx, Tx)
1010
import qualified Cardano.Ledger.Core as SL (hashBlockBody, mkBasicBlockBody, txSeqBlockBodyL)
1111
import qualified Cardano.Ledger.Shelley.API as SL (Block (..), extractTx)
1212
import qualified Cardano.Ledger.Shelley.BlockBody as SL (bBodySize)
@@ -85,7 +85,7 @@ forgeShelleyBlock
8585

8686
actualBodySize = SL.bBodySize protocolVersion body
8787

88-
extractTx :: Validated (GenTx (ShelleyBlock proto era)) -> Core.Tx era
88+
extractTx :: Validated (GenTx (ShelleyBlock proto era)) -> Core.Tx Core.TopTx era
8989
extractTx (ShelleyValidatedTx _txid vtx) = SL.extractTx vtx
9090

9191
prevHash :: SL.PrevHash

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import qualified Cardano.Crypto.Hash as Hash
4545
import qualified Cardano.Ledger.Allegra.Rules as AllegraEra
4646
import Cardano.Ledger.Alonzo.Core
4747
( BlockBody
48+
, TopTx
4849
, Tx
4950
, allInputsTxBodyF
5051
, bodyTxL
@@ -112,7 +113,7 @@ import Ouroboros.Consensus.Util (ShowProxy (..), coerceSet)
112113
import Ouroboros.Consensus.Util.Condense
113114
import Ouroboros.Network.Block (unwrapCBORinCBOR, wrapCBORinCBOR)
114115

115-
data instance GenTx (ShelleyBlock proto era) = ShelleyTx !SL.TxId !(Tx era)
116+
data instance GenTx (ShelleyBlock proto era) = ShelleyTx !SL.TxId !(Tx TopTx era)
116117
deriving stock Generic
117118

118119
deriving instance ShelleyBasedEra era => NoThunks (GenTx (ShelleyBlock proto era))
@@ -126,7 +127,7 @@ instance
126127
data instance Validated (GenTx (ShelleyBlock proto era))
127128
= ShelleyValidatedTx
128129
!SL.TxId
129-
!(SL.Validated (Tx era))
130+
!(SL.Validated (Tx TopTx era))
130131
deriving stock Generic
131132

132133
deriving instance ShelleyBasedEra era => NoThunks (Validated (GenTx (ShelleyBlock proto era)))
@@ -186,13 +187,14 @@ instance
186187
coerceSet
187188
(tx ^. bodyTxL . allInputsTxBodyF)
188189

189-
mkShelleyTx :: forall era proto. ShelleyBasedEra era => Tx era -> GenTx (ShelleyBlock proto era)
190+
mkShelleyTx ::
191+
forall era proto. ShelleyBasedEra era => Tx TopTx era -> GenTx (ShelleyBlock proto era)
190192
mkShelleyTx tx = ShelleyTx (txIdTx tx) tx
191193

192194
mkShelleyValidatedTx ::
193195
forall era proto.
194196
ShelleyBasedEra era =>
195-
SL.Validated (Tx era) ->
197+
SL.Validated (Tx TopTx era) ->
196198
Validated (GenTx (ShelleyBlock proto era))
197199
mkShelleyValidatedTx vtx = ShelleyValidatedTx txid vtx
198200
where
@@ -226,7 +228,7 @@ instance ShelleyBasedEra era => HasTxs (ShelleyBlock proto era) where
226228
. SL.blockBody
227229
. shelleyBlockRaw
228230
where
229-
blockBodyToTxList :: BlockBody era -> [Tx era]
231+
blockBodyToTxList :: BlockBody era -> [Tx TopTx era]
230232
blockBodyToTxList blockBody = toList $ blockBody ^. txSeqBlockBodyL
231233

232234
{-------------------------------------------------------------------------------

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/ShelleyHFC.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,30 +391,30 @@ translateShelleyTables (LedgerTables utxoTable) =
391391

392392
instance
393393
( ShelleyBasedEra era
394-
, SL.TranslateEra era SL.Tx
394+
, SL.TranslateEra era (SL.Tx SL.TopTx)
395395
) =>
396396
SL.TranslateEra era (GenTx :.: ShelleyBlock proto)
397397
where
398-
type TranslationError era (GenTx :.: ShelleyBlock proto) = SL.TranslationError era SL.Tx
398+
type TranslationError era (GenTx :.: ShelleyBlock proto) = SL.TranslationError era (SL.Tx SL.TopTx)
399399
translateEra ctxt (Comp (ShelleyTx _txId tx)) =
400400
Comp . mkShelleyTx
401401
<$> SL.translateEra ctxt tx
402402

403403
instance
404404
( ShelleyBasedEra era
405-
, SL.TranslateEra era SL.Tx
405+
, SL.TranslateEra era (SL.Tx SL.TopTx)
406406
) =>
407407
SL.TranslateEra era (WrapValidatedGenTx :.: ShelleyBlock proto)
408408
where
409409
type
410410
TranslationError era (WrapValidatedGenTx :.: ShelleyBlock proto) =
411-
SL.TranslationError era SL.Tx
411+
SL.TranslationError era (SL.Tx SL.TopTx)
412412
translateEra ctxt (Comp (WrapValidatedGenTx (ShelleyValidatedTx _txId vtx))) =
413413
Comp
414414
. WrapValidatedGenTx
415415
. mkShelleyValidatedTx
416416
. SL.coerceValidated
417-
<$> SL.translateValidated @era @SL.Tx ctxt (SL.coerceValidated vtx)
417+
<$> SL.translateValidated @era @(SL.Tx SL.TopTx) ctxt (SL.coerceValidated vtx)
418418

419419
{-------------------------------------------------------------------------------
420420
Canonical TxIn

ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/Infra/ShelleyBasedHardFork.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ type ShelleyBasedHardForkConstraints proto1 era1 proto2 era2 =
188188
, TranslateTxMeasure (TxMeasure (ShelleyBlock proto1 era1)) (TxMeasure (ShelleyBlock proto2 era2))
189189
, SL.PreviousEra era2 ~ era1
190190
, SL.TranslateEra era2 SL.NewEpochState
191-
, SL.TranslateEra era2 SL.Tx
191+
, SL.TranslateEra era2 (SL.Tx SL.TopTx)
192192
, SL.TranslationError era2 SL.NewEpochState ~ Void
193193
, -- At the moment, fix the protocols together
194194
ProtoCrypto proto1 ~ ProtoCrypto proto2

ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/TxGen/Cardano.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ migrateUTxO migrationInfo curSlot lcfg lst
176176
assert (pickedCoin > spentCoin) $
177177
pickedCoin <-> spentCoin
178178

179-
body :: SL.TxBody ShelleyEra
179+
body :: SL.TxBody SL.TopTx ShelleyEra
180180
body =
181181
SL.mkBasicTxBody
182182
& SL.certsTxBodyL

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Block/Shelley.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ instance
6565
countTxOutputs blk = case Shelley.shelleyBlockRaw blk of
6666
SL.Block _ body -> getSum $ foldMap (Sum . countOutputs) (body ^. Core.txSeqBlockBodyL)
6767
where
68-
countOutputs :: Core.Tx era -> Int
68+
countOutputs :: Core.Tx Core.TopTx era -> Int
6969
countOutputs tx = length $ tx ^. Core.bodyTxL . Core.outputsTxBodyL
7070

7171
blockTxSizes blk = case Shelley.shelleyBlockRaw blk of
@@ -100,7 +100,7 @@ instance
100100
| f <- maybeToList txExUnitsSteps
101101
]
102102
where
103-
txs :: StrictSeq (Core.Tx era)
103+
txs :: StrictSeq (Core.Tx Core.TopTx era)
104104
txs = case Shelley.shelleyBlockRaw blk of
105105
SL.Block _ body -> body ^. Core.txSeqBlockBodyL
106106

@@ -109,7 +109,7 @@ instance
109109
blockApplicationMetrics = []
110110

111111
class PerEraAnalysis era where
112-
txExUnitsSteps :: Maybe (Core.Tx era -> Word64)
112+
txExUnitsSteps :: Maybe (Core.Tx Core.TopTx era -> Word64)
113113

114114
instance PerEraAnalysis ShelleyEra where txExUnitsSteps = Nothing
115115
instance PerEraAnalysis AllegraEra where txExUnitsSteps = Nothing

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Examples.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ codecConfig = ShelleyCodecConfig
9494
mkLedgerTables ::
9595
forall proto era.
9696
ShelleyCompatible proto era =>
97-
LC.Tx era ->
97+
LC.Tx LC.TopTx era ->
9898
LedgerTables (LedgerState (ShelleyBlock proto era)) ValuesMK
9999
mkLedgerTables tx =
100100
LedgerTables $

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/MockCrypto.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ type CanMock proto era =
7979
, Arbitrary (Core.PParams era)
8080
, Arbitrary (Core.PParamsUpdate era)
8181
, Arbitrary (Core.Script era)
82-
, Arbitrary (Core.TxBody era)
83-
, Arbitrary (Core.Tx era)
82+
, Arbitrary (Core.TxBody Core.TopTx era)
83+
, Arbitrary (Core.Tx Core.TopTx era)
8484
, Arbitrary (Core.TxOut era)
8585
, Arbitrary (Core.Value era)
8686
, Arbitrary (PredicateFailure (SL.ShelleyUTXOW era))

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ mkSetDecentralizationParamTxs coreNodes pVer ttl dNew =
525525

526526
-- Nothing but the parameter update and the obligatory touching of an
527527
-- input.
528-
body :: SL.TxBody ShelleyEra
528+
body :: SL.TxBody SL.TopTx ShelleyEra
529529
body =
530530
SL.mkBasicTxBody
531531
& SL.inputsTxBodyL .~ Set.singleton (fst touchCoins)
@@ -646,7 +646,7 @@ mkMASetDecentralizationParamTxs coreNodes pVer ttl dNew =
646646

647647
-- Nothing but the parameter update and the obligatory touching of an
648648
-- input.
649-
body :: SL.TxBody era
649+
body :: SL.TxBody SL.TopTx era
650650
body =
651651
SL.mkBasicTxBody
652652
& SL.inputsTxBodyL .~ inputs

0 commit comments

Comments
 (0)