Skip to content

Commit d01b031

Browse files
committed
Account for new ledger refactor.
Recent PR to ledger: IntersectMBO/cardano-ledger#2901 introduced a lot of breaking changes. This commit accounts for those changes
1 parent e975b9b commit d01b031

File tree

13 files changed

+93
-100
lines changed

13 files changed

+93
-100
lines changed

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ source-repository-package
222222
source-repository-package
223223
type: git
224224
location: https://github.com/input-output-hk/cardano-ledger
225-
tag: 389b266d6226dedf3d2aec7af640b3ca4984c5ea
226-
--sha256: 0i9zirl5pll9bwfp3l1zy8lhivmfmm8jpaprfx5jdjcnyha3ixrx
225+
tag: d696f1d47a149a6a3efd63e4cea363d19f3c7906
226+
--sha256: 1l1618vga3gz47ssvrlnblh8am3bxk1a1l0vh8mb6114cyd4r9kc
227227
subdir:
228228
eras/alonzo/impl
229229
eras/alonzo/test-suite

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import Control.Exception (assert)
1414
import Data.Map (Map)
1515
import qualified Data.Map as Map
1616
import Data.Maybe (maybeToList)
17-
import Data.SOP.Strict
1817
import qualified Data.Sequence.Strict as StrictSeq
1918
import qualified Data.Set as Set
19+
import Data.SOP.Strict
2020

2121
import Ouroboros.Consensus.Block (SlotNo (..))
2222
import Ouroboros.Consensus.Config
@@ -36,11 +36,11 @@ import qualified Cardano.Chain.Common as Byron
3636
import Cardano.Chain.Genesis (GeneratedSecrets (..))
3737

3838
import qualified Cardano.Ledger.Address as SL (BootstrapAddress (..))
39+
import qualified Cardano.Ledger.Core as SL (TxBody, TxOut)
3940
import qualified Cardano.Ledger.Hashes as SL
41+
import qualified Cardano.Ledger.Keys.Bootstrap as SL (makeBootstrapWitness)
4042
import qualified Cardano.Ledger.SafeHash as SL
41-
import qualified Cardano.Ledger.Shelley.API as SL
42-
import qualified Cardano.Ledger.Shelley.Address.Bootstrap as SL
43-
(makeBootstrapWitness)
43+
import qualified Cardano.Ledger.Shelley.API as SL hiding (TxBody, TxOut)
4444
import qualified Cardano.Ledger.Shelley.Tx as SL (WitnessSetHKD (..))
4545
import qualified Cardano.Ledger.Shelley.UTxO as SL (makeWitnessVKey)
4646
import Cardano.Ledger.Val ((<->))
@@ -143,12 +143,12 @@ migrateUTxO migrationInfo curSlot lcfg lst
143143
let picked :: Map (SL.TxIn c) (SL.TxOut (ShelleyEra c))
144144
picked = Map.filter pick $ SL.unUTxO utxo
145145
where
146-
pick (SL.TxOut addr _) =
146+
pick (SL.ShelleyTxOut addr _) =
147147
addr == SL.AddrBootstrap (SL.BootstrapAddress byronAddr)
148148

149149
-- Total held by 'byronAddr'
150150
pickedCoin :: SL.Coin
151-
pickedCoin = foldMap (\(SL.TxOut _ coin) -> coin) picked
151+
pickedCoin = foldMap (\(SL.ShelleyTxOut _ coin) -> coin) picked
152152

153153
-- NOTE: The Cardano ThreadNet tests use the
154154
-- ouroboros-consensus-shelley-test infra's genesis config, which sets
@@ -164,7 +164,7 @@ migrateUTxO migrationInfo curSlot lcfg lst
164164
pickedCoin <-> spentCoin
165165

166166
body :: SL.TxBody (ShelleyEra c)
167-
body = SL.TxBody
167+
body = SL.ShelleyTxBody
168168
{ SL._certs = StrictSeq.fromList $
169169
[ SL.DCertDeleg $ SL.RegKey $ Shelley.mkCredential stakingSK
170170
, SL.DCertPool $ SL.RegPool $ poolParams unspentCoin
@@ -176,7 +176,7 @@ migrateUTxO migrationInfo curSlot lcfg lst
176176
, SL._inputs = Map.keysSet picked
177177
, SL._mdHash = SL.SNothing
178178
, SL._outputs =
179-
StrictSeq.singleton $ SL.TxOut shelleyAddr unspentCoin
179+
StrictSeq.singleton $ SL.ShelleyTxOut shelleyAddr unspentCoin
180180
, SL._ttl = SlotNo maxBound
181181
, SL._txUpdate = SL.SNothing
182182
, SL._txfee = fee
@@ -209,7 +209,7 @@ migrateUTxO migrationInfo curSlot lcfg lst
209209
in
210210
if Map.null picked then Nothing else
211211
(Just . GenTxShelley. mkShelleyTx) $
212-
SL.Tx
212+
SL.ShelleyTx
213213
{ SL.body = body
214214
, SL.auxiliaryData = SL.SNothing
215215
, SL.wits = SL.WitnessSet

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ executable db-analyser
8888
, cborg
8989
, containers
9090
, contra-tracer
91+
, microlens
9192
, mtl
9293
, nothunks
9394
, optparse-applicative

ouroboros-consensus-cardano/tools/db-analyser/Block/Shelley.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import Data.Foldable (asum, toList)
1919
import qualified Data.Map.Strict as Map
2020
import Data.Maybe (catMaybes)
2121
import Data.Maybe.Strict
22-
import Data.Sequence.Strict (StrictSeq)
23-
import GHC.Records (HasField, getField)
22+
import Lens.Micro ((^.))
23+
import Lens.Micro.Extras (view)
2424
import Options.Applicative
2525

2626
import qualified Cardano.Ledger.Core as Core
@@ -47,20 +47,18 @@ import Ouroboros.Consensus.Shelley.Node (Nonce (..),
4747
import HasAnalysis
4848

4949
-- | Usable for each Shelley-based era
50-
instance ( ShelleyCompatible proto era
51-
, HasField "outputs" (Core.TxBody era) (StrictSeq (Core.TxOut era))
52-
) => HasAnalysis (ShelleyBlock proto era) where
50+
instance ShelleyCompatible proto era => HasAnalysis (ShelleyBlock proto era) where
5351

5452
countTxOutputs blk = case Shelley.shelleyBlockRaw blk of
5553
SL.Block _ body -> sum $ fmap countOutputs (CL.fromTxSeq @era body)
5654
where
5755
countOutputs :: Core.Tx era -> Int
58-
countOutputs = length . getField @"outputs" . getField @"body"
56+
countOutputs tx = length $ tx ^. Core.bodyTxL . Core.outputsTxBodyL
5957

6058
blockTxSizes blk = case Shelley.shelleyBlockRaw blk of
6159
SL.Block _ body ->
6260
toList
63-
$ fmap (fromIntegral . (getField @"txsize")) (CL.fromTxSeq @era body)
61+
$ fmap (fromIntegral . view Core.sizeTxF) (CL.fromTxSeq @era body)
6462

6563
knownEBBs = const Map.empty
6664

ouroboros-consensus-shelley-test/src/Test/Consensus/Shelley/Generators.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Ouroboros.Consensus.Ledger.Query
1919
import Ouroboros.Consensus.Ledger.SupportsMempool
2020

2121
import qualified Cardano.Ledger.Shelley.API as SL
22+
import qualified Cardano.Ledger.Shelley.PParams as SL
2223

2324
import Ouroboros.Consensus.Protocol.TPraos (PraosCrypto, TPraos,
2425
TPraosState (..))
@@ -207,7 +208,7 @@ instance ShelleyBasedEra era
207208
Generators for cardano-ledger-specs
208209
-------------------------------------------------------------------------------}
209210

210-
instance Arbitrary (SL.PParams' SL.StrictMaybe era) where
211+
instance Arbitrary (SL.ShelleyPParamsUpdate era) where
211212
arbitrary = genericArbitraryU
212213
shrink = genericShrink
213214

ouroboros-consensus-shelley-test/src/Test/Consensus/Shelley/MockCrypto.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import Cardano.Crypto.VRF (MockVRF)
2222
import qualified Cardano.Ledger.Core as Core
2323
import Cardano.Ledger.Crypto (Crypto (..))
2424
import qualified Cardano.Ledger.Shelley.API as SL
25-
import qualified Cardano.Ledger.Shelley.Tx as SL (ValidateScript)
2625
import qualified Cardano.Protocol.TPraos.API as SL
2726
import Control.State.Transition.Extended (PredicateFailure)
2827

@@ -65,7 +64,7 @@ type CanMock proto era =
6564
, LedgerSupportsProtocol (ShelleyBlock proto era)
6665
, SL.Mock (EraCrypto era)
6766
, Praos.PraosCrypto (EraCrypto era)
68-
, SL.ValidateScript era
67+
, Core.EraTx era
6968
, Arbitrary (Core.AuxiliaryData era)
7069
, Arbitrary (Core.PParams era)
7170
, Arbitrary (Core.Script era)

ouroboros-consensus-shelley-test/src/Test/ThreadNet/Infra/Shelley.hs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,13 @@ import Test.Util.Time (dawnOfTime)
7676
import Cardano.Ledger.BaseTypes (boundRational)
7777
import qualified Cardano.Ledger.Core as Core
7878
import Cardano.Ledger.Crypto (Crypto, DSIGN, HASH, KES, VRF)
79-
import qualified Cardano.Ledger.Era as Core
8079
import Cardano.Ledger.Hashes (EraIndependentTxBody)
8180
import qualified Cardano.Ledger.Keys
8281
import Cardano.Ledger.SafeHash (HashAnnotated (..), SafeHash,
8382
hashAnnotated)
8483
import qualified Cardano.Ledger.Shelley.API as SL
85-
import qualified Cardano.Ledger.Shelley.PParams as SL (emptyPParams,
86-
emptyPParamsUpdate)
84+
import qualified Cardano.Ledger.Shelley.PParams as SL (ShelleyPParamsUpdate,
85+
emptyPParams, emptyPParamsUpdate)
8786
import qualified Cardano.Ledger.Shelley.Tx as SL (WitnessSetHKD (..))
8887
import qualified Cardano.Ledger.Shelley.UTxO as SL (makeWitnessesVKey)
8988
import qualified Cardano.Ledger.ShelleyMA.TxBody as MA
@@ -333,7 +332,7 @@ mkGenesisConfig pVer k f d maxLovelaceSupply slotLength kesCfg coreNodes =
333332
where
334333
nbCoreNodes = fromIntegral (length coreNodes)
335334

336-
pparams :: SL.PParams era
335+
pparams :: SL.ShelleyPParams era
337336
pparams = SL.emptyPParams
338337
{ SL._d =
339338
unsafeBoundRational (decentralizationParamToRational d)
@@ -449,7 +448,7 @@ mkSetDecentralizationParamTxs ::
449448
mkSetDecentralizationParamTxs coreNodes pVer ttl dNew =
450449
(:[]) $
451450
mkShelleyTx $
452-
SL.Tx
451+
SL.ShelleyTx
453452
{ body = body
454453
, wits = witnessSet
455454
, auxiliaryData = SL.SNothing
@@ -477,8 +476,8 @@ mkSetDecentralizationParamTxs coreNodes pVer ttl dNew =
477476

478477
-- Nothing but the parameter update and the obligatory touching of an
479478
-- input.
480-
body :: SL.TxBody (ShelleyEra c)
481-
body = SL.TxBody
479+
body :: Core.TxBody (ShelleyEra c)
480+
body = SL.ShelleyTxBody
482481
{ _certs = Seq.empty
483482
, _inputs = Set.singleton (fst touchCoins)
484483
, _mdHash = SL.SNothing
@@ -494,12 +493,12 @@ mkSetDecentralizationParamTxs coreNodes pVer ttl dNew =
494493
-- We use the input of the first node, but we just put it all right back.
495494
--
496495
-- ASSUMPTION: This transaction runs in the first slot.
497-
touchCoins :: (SL.TxIn c, SL.TxOut (ShelleyEra c))
496+
touchCoins :: (SL.TxIn c, Core.TxOut (ShelleyEra c))
498497
touchCoins = case coreNodes of
499498
[] -> error "no nodes!"
500499
cn:_ ->
501500
( SL.initialFundsPseudoTxIn addr
502-
, SL.TxOut addr coin
501+
, SL.ShelleyTxOut addr coin
503502
)
504503
where
505504
addr = SL.Addr networkId
@@ -563,10 +562,10 @@ networkId = SL.Testnet
563562
mkMASetDecentralizationParamTxs ::
564563
forall proto era.
565564
( ShelleyBasedEra era
566-
, Core.Tx era ~ SL.Tx era
567-
, Core.TxBody era ~ MA.TxBody era
568-
, Core.PParams era ~ SL.PParams era
569-
, Core.PParamsDelta era ~ SL.PParams' SL.StrictMaybe era
565+
, MA.ShelleyMAEraTxBody era
566+
, Core.Tx era ~ SL.ShelleyTx era
567+
, Core.TxBody era ~ MA.MATxBody era
568+
, Core.PParamsUpdate era ~ SL.ShelleyPParamsUpdate era
570569
, Core.Witnesses era ~ SL.WitnessSet era
571570
)
572571
=> [CoreNode (Core.Crypto era)]
@@ -577,7 +576,7 @@ mkMASetDecentralizationParamTxs ::
577576
mkMASetDecentralizationParamTxs coreNodes pVer ttl dNew =
578577
(:[]) $
579578
mkShelleyTx $
580-
SL.Tx
579+
SL.ShelleyTx
581580
{ body = body
582581
, wits = witnessSet
583582
, auxiliaryData = SL.SNothing
@@ -605,8 +604,8 @@ mkMASetDecentralizationParamTxs coreNodes pVer ttl dNew =
605604

606605
-- Nothing but the parameter update and the obligatory touching of an
607606
-- input.
608-
body :: MA.TxBody era
609-
body = MA.TxBody
607+
body :: MA.MATxBody era
608+
body = MA.MATxBody
610609
inputs
611610
outputs
612611
certs
@@ -635,12 +634,12 @@ mkMASetDecentralizationParamTxs coreNodes pVer ttl dNew =
635634
-- We use the input of the first node, but we just put it all right back.
636635
--
637636
-- ASSUMPTION: This transaction runs in the first slot.
638-
touchCoins :: (SL.TxIn (Core.Crypto era), SL.TxOut era)
637+
touchCoins :: (SL.TxIn (Core.Crypto era), SL.ShelleyTxOut era)
639638
touchCoins = case coreNodes of
640639
[] -> error "no nodes!"
641640
cn:_ ->
642641
( SL.initialFundsPseudoTxIn addr
643-
, SL.TxOut addr coin
642+
, SL.ShelleyTxOut addr coin
644643
)
645644
where
646645
addr = SL.Addr networkId

ouroboros-consensus-shelley/ouroboros-consensus-shelley.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ library
6969
, deepseq
7070
, measures
7171
, mtl >=2.2 && <2.3
72+
, microlens
7273
, nothunks
7374
, orphans-deriving-via
7475
, serialise >=0.2 && <0.3

0 commit comments

Comments
 (0)