Skip to content

Commit

Permalink
Revert "Refactored RewardSnapShot, and added Pulsing to SnapShots."
Browse files Browse the repository at this point in the history
This reverts commit a7d4911.
  • Loading branch information
Jared Corduan committed Sep 15, 2021
1 parent ab13813 commit 8e34883
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 427 deletions.
5 changes: 4 additions & 1 deletion alonzo/impl/src/Cardano/Ledger/Alonzo/PlutusScriptApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Cardano.Ledger.Alonzo.PlutusScriptApi
where

import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Ledger.Address (Addr)
import Cardano.Ledger.Alonzo.Data (getPlutusData)
import Cardano.Ledger.Alonzo.Language (Language (..))
import Cardano.Ledger.Alonzo.PParams (ProtVer)
Expand Down Expand Up @@ -248,6 +249,7 @@ scriptsNeeded ::
HasField "inputs" (Core.TxBody era) (Set (TxIn (Crypto era))),
HasField "wdrls" (Core.TxBody era) (Wdrl (Crypto era)),
HasField "certs" (Core.TxBody era) (StrictSeq (DCert (Crypto era))),
HasField "address" (Core.TxOut era) (Addr (Crypto era)),
HasField "body" tx (Core.TxBody era)
) =>
UTxO era ->
Expand All @@ -272,7 +274,8 @@ scriptsNeededFromBody ::
( Era era,
HasField "inputs" (Core.TxBody era) (Set (TxIn (Crypto era))),
HasField "wdrls" (Core.TxBody era) (Wdrl (Crypto era)),
HasField "certs" (Core.TxBody era) (StrictSeq (DCert (Crypto era)))
HasField "certs" (Core.TxBody era) (StrictSeq (DCert (Crypto era))),
HasField "address" (Core.TxOut era) (Addr (Crypto era))
) =>
UTxO era ->
Core.TxBody era ->
Expand Down
3 changes: 2 additions & 1 deletion alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ witsVKeyNeeded ::
HasField "certs" (Core.TxBody era) (StrictSeq (DCert (Crypto era))),
HasField "inputs" (Core.TxBody era) (Set (TxIn (Crypto era))),
HasField "collateral" (Core.TxBody era) (Set (TxIn (Crypto era))),
HasField "update" (Core.TxBody era) (StrictMaybe (Update era))
HasField "update" (Core.TxBody era) (StrictMaybe (Update era)),
HasField "address" (Core.TxOut era) (Addr (Crypto era))
) =>
UTxO era ->
tx ->
Expand Down
3 changes: 1 addition & 2 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import Shelley.Spec.Ledger.API
StrictMaybe (..),
)
import qualified Shelley.Spec.Ledger.API as API
import Shelley.Spec.Ledger.EpochBoundary (translateSnapShots)
import qualified Shelley.Spec.Ledger.PParams as Shelley
import qualified Shelley.Spec.Ledger.Tx as LTX
import qualified Shelley.Spec.Ledger.TxBody as Shelley
Expand Down Expand Up @@ -140,7 +139,7 @@ instance Crypto c => TranslateEra (AlonzoEra c) EpochState where
return
EpochState
{ esAccountState = esAccountState es,
esSnapshots = translateSnapShots (esSnapshots es),
esSnapshots = esSnapshots es,
esLState = translateEra' ctxt $ esLState es,
esPrevPp = translatePParams ctxt $ esPrevPp es,
esPp = translatePParams ctxt $ esPp es,
Expand Down
2 changes: 0 additions & 2 deletions cardano-ledger-core/src/Cardano/Ledger/Era.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module Cardano.Ledger.Era
where

import qualified Cardano.Crypto.Hash as Hash
import Cardano.Ledger.Address (Addr)
import Cardano.Ledger.AuxiliaryData (AuxiliaryDataHash)
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Compactible (Compactible)
Expand Down Expand Up @@ -256,7 +255,6 @@ type WellFormed era =
HasField "scriptWits" (Core.Tx era) (Map (ScriptHash (Crypto era)) (Core.Script era)),
-- TxOut
HasField "value" (Core.TxOut era) (Core.Value era),
HasField "address" (Core.TxOut era) (Addr (Crypto era)),
-- HashAnnotated
HashAnnotated (Core.AuxiliaryData era) EraIndependentAuxiliaryData (Crypto era),
HashAnnotated (Core.TxBody era) EraIndependentTxBody (Crypto era),
Expand Down
3 changes: 1 addition & 2 deletions example-shelley/src/Cardano/Ledger/Example/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import Control.Monad.Except (throwError)
import Data.Coerce (coerce)
import qualified Data.Map.Strict as Map
import Shelley.Spec.Ledger.API
import Shelley.Spec.Ledger.EpochBoundary (translateSnapShots)
import Shelley.Spec.Ledger.PParams ()
import Shelley.Spec.Ledger.Tx (decodeWits)

Expand Down Expand Up @@ -169,7 +168,7 @@ instance Crypto c => TranslateEra (ExampleEra c) EpochState where
return
EpochState
{ esAccountState = esAccountState es,
esSnapshots = translateSnapShots (esSnapshots es),
esSnapshots = esSnapshots es,
esLState = translateEra' ctxt $ esLState es,
esPrevPp = translateEra' ctxt $ esPrevPp es,
esPp = translateEra' ctxt $ esPp es,
Expand Down
3 changes: 1 addition & 2 deletions shelley-ma/impl/src/Cardano/Ledger/Allegra/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import Control.Monad.Except (throwError)
import Data.Coerce (coerce)
import qualified Data.Map.Strict as Map
import Shelley.Spec.Ledger.API
import Shelley.Spec.Ledger.EpochBoundary (translateSnapShots)
import qualified Shelley.Spec.Ledger.LedgerState as LS
( returnRedeemAddrsToReserves,
)
Expand Down Expand Up @@ -171,7 +170,7 @@ instance Crypto c => TranslateEra (AllegraEra c) EpochState where
return
EpochState
{ esAccountState = esAccountState es,
esSnapshots = translateSnapShots (esSnapshots es),
esSnapshots = esSnapshots es,
esLState = translateEra' ctxt $ esLState es,
esPrevPp = translateEra' ctxt $ esPrevPp es,
esPp = translateEra' ctxt $ esPp es,
Expand Down
7 changes: 4 additions & 3 deletions shelley-ma/impl/src/Cardano/Ledger/Mary/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ import Data.Coerce (coerce)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
import Shelley.Spec.Ledger.API hiding (Metadata, TxBody)
import Shelley.Spec.Ledger.EpochBoundary (translateSnapShots)
import Shelley.Spec.Ledger.Tx (decodeWits)
import Shelley.Spec.Ledger.Tx
( decodeWits,
)

--------------------------------------------------------------------------------
-- Translation from Allegra to Mary
Expand Down Expand Up @@ -117,7 +118,7 @@ instance Crypto c => TranslateEra (MaryEra c) EpochState where
return
EpochState
{ esAccountState = esAccountState es,
esSnapshots = translateSnapShots (esSnapshots es),
esSnapshots = esSnapshots es,
esLState = translateEra' ctxt $ esLState es,
esPrevPp = translateEra' ctxt $ esPrevPp es,
esPp = translateEra' ctxt $ esPp es,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ import Shelley.Spec.Ledger.BlockChain (Block (..))
import Shelley.Spec.Ledger.CompactAddr (CompactAddr (..), decompactAddr)
import Shelley.Spec.Ledger.EpochBoundary
( BlocksMade (..),
PulsingStakeDistr (..),
SnapShot (..),
SnapShots (..),
Stake (..),
Expand Down Expand Up @@ -511,11 +510,10 @@ ppRewardUpdate (RewardUpdate dt dr rss df nonmyop) =
]

ppRewardSnapShot :: RewardSnapShot crypto -> PDoc
ppRewardSnapShot (RewardSnapShot go fee a0 nopt ver non deltaR1 rR deltaT1 total pot) =
ppRewardSnapShot (RewardSnapShot snaps a0 nopt ver non deltaR1 rR deltaT1 total pot) =
ppRecord
"RewardSnapShot"
[ ("GoSnapShot", ppSnapShot go),
("feeSnapShot", ppCoin fee),
[ ("snapshots", ppSnapShots snaps),
("a0", ppRational $ unboundRational a0),
("nOpt", ppNatural nopt),
("version", ppProtVer ver),
Expand Down Expand Up @@ -840,7 +838,7 @@ ppSnapShots :: SnapShots crypto -> PDoc
ppSnapShots (SnapShots mark set go fees) =
ppRecord
"SnapShots"
[ ("pstakeMark", ppPulsingStakeDistr mark),
[ ("pstakeMark", ppSnapShot mark),
("pstakeSet", ppSnapShot set),
("pstakeGo", ppSnapShot go),
("fee", ppCoin fees)
Expand All @@ -849,10 +847,6 @@ ppSnapShots (SnapShots mark set go fees) =
instance PrettyA (Stake crypto) where
prettyA = ppStake

ppPulsingStakeDistr :: PulsingStakeDistr era m -> PDoc
ppPulsingStakeDistr (Completed ss) = ppSnapShot ss
ppPulsingStakeDistr (StillPulsing _) = ppString "StillPulsing"

instance PrettyA (BlocksMade crypto) where
prettyA = ppBlocksMade

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import Shelley.Spec.Ledger.UTxO (UTxO (..))
-- This is not based on any snapshot, but uses the current ledger state.
poolsByTotalStakeFraction ::
forall era.
UsesValue era =>
(UsesValue era, HasField "address" (Core.TxOut era) (Addr (Crypto era))) =>
Globals ->
NewEpochState era ->
PoolDistr (Crypto era)
Expand Down Expand Up @@ -143,7 +143,8 @@ getTotalStake globals ss =
getNonMyopicMemberRewards ::
( UsesValue era,
HasField "_a0" (Core.PParams era) NonNegativeInterval,
HasField "_nOpt" (Core.PParams era) Natural
HasField "_nOpt" (Core.PParams era) Natural,
HasField "address" (Core.TxOut era) (Addr (Crypto era))
) =>
Globals ->
NewEpochState era ->
Expand Down Expand Up @@ -216,7 +217,9 @@ getNonMyopicMemberRewards globals ss creds =
-- do not want to use one of the regular snapshots, but rather the most recent
-- ledger state.
currentSnapshot ::
UsesValue era =>
( UsesValue era,
HasField "address" (Core.TxOut era) (Addr (Crypto era))
) =>
NewEpochState era ->
EB.SnapShot (Crypto era)
currentSnapshot ss =
Expand Down
Loading

0 comments on commit 8e34883

Please sign in to comment.