Skip to content

Commit

Permalink
Remove currentProtocolParametersInRecentEras
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed Oct 28, 2024
1 parent d48fb27 commit ef53212
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
2 changes: 0 additions & 2 deletions lib/benchmarks/exe/api-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,6 @@ mockNetworkLayer = dummyNetworkLayer
:: Read.PParams Read.Babbage
)
, currentProtocolParameters = pure dummyProtocolParameters
, currentProtocolParametersInRecentEras =
pure $ Write.InRecentEraBabbage dummyLedgerProtocolParameters
, currentNodeEra = pure $ Cardano.anyCardanoEra Cardano.BabbageEra
, currentNodeTip = pure Read.BlockTip
{ Read.slotNo = Read.SlotNo 123456789
Expand Down
3 changes: 0 additions & 3 deletions lib/network-layer/src/Cardano/Wallet/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ data NetworkLayer m block = NetworkLayer
:: m ProtocolParameters
-- ^ Get the last known protocol parameters. In principle, these can
-- only change once per epoch.
, currentProtocolParametersInRecentEras
:: m (MaybeInRecentEra Write.PParams)
-- ^ Get the last known protocol parameters for recent eras.
, currentSlottingParameters
:: m SlottingParameters
-- ^ Get the last known slotting parameters. In principle, these can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ import qualified Data.ByteString as BS
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Internal.Cardano.Write.Tx as Write
import qualified Ouroboros.Consensus.Cardano.Block as Consensus
import qualified Ouroboros.Consensus.Shelley.Ledger.Mempool as Consensus

Expand Down Expand Up @@ -431,7 +430,6 @@ withNetworkLayer tr pipeliningStrategy np conn ver tol action = do
-- | Network parameters and protocol parameters for the node's current tip.
data NetworkParams = NetworkParams
{ protocolParams :: Read.EraValue Read.PParams
, protocolParamsRecent :: MaybeInRecentEra Write.PParams
, protocolParamsLegacy :: ProtocolParameters
, slottingParamsLegacy :: SlottingParameters
}
Expand Down Expand Up @@ -520,8 +518,6 @@ withNodeNetworkLayerBase
, currentProtocolParameters =
protocolParamsLegacy
<$> atomically (readTMVar networkParamsVar)
, currentProtocolParametersInRecentEras =
protocolParamsRecent <$> atomically (readTMVar networkParamsVar)
, currentSlottingParameters =
slottingParamsLegacy
<$> atomically (readTMVar networkParamsVar)
Expand Down Expand Up @@ -963,7 +959,6 @@ mkWalletToNodeProtocols
let queryParams =
NetworkParams
<$> LSQ.protocolParams
<*> LSQ.protocolParamsRecent
<*> LSQ.protocolParamsLegacy
<*> (LSQ.slottingParamsLegacy np)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Cardano.Wallet.Network.LocalStateQuery.Extra
import Cardano.Wallet.Network.LocalStateQuery.PParams
( protocolParams
, protocolParamsLegacy
, protocolParamsRecent
, slottingParamsLegacy
)
import Cardano.Wallet.Network.LocalStateQuery.RewardAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
module Cardano.Wallet.Network.LocalStateQuery.PParams
( protocolParams
, protocolParamsLegacy
, protocolParamsRecent
, slottingParamsLegacy
) where

Expand All @@ -19,7 +18,6 @@ import Cardano.Wallet.Network.Implementation.Ouroboros
)
import Cardano.Wallet.Network.LocalStateQuery.Extra
( byronOrShelleyBased
, onAnyEra
, onAnyEra'
)
import Cardano.Wallet.Primitive.Ledger.Read.PParams
Expand All @@ -40,9 +38,6 @@ import Cardano.Wallet.Primitive.Types.ProtocolParameters
import Cardano.Wallet.Primitive.Types.SlottingParameters
( SlottingParameters
)
import Cardano.Write.Eras
( MaybeInRecentEra (..)
)
import Ouroboros.Consensus.Cardano
( CardanoBlock
)
Expand All @@ -63,7 +58,6 @@ import qualified Cardano.Chain.Update.Validation.Interface as Byron
( adoptedProtocolParameters
)
import qualified Cardano.Wallet.Read as Read
import qualified Internal.Cardano.Write.Tx as Write
import qualified Ouroboros.Consensus.Byron.Ledger as Byron
import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley

Expand All @@ -85,17 +79,6 @@ protocolParams =
where
fromByron = Read.PParams . Byron.adoptedProtocolParameters

protocolParamsRecent :: LSQ' m (MaybeInRecentEra Write.PParams)
protocolParamsRecent =
onAnyEra
(pure InNonRecentEraByron)
(pure InNonRecentEraShelley)
(pure InNonRecentEraAllegra)
(pure InNonRecentEraMary)
(pure InNonRecentEraAlonzo)
(InRecentEraBabbage <$> LSQry Shelley.GetCurrentPParams)
(InRecentEraConway <$> LSQry Shelley.GetCurrentPParams)

slottingParamsLegacy :: NetworkParameters -> LSQ' m SlottingParameters
slottingParamsLegacy np =
byronOrShelleyBased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ dummyNetworkLayer = NetworkLayer
, watchNodeTip = err "watchNodeTip"
, currentPParams = err "currentPParams"
, currentProtocolParameters = err "currentProtocolParameters"
, currentProtocolParametersInRecentEras
= err "currentProtocolParametersInRecentEras"
, currentSlottingParameters = err "currentSlottingParameters"
, getUTxOByTxIn = err "getUTxOByTxIn"
, getStakeDelegDeposits = error "getStakeDelegDeposits"
Expand Down
18 changes: 17 additions & 1 deletion lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ import qualified Cardano.Address.Script as CA
import qualified Cardano.Address.Style.Shelley as CAShelley
import qualified Cardano.Api as Cardano
import qualified Cardano.Crypto.Wallet as CC
import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Slotting.Slot as Slot
import qualified Cardano.Wallet.Address.Discovery.Random as Rnd
import qualified Cardano.Wallet.Address.Discovery.Sequential as Seq
Expand Down Expand Up @@ -2160,12 +2161,27 @@ readNodeTipStateForTxWrite
-> IO (Write.PParamsInAnyRecentEra, TimeTranslation)
readNodeTipStateForTxWrite netLayer = do
timeTranslation <- toTimeTranslation (timeInterpreter netLayer)
mpp <- currentProtocolParametersInRecentEras netLayer
mpp <- Read.applyEraFun pparamsInRecentEra <$> currentPParams netLayer
case toRecentEraGADT mpp of
Left nopp -> throwIO $ ExceptionWriteTxEra
$ ErrNodeNotYetInRecentEra nopp
Right pp -> pure (pp, timeTranslation)

-- | Filter protocol parameters for recent eras.
pparamsInRecentEra
:: forall era. Read.IsEra era
=> Read.PParams era
-> Write.MaybeInRecentEra Ledger.PParams
pparamsInRecentEra (Read.PParams pparams) =
case Read.theEra :: Read.Era era of
Read.Byron -> Write.InNonRecentEraByron
Read.Shelley -> Write.InNonRecentEraShelley
Read.Allegra -> Write.InNonRecentEraAllegra
Read.Mary -> Write.InNonRecentEraMary
Read.Alonzo -> Write.InNonRecentEraAlonzo
Read.Babbage -> Write.InRecentEraBabbage pparams
Read.Conway -> Write.InRecentEraConway pparams

-- | Wallet-specific wrapped version of 'Write.balanceTx', made for the new tx
-- workflow with Shelley- and Shared- wallet flavors.
--
Expand Down

0 comments on commit ef53212

Please sign in to comment.