Skip to content

Commit 1f34356

Browse files
iohk-bors[bot]lehins
authored andcommitted
Merge #3933
3933: Account for new ledger refactor. r=lehins a=lehins Recent PR to ledger: IntersectMBO/cardano-ledger#2901 introduced a lot of breaking changes. This PR accounts for those changes. # Description <!-- CI flakiness -- delete this before opening a PR Sadly, some CI checks are currently flaky. Right now, this includes: - GH Actions Windows job runs out of memory, e.g. in https://github.com/input-output-hk/ouroboros-network/runs/7231748864?check_suite_focus=true - The Hydra check for test-storage on Windows (mingwW64) fails with inscrutable malloc-related error messages: https://hydra.iohk.io/build/16260881/nixlog/1 - The tests in WallClock.delay* can fail under load (quite rarely): https://hydra.iohk.io/build/16723452/nixlog/76 If you encounter one of these, try restarting the job to see if the failure vanishes. If it does not or when in doubt, consider posting in the #network or #consensus channels on Slack. --> _description of the pull request, if it fixes a particular issue it should link the PR to a particular issue, see [ref](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword=)_ Co-authored-by: Alexey Kuleshevich <[email protected]>
2 parents 79998cf + 774f3e4 commit 1f34356

File tree

14 files changed

+111
-123
lines changed

14 files changed

+111
-123
lines changed

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ source-repository-package
226226
source-repository-package
227227
type: git
228228
location: https://github.com/input-output-hk/cardano-ledger
229-
tag: 389b266d6226dedf3d2aec7af640b3ca4984c5ea
230-
--sha256: 0i9zirl5pll9bwfp3l1zy8lhivmfmm8jpaprfx5jdjcnyha3ixrx
229+
tag: 49613f11e034485c8377945c86c0465726c0860c
230+
--sha256: 0gxb9xghsacr0qaljhq3qzvmb2f1wwmly89prwqy4fdm9mvqiq95
231231
subdir:
232232
eras/alonzo/impl
233233
eras/alonzo/test-suite

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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-tools/ouroboros-consensus-cardano-tools.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ library
5050
, deepseq
5151
, directory
5252
, filepath
53+
, microlens
5354
, mtl
5455
, nothunks
5556
, serialise

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import Data.Foldable (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

2525
import qualified Cardano.Ledger.Core as Core
2626
import qualified Cardano.Ledger.Era as CL
@@ -46,20 +46,18 @@ import Ouroboros.Consensus.Shelley.Node (Nonce (..),
4646
import Cardano.Tools.DBAnalyser.HasAnalysis
4747

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

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

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

6462
knownEBBs = const Map.empty
6563

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: 2 additions & 3 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,15 +64,15 @@ 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)
7271
, Arbitrary (Core.TxBody era)
7372
, Arbitrary (Core.Tx era)
7473
, Arbitrary (Core.TxOut era)
7574
, Arbitrary (Core.Value era)
76-
, Arbitrary (PredicateFailure (SL.UTXOW era))
75+
, Arbitrary (PredicateFailure (SL.ShelleyUTXOW era))
7776
, Arbitrary (Core.Witnesses era)
7877
, Arbitrary (StashedAVVMAddresses era)
7978
)

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
@@ -68,6 +68,7 @@ library
6868
, data-default-class
6969
, deepseq
7070
, measures
71+
, microlens
7172
, mtl >=2.2 && <2.3
7273
, nothunks
7374
, orphans-deriving-via

0 commit comments

Comments
 (0)