Skip to content

Commit d082ac9

Browse files
committed
Done with updating ledger
1 parent 3141baf commit d082ac9

File tree

14 files changed

+164
-159
lines changed

14 files changed

+164
-159
lines changed

cardano-api/src/Cardano/Api/Convenience/Construction.hs

-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ import Cardano.Api.Query
3434
import Cardano.Api.Tx
3535
import Cardano.Api.TxBody
3636
import Cardano.Api.Utils
37-
import Cardano.Ledger.Shelley.TxBody (ShelleyEraTxBody)
3837

3938
-- | Construct a balanced transaction.
4039
-- See Cardano.Api.Convenience.Query.queryStateForBalancedTx for a
4140
-- convenient way of querying the node to get the required arguements
4241
-- for constructBalancedTx.
4342
constructBalancedTx
4443
:: ( IsShelleyBasedEra era
45-
, ShelleyEraTxBody (ShelleyLedgerEra era)
4644
)
4745
=> EraInMode era CardanoMode
4846
-> TxBodyContent BuildTx era

cardano-api/src/Cardano/Api/Fees.hs

+22-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{-# LANGUAGE TypeApplications #-}
1111

1212
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
13+
{-# LANGUAGE AllowAmbiguousTypes #-}
1314

1415
-- | Fee calculation
1516
--
@@ -127,7 +128,7 @@ import Cardano.Ledger.Mary.Value (MaryValue)
127128
-- probably want to consider estimateTransactionFee.
128129
--
129130
transactionFee :: forall era.
130-
(IsShelleyBasedEra era, EraTx (ShelleyLedgerEra era))
131+
IsShelleyBasedEra era
131132
=> Natural -- ^ The fixed tx fee
132133
-> Natural -- ^ The tx fee per byte
133134
-> Tx era
@@ -168,7 +169,7 @@ transactionFee txFeeFixed txFeePerByte tx =
168169
-- metadata, withdrawals, certs etc)
169170
--
170171
estimateTransactionFee :: forall era.
171-
(IsShelleyBasedEra era, EraTx (ShelleyLedgerEra era))
172+
IsShelleyBasedEra era
172173
=> NetworkId
173174
-> Natural -- ^ The fixed tx fee
174175
-> Natural -- ^ The tx fee per byte
@@ -651,7 +652,7 @@ toLedgerEpochInfo (EraHistory _ interpreter) =
651652
-- useful for adjusting a transaction to be fully balanced.
652653
--
653654
evaluateTransactionBalance :: forall era.
654-
(IsShelleyBasedEra era, ShelleyEraTxBody (ShelleyLedgerEra era))
655+
IsShelleyBasedEra era
655656
=> ProtocolParameters
656657
-> Set PoolId
657658
-> UTxO era
@@ -663,13 +664,28 @@ evaluateTransactionBalance _ _ _ (ByronTxBody _) =
663664

664665
evaluateTransactionBalance pparams poolids utxo
665666
(ShelleyTxBody era txbody _ _ _ _) =
666-
withLedgerConstraints era evalAdaOnly evalMultiAsset
667+
withLedgerConstraints
668+
era
669+
(getShelleyEraTxBodyConstraint era evalAdaOnly)
670+
(getShelleyEraTxBodyConstraint era evalMultiAsset)
667671
where
672+
getShelleyEraTxBodyConstraint
673+
:: forall era' a.
674+
ShelleyBasedEra era'
675+
-> (ShelleyEraTxBody (ShelleyLedgerEra era') => a)
676+
-> a
677+
getShelleyEraTxBodyConstraint ShelleyBasedEraShelley x = x
678+
getShelleyEraTxBodyConstraint ShelleyBasedEraMary x = x
679+
getShelleyEraTxBodyConstraint ShelleyBasedEraAllegra x = x
680+
getShelleyEraTxBodyConstraint ShelleyBasedEraAlonzo x = x
681+
getShelleyEraTxBodyConstraint ShelleyBasedEraBabbage x = x
682+
668683
isNewPool :: Ledger.KeyHash Ledger.StakePool Ledger.StandardCrypto -> Bool
669684
isNewPool kh = StakePoolKeyHash kh `Set.notMember` poolids
670685

671686
evalMultiAsset :: forall ledgerera.
672687
ShelleyLedgerEra era ~ ledgerera
688+
=> ShelleyEraTxBody ledgerera
673689
=> LedgerEraConstraints ledgerera
674690
=> LedgerMultiAssetConstraints ledgerera
675691
=> MultiAssetSupportedInEra era
@@ -684,6 +700,7 @@ evaluateTransactionBalance pparams poolids utxo
684700

685701
evalAdaOnly :: forall ledgerera.
686702
ShelleyLedgerEra era ~ ledgerera
703+
=> ShelleyEraTxBody ledgerera
687704
=> LedgerEraConstraints ledgerera
688705
=> LedgerAdaOnlyConstraints ledgerera
689706
=> OnlyAdaSupportedInEra era
@@ -912,7 +929,7 @@ data BalancedTxBody era
912929
--
913930
makeTransactionBodyAutoBalance
914931
:: forall era mode.
915-
(IsShelleyBasedEra era, ShelleyEraTxBody (ShelleyLedgerEra era))
932+
IsShelleyBasedEra era
916933
=> EraInMode era mode
917934
-> SystemStart
918935
-> EraHistory mode

cardano-api/src/Cardano/Api/LedgerState.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,10 @@ obtainDecodeEpochStateConstraints
14841484
, FromCBOR (State (Core.EraRule "PPUP" ledgerera))
14851485
, FromCBOR (Core.Value ledgerera)
14861486
, FromSharedCBOR (Core.TxOut ledgerera)
1487+
, HashAnnotated
1488+
(Core.TxBody ledgerera)
1489+
Core.EraIndependentTxBody
1490+
(Ledger.Crypto (ShelleyLedgerEra era))
14871491
) => a) -> a
14881492
obtainDecodeEpochStateConstraints ShelleyBasedEraShelley f = f
14891493
obtainDecodeEpochStateConstraints ShelleyBasedEraAllegra f = f
@@ -1503,7 +1507,6 @@ currentEpochEligibleLeadershipSlots :: forall era ledgerera. ()
15031507
-- => Ledger.Crypto ledgerera ~ Shelley.StandardCrypto
15041508
=> FromCBOR (Consensus.ChainDepState (Api.ConsensusProtocol era))
15051509
-- => Consensus.ChainDepState (ConsensusProtocol era) ~ Consensus.ChainDepState (ConsensusProtocol era)
1506-
=> HashAnnotated (Core.TxBody ledgerera) Core.EraIndependentTxBody (Ledger.Crypto ledgerera)
15071510
=> ShelleyBasedEra era
15081511
-> ShelleyGenesis Shelley.StandardShelley
15091512
-> EpochInfo (Either Text)

cardano-api/src/Cardano/Api/Query.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ newtype SerialisedCurrentEpochState era
382382
newtype CurrentEpochState era = CurrentEpochState (Shelley.EpochState (ShelleyLedgerEra era))
383383

384384
decodeCurrentEpochState
385-
:: forall era. (Ledger.Era (ShelleyLedgerEra era)
385+
:: forall era. ( Ledger.Era (ShelleyLedgerEra era)
386386
, HashAnnotated (Core.TxBody (ShelleyLedgerEra era)) Core.EraIndependentTxBody (Ledger.Crypto (ShelleyLedgerEra era))
387387
)
388388
=> FromSharedCBOR (Core.TxOut (ShelleyLedgerEra era))

cardano-api/src/Cardano/Api/TxBody.hs

+10-19
Original file line numberDiff line numberDiff line change
@@ -2359,29 +2359,17 @@ makeTransactionBody =
23592359
ShelleyBasedEra era -> makeShelleyTransactionBody era
23602360

23612361

2362-
pattern TxBody
2363-
:: ( CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto
2364-
, Ledger.TxOut (ShelleyLedgerEra era) ~ BabbageTxOut (ShelleyLedgerEra era)
2365-
) =>
2366-
TxBodyContent ViewTx era -> TxBody era
2362+
pattern TxBody :: TxBodyContent ViewTx era -> TxBody era
23672363
pattern TxBody txbodycontent <- (getTxBodyContent -> txbodycontent)
23682364
{-# COMPLETE TxBody #-}
23692365

2370-
getTxBodyContent
2371-
:: ( CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto
2372-
, Ledger.TxOut (ShelleyLedgerEra era) ~ BabbageTxOut (ShelleyLedgerEra era)
2373-
)
2374-
=> TxBody era
2375-
-> TxBodyContent ViewTx era
2366+
getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era
23762367
getTxBodyContent (ByronTxBody body) = getByronTxBodyContent body
23772368
getTxBodyContent (ShelleyTxBody era body _scripts scriptdata mAux scriptValidity) =
23782369
fromLedgerTxBody era scriptValidity body scriptdata mAux
23792370

23802371
fromLedgerTxBody
2381-
:: ( CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto
2382-
, Ledger.TxOut (ShelleyLedgerEra era) ~ BabbageTxOut (ShelleyLedgerEra era)
2383-
)
2384-
=> ShelleyBasedEra era
2372+
:: ShelleyBasedEra era
23852373
-> TxScriptValidity era
23862374
-> Ledger.TxBody (ShelleyLedgerEra era)
23872375
-> TxBodyScriptData era
@@ -2451,7 +2439,6 @@ fromLedgerTxInsCollateral era body =
24512439

24522440
fromLedgerTxInsReference
24532441
::
2454-
(CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
24552442
ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxInsReference ViewTx era
24562443
fromLedgerTxInsReference era txBody =
24572444
case refInsScriptsAndInlineDatsSupportedInEra $ shelleyBasedToCardanoEra era of
@@ -2463,7 +2450,7 @@ fromLedgerTxInsReference era txBody =
24632450
where
24642451
obtainReferenceInputsHasFieldConstraint
24652452
:: ReferenceTxInsScriptsInlineDatumsSupportedInEra era
2466-
-> (BabbageEraTxBody (ShelleyLedgerEra era) => a)
2453+
-> ((CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto, BabbageEraTxBody (ShelleyLedgerEra era)) => a)
24672454
-> a
24682455
obtainReferenceInputsHasFieldConstraint ReferenceTxInsScriptsInlineDatumsInBabbageEra f = f
24692456

@@ -2596,7 +2583,7 @@ fromLedgerTxTotalCollateral era txbody =
25962583
obtainTotalCollateralHasFieldConstraint TxTotalAndReturnCollateralInBabbageEra f = f
25972584

25982585
fromLedgerTxReturnCollateral
2599-
:: ( Ledger.TxOut (ShelleyLedgerEra era) ~ BabbageTxOut (ShelleyLedgerEra era)
2586+
:: (
26002587
)
26012588
=> ShelleyBasedEra era
26022589
-> Ledger.TxBody (ShelleyLedgerEra era)
@@ -2612,7 +2599,11 @@ fromLedgerTxReturnCollateral era txbody =
26122599
where
26132600
obtainCollateralReturnHasFieldConstraint
26142601
:: TxTotalAndReturnCollateralSupportedInEra era
2615-
-> (BabbageEraTxBody (ShelleyLedgerEra era) => a)
2602+
-> (
2603+
( Ledger.TxOut (ShelleyLedgerEra era) ~ BabbageTxOut (ShelleyLedgerEra era)
2604+
, CC.Crypto (ShelleyLedgerEra era) ~ StandardCrypto
2605+
, BabbageEraTxBody (ShelleyLedgerEra era)
2606+
) => a)
26162607
-> a
26172608
obtainCollateralReturnHasFieldConstraint TxTotalAndReturnCollateralInBabbageEra f = f
26182609

cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs

+8-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ import qualified Cardano.Ledger.Crypto as Crypto
8282
import qualified Cardano.Ledger.Era as Era
8383
import qualified Cardano.Ledger.Era as Ledger
8484
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
85-
import Cardano.Ledger.Shelley.Constraints
8685
import Cardano.Ledger.Shelley.EpochBoundary
8786
import Cardano.Ledger.Shelley.LedgerState (EpochState (esSnapshots),
8887
NewEpochState (nesEs), PState (_fPParams, _pParams, _retiring))
@@ -103,6 +102,7 @@ import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
103102

104103
import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry
105104
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery
105+
import Cardano.Ledger.SafeHash (HashAnnotated)
106106

107107
{- HLINT ignore "Reduce duplication" -}
108108
{- HLINT ignore "Use const" -}
@@ -1397,10 +1397,10 @@ toEpochInfo (EraHistory _ interpreter) =
13971397
obtainLedgerEraClassConstraints
13981398
:: ShelleyLedgerEra era ~ ledgerera
13991399
=> Api.ShelleyBasedEra era
1400-
-> (( UsesValue ledgerera
1401-
, ToJSON (DebugLedgerState era)
1400+
-> (( ToJSON (DebugLedgerState era)
14021401
, FromCBOR (DebugLedgerState era)
14031402
, Era.Crypto ledgerera ~ StandardCrypto
1403+
, Ledger.Era (ShelleyLedgerEra era)
14041404
) => a) -> a
14051405
obtainLedgerEraClassConstraints ShelleyBasedEraShelley f = f
14061406
obtainLedgerEraClassConstraints ShelleyBasedEraAllegra f = f
@@ -1420,7 +1420,11 @@ eligibleLeaderSlotsConstaints
14201420
, HasField "_d" (Core.PParams (ShelleyLedgerEra era)) UnitInterval
14211421
, Crypto.Signable (Crypto.VRF (Ledger.Crypto ledgerera)) Seed
14221422
, Share (Core.TxOut (ShelleyLedgerEra era)) ~ Interns (Ledger.Credential 'Staking StandardCrypto)
1423-
, Crypto.ADDRHASH (Consensus.PraosProtocolSupportsNodeCrypto (ConsensusProtocol era)) ~ Blake2b.Blake2b_224
1423+
, Crypto.ADDRHASH (Consensus.PraosProtocolSupportsNodeCrypto (ConsensusProtocol era)) ~ Blake2b.Blake2b_224
1424+
, HashAnnotated
1425+
(Core.TxBody (ShelleyLedgerEra era))
1426+
Core.EraIndependentTxBody
1427+
StandardCrypto
14241428
) => a
14251429
)
14261430
-> a

cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{-# LANGUAGE TupleSections #-}
99

1010
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
11+
{-# LANGUAGE TypeApplications #-}
1112

1213
module Cardano.CLI.Shelley.Run.Transaction
1314
( ShelleyTxCmdError(..)

cardano-client-demo/StakeCredentialHistory.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Cardano.Api
99
import Cardano.Api.Shelley
1010
import Cardano.Ledger.Address (getRewardAcnt)
11-
import Cardano.Ledger.Alonzo.PParams (PParams' (..))
11+
import Cardano.Ledger.Alonzo.PParams (AlonzoPParamsHKD (..))
1212
import qualified Cardano.Ledger.BaseTypes as L
1313
import Cardano.Ledger.Compactible (Compactible (..))
1414
import qualified Cardano.Ledger.Core as LC

cardano-node/cardano-node.cabal

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ library
134134
, cardano-git-rev
135135
, cardano-crypto-class
136136
, cardano-crypto-wrapper
137-
, cardano-ledger-alonzo
138-
, cardano-ledger-babbage
139-
, cardano-ledger-byron
140137
, cardano-ledger-core
138+
, cardano-ledger-byron
139+
, cardano-ledger-shelley
141140
, cardano-ledger-shelley-ma
141+
, cardano-ledger-alonzo
142+
, cardano-ledger-babbage
142143
, cardano-prelude
143144
, cardano-protocol-tpraos
144145
, cardano-slotting
@@ -174,7 +175,6 @@ library
174175
, safe-exceptions
175176
, scientific
176177
, strict-stm
177-
, cardano-ledger-shelley
178178
, stm
179179
, text
180180
, time

cardano-node/src/Cardano/Node/Run.hs

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Cardano.Node.Run
2121
import qualified Cardano.Api as Api
2222
import Cardano.Prelude hiding (ByteString, STM, atomically, show, take, trace)
2323
import Data.IP (toSockAddr)
24-
import Prelude (String, id, show)
24+
import Prelude (String, id, show, undefined)
2525

2626
import Control.Monad.Class.MonadSTM.Strict
2727
import Control.Monad.Trans.Except.Extra (left)
@@ -621,8 +621,10 @@ mkP2PArguments NodeConfiguration {
621621
, P2P.daReadLocalRootPeers
622622
, P2P.daReadPublicRootPeers
623623
, P2P.daReadUseLedgerAfter
624-
, P2P.daProtocolIdleTimeout = ncProtocolIdleTimeout
625-
, P2P.daTimeWaitTimeout = ncTimeWaitTimeout
624+
, P2P.daProtocolIdleTimeout = ncProtocolIdleTimeout
625+
, P2P.daTimeWaitTimeout = ncTimeWaitTimeout
626+
, P2P.daDeadlineChurnInterval = Prelude.undefined
627+
, P2P.daBulkChurnInterval = Prelude.undefined
626628
}
627629
where
628630
daPeerSelectionTargets = PeerSelectionTargets {

0 commit comments

Comments
 (0)