Skip to content

Commit 0627e36

Browse files
authored
Merge pull request #4971 from IntersectMBO/lehins/rename-AccountState
Rename `AccountState` to `ChainAccountState`
2 parents f687855 + 8dd57ba commit 0627e36

File tree

84 files changed

+490
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+490
-438
lines changed

eras/allegra/impl/src/Cardano/Ledger/Allegra/Translation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ instance TranslateEra AllegraEra EpochState where
156156
translateEra ctxt es =
157157
return
158158
EpochState
159-
{ esAccountState = esAccountState es
159+
{ esChainAccountState = esChainAccountState es
160160
, esSnapshots = esSnapshots es
161161
, esLState = translateEra' ctxt $ esLState es
162162
, esNonMyopic = esNonMyopic es

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Translation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ instance TranslateEra AlonzoEra EpochState where
9494
translateEra ctxt es =
9595
return
9696
EpochState
97-
{ esAccountState = esAccountState es
97+
{ esChainAccountState = esChainAccountState es
9898
, esSnapshots = esSnapshots es
9999
, esLState = translateEra' ctxt $ esLState es
100100
, esNonMyopic = esNonMyopic es

eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/Trace.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ instance
7575
<$> genEraPParams @era geConstants
7676
<*> genAccountState geConstants
7777

78-
sigGen genenv env state = genTx genenv env state
78+
sigGen = genTx
7979

8080
shrinkSignal _ = [] -- TODO add some kind of Shrinker?
8181

eras/babbage/impl/src/Cardano/Ledger/Babbage/Translation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ instance TranslateEra BabbageEra EpochState where
9494
translateEra ctxt es =
9595
pure
9696
EpochState
97-
{ esAccountState = esAccountState es
97+
{ esChainAccountState = esChainAccountState es
9898
, esSnapshots = esSnapshots es
9999
, esLState = translateEra' ctxt $ esLState es
100100
, esNonMyopic = esNonMyopic es

eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ import Cardano.Ledger.Shelley.LedgerState (
218218
NewEpochState (..),
219219
epochStateGovStateL,
220220
epochStatePoolParamsL,
221-
epochStateTreasuryL,
222221
esLStateL,
223222
lsCertState,
224223
lsCertStateL,
@@ -504,7 +503,7 @@ setFreshDRepPulsingState epochNo stakePoolDistr epochState = do
504503
, dpCommitteeState = vsCommitteeState vState
505504
, dpEnactState =
506505
mkEnactState govState
507-
& ensTreasuryL .~ epochState ^. epochStateTreasuryL
506+
& ensTreasuryL .~ epochState ^. treasuryL
508507
, dpProposals = proposalsActions props
509508
, dpProposalDeposits = proposalsDeposits props
510509
, dpGlobals = globals

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ import Cardano.Ledger.Shelley.LedgerState (
6767
EpochState (..),
6868
LedgerState (..),
6969
UTxOState (..),
70-
asTreasuryL,
7170
curPParamsEpochStateL,
72-
esAccountState,
73-
esAccountStateL,
7471
esLStateL,
7572
esSnapshotsL,
7673
lsCertStateL,
@@ -228,23 +225,23 @@ updateNumDormantEpochs currentEpoch ps vState =
228225
--
229226
-- The utxo fees and donations are applied in the remaining body of EPOCH transition
230227
applyEnactedWithdrawals ::
231-
AccountState ->
228+
ChainAccountState ->
232229
DState era ->
233230
EnactState era ->
234-
(AccountState, DState era, EnactState era)
235-
applyEnactedWithdrawals accountState dState enactedState =
231+
(ChainAccountState, DState era, EnactState era)
232+
applyEnactedWithdrawals chainAccountState dState enactedState =
236233
let enactedWithdrawals = enactedState ^. ensWithdrawalsL
237234
rewardsUView = RewDepUView $ dState ^. dsUnifiedL
238235
successfulWithdrawls = rewardsUView enactedWithdrawals
239-
accountState' =
240-
accountState
236+
chainAccountState' =
237+
chainAccountState
241238
-- Subtract `successfulWithdrawals` from the treasury, and add them to the rewards UMap
242239
-- `unclaimed` withdrawals remain in the treasury.
243240
-- Compared to the spec, instead of adding `unclaimed` and subtracting `totWithdrawals`
244241
-- + unclaimed - totWithdrawals
245242
-- we just subtract the `refunds`
246243
-- - refunds
247-
& asTreasuryL %~ (<-> fold successfulWithdrawls)
244+
& casTreasuryL %~ (<-> fold successfulWithdrawls)
248245
-- The use of the partial function `compactCoinOrError` is justified here because
249246
-- 1. the decoder for coin at the proposal-submission boundary has already
250247
-- confirmed we have a compactible value
@@ -258,7 +255,7 @@ applyEnactedWithdrawals accountState dState enactedState =
258255
enactedState
259256
& ensWithdrawalsL .~ Map.empty
260257
& ensTreasuryL .~ mempty
261-
in (accountState', dState', enactedState')
258+
in (chainAccountState', dState', enactedState')
262259

263260
epochTransition ::
264261
forall era.
@@ -291,14 +288,14 @@ epochTransition = do
291288
TRC
292289
( ()
293290
, epochState0@EpochState
294-
{ esAccountState = accountState0
295-
, esSnapshots = snapshots0
291+
{ esSnapshots = snapshots0
296292
, esLState = ledgerState0
297293
}
298294
, eNo
299295
) <-
300296
judgmentContext
301-
let govState0 = utxosGovState utxoState0
297+
let chainAccountState0 = epochState0 ^. chainAccountStateL
298+
govState0 = utxosGovState utxoState0
302299
curPParams = govState0 ^. curPParamsGovStateL
303300
utxoState0 = lsUTxOState ledgerState0
304301
certState0 = ledgerState0 ^. lsCertStateL
@@ -314,9 +311,9 @@ epochTransition = do
314311
{ psStakePoolParams = newStakePoolParams
315312
, psFutureStakePoolParams = Map.empty
316313
}
317-
PoolreapState utxoState1 accountState1 certState1 <-
314+
PoolreapState utxoState1 chainAccountState1 certState1 <-
318315
trans @(EraRule "POOLREAP" era) $
319-
TRC ((), PoolreapState utxoState0 accountState0 (certState0 & certPStateL .~ pState1), eNo)
316+
TRC ((), PoolreapState utxoState0 chainAccountState0 (certState0 & certPStateL .~ pState1), eNo)
320317

321318
let
322319
stakePoolDistr = ssStakeMarkPoolDistr snapshots1
@@ -325,8 +322,8 @@ epochTransition = do
325322
ratifyState@RatifyState {rsEnactState, rsEnacted, rsExpired} =
326323
extractDRepPulsingState pulsingState
327324

328-
(accountState2, dState2, EnactState {..}) =
329-
applyEnactedWithdrawals accountState1 (certState1 ^. certDStateL) rsEnactState
325+
(chainAccountState2, dState2, EnactState {..}) =
326+
applyEnactedWithdrawals chainAccountState1 (certState1 ^. certDStateL) rsEnactState
330327

331328
-- NOTE: It is important that we apply the results of ratification
332329
-- and enactment from the pulser to the working copy of proposals.
@@ -375,10 +372,10 @@ epochTransition = do
375372
)
376373
(certState1 ^. certPStateL)
377374
(dState2 & dsUnifiedL .~ newUMap)
378-
accountState3 =
379-
accountState2
375+
chainAccountState3 =
376+
chainAccountState2
380377
-- Move donations and unclaimed rewards from proposals to treasury:
381-
& asTreasuryL <>~ (utxoState0 ^. utxosDonationL <> fold unclaimed)
378+
& casTreasuryL <>~ (utxoState0 ^. utxosDonationL <> fold unclaimed)
382379
utxoState2 =
383380
utxoState1
384381
& utxosDepositedL .~ totalObligation certState2 govState1
@@ -391,7 +388,7 @@ epochTransition = do
391388
& lsUTxOStateL .~ utxoState2
392389
epochState1 =
393390
epochState0
394-
& esAccountStateL .~ accountState3
391+
& chainAccountStateL .~ chainAccountState3
395392
& esSnapshotsL .~ snapshots1
396393
& esLStateL .~ ledgerState1
397394
tellEvent $ EpochBoundaryRatifyState ratifyState

eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Ledger.hs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,13 @@ import Cardano.Ledger.Conway.Rules.GovCert (ConwayGovCertPredFailure)
8383
import Cardano.Ledger.Conway.Rules.Utxo (ConwayUtxoPredFailure)
8484
import Cardano.Ledger.Conway.Rules.Utxos (ConwayUtxosPredFailure)
8585
import Cardano.Ledger.Conway.Rules.Utxow (ConwayUtxowPredFailure)
86-
import Cardano.Ledger.Conway.State (ConwayEraCertState)
86+
import Cardano.Ledger.Conway.State
8787
import Cardano.Ledger.Conway.UTxO (txNonDistinctRefScriptsSize)
8888
import Cardano.Ledger.Credential (Credential (..), credKeyHash)
8989
import qualified Cardano.Ledger.Shelley.HardForks as HF (bootstrapPhase)
9090
import Cardano.Ledger.Shelley.LedgerState (
9191
LedgerState (..),
9292
UTxOState (..),
93-
asTreasuryL,
94-
dsUnifiedL,
95-
utxoL,
9693
utxosGovStateL,
9794
)
9895
import Cardano.Ledger.Shelley.Rules (
@@ -108,7 +105,6 @@ import Cardano.Ledger.Shelley.Rules (
108105
shelleyLedgerAssertions,
109106
)
110107
import Cardano.Ledger.Slot (epochFromSlot)
111-
import Cardano.Ledger.State (EraCertState (..), EraUTxO (..))
112108
import Cardano.Ledger.UMap (UView (..))
113109
import qualified Cardano.Ledger.UMap as UMap
114110
import Control.DeepSeq (NFData)
@@ -363,7 +359,7 @@ ledgerTransition ::
363359
TransitionRule (someLEDGER era)
364360
ledgerTransition = do
365361
TRC
366-
( LedgerEnv slot mbCurEpochNo _txIx pp account
362+
( LedgerEnv slot mbCurEpochNo _txIx pp chainAccountState
367363
, LedgerState utxoState certState
368364
, tx
369365
) <-
@@ -375,7 +371,7 @@ ledgerTransition = do
375371
if tx ^. isValidTxL == IsValid True
376372
then do
377373
let txBody = tx ^. bodyTxL
378-
actualTreasuryValue = account ^. asTreasuryL
374+
actualTreasuryValue = chainAccountState ^. casTreasuryL
379375
case txBody ^. currentTreasuryValueTxBodyL of
380376
SNothing -> pure ()
381377
SJust submittedTreasuryValue ->

eras/conway/impl/src/Cardano/Ledger/Conway/Translation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ instance TranslateEra ConwayEra EpochState where
128128
translateEra ctxt es =
129129
pure $
130130
EpochState
131-
{ esAccountState = esAccountState es
131+
{ esChainAccountState = esChainAccountState es
132132
, esSnapshots = esSnapshots es
133133
, esLState = translateEra' ctxt $ esLState es
134134
, esNonMyopic = esNonMyopic es

eras/conway/impl/src/Cardano/Ledger/Conway/Tx.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ getConwayMinFeeTx pp tx refScriptsSize =
105105
refScriptCostPerByte
106106
refScriptsSize
107107

108-
-- | Calculate the fee for reference scripts using an expoential growth of the price per
108+
-- | Calculate the fee for reference scripts using an exponential growth of the price per
109109
-- byte with linear increments
110110
tierRefScriptFee ::
111111
HasCallStack =>

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/BbodySpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Cardano.Ledger.Conway.Rules (
2121
maxRefScriptSizePerBlock,
2222
maxRefScriptSizePerTx,
2323
)
24+
import Cardano.Ledger.Conway.State
2425
import Cardano.Ledger.Plutus (SLanguage (..))
2526
import Cardano.Ledger.Shelley.LedgerState
2627
import Cardano.Ledger.Shelley.Rules (
@@ -77,7 +78,6 @@ spec = describe "BBODY" $ do
7778
nes <- use impNESL
7879
let ls = nes ^. nesEsL . esLStateL
7980
pp = nes ^. nesEsL . curPParamsEpochStateL
80-
account = nes ^. nesEsL . esAccountStateL
8181
kh <- freshKeyHash
8282
slotNo <- use impLastTickG
8383
let bhView =
@@ -90,7 +90,7 @@ spec = describe "BBODY" $ do
9090
}
9191
Left predFailures <-
9292
tryRunImpRule @"BBODY"
93-
(BbodyEnv pp account)
93+
(BbodyEnv pp (nes ^. chainAccountStateL))
9494
(BbodyState ls (BlocksMade Map.empty))
9595
(Block bhView txSeq)
9696
predFailures

0 commit comments

Comments
 (0)