Skip to content

Commit ee3856e

Browse files
committed
Replace usage of UMap with different specialized per era types
Introduce two type families for `Accounts` and `AccountState` that have different representation for Conway era and era before it
1 parent fa49cbe commit ee3856e

File tree

190 files changed

+3339
-3270
lines changed

Some content is hidden

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

190 files changed

+3339
-3270
lines changed

eras/allegra/impl/cardano-ledger-allegra.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ library
4747
Cardano.Ledger.Allegra.Rules.Ppup
4848
Cardano.Ledger.Allegra.Rules.Utxo
4949
Cardano.Ledger.Allegra.Rules.Utxow
50+
Cardano.Ledger.Allegra.State.Account
5051
Cardano.Ledger.Allegra.State.CertState
5152
Cardano.Ledger.Allegra.State.Stake
5253
Cardano.Ledger.Allegra.TxCert

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Cardano.Ledger.Allegra.State (
22
module Cardano.Ledger.Shelley.State,
33
) where
44

5+
import Cardano.Ledger.Allegra.State.Account ()
56
import Cardano.Ledger.Allegra.State.CertState ()
67
import Cardano.Ledger.Allegra.State.Stake ()
78
import Cardano.Ledger.Shelley.State
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{-# LANGUAGE TypeFamilies #-}
2+
{-# OPTIONS_GHC -Wno-orphans #-}
3+
4+
module Cardano.Ledger.Allegra.State.Account () where
5+
6+
import Cardano.Ledger.Allegra.Era
7+
import Cardano.Ledger.BaseTypes
8+
import Cardano.Ledger.Shelley.State
9+
import Lens.Micro
10+
11+
instance EraAccounts AllegraEra where
12+
type AccountState AllegraEra = ShelleyAccountState AllegraEra
13+
type Accounts AllegraEra = ShelleyAccounts AllegraEra
14+
15+
addAccountState = shelleyAddAccountState
16+
17+
accountsMapL = lens saStates $ \sas asMap -> sas {saStates = asMap}
18+
19+
balanceAccountStateL = lens sasBalance $ \sas b -> sas {sasBalance = b}
20+
21+
depositAccountStateL = lens sasDeposit $ \sas d -> sas {sasDeposit = d}
22+
23+
stakePoolDelegationAccountStateL =
24+
lens (strictMaybeToMaybe . sasStakePoolDelegation) $ \sas d ->
25+
sas {sasStakePoolDelegation = maybeToStrictMaybe d}
26+
27+
unregisterAccount = unregisterShelleyAccount
28+
29+
instance ShelleyEraAccounts AllegraEra

eras/allegra/impl/src/Cardano/Ledger/Allegra/State/CertState.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
module Cardano.Ledger.Allegra.State.CertState () where
66

77
import Cardano.Ledger.Allegra.Era (AllegraEra)
8+
import Cardano.Ledger.Allegra.State.Account ()
89
import Cardano.Ledger.Shelley.State
910

1011
instance EraCertState AllegraEra where

eras/allegra/impl/src/Cardano/Ledger/Allegra/State/Stake.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Cardano.Ledger.Allegra.State.Stake () where
55

66
import Cardano.Ledger.Allegra.Core ()
77
import Cardano.Ledger.Allegra.Era (AllegraEra)
8+
import Cardano.Ledger.Allegra.State.Account ()
89
import Cardano.Ledger.Shelley.State (
910
EraStake (..),
1011
ShelleyInstantStake,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ instance EraTransition AllegraEra where
2222

2323
mkTransitionConfig NoGenesis = AllegraTransitionConfig
2424

25-
injectIntoTestState = registerInitialFundsThenStaking
25+
injectIntoTestState = shelleyRegisterInitialFundsThenStaking
2626

2727
tcPreviousEraConfigL =
2828
lens atcShelleyTransitionConfig (\atc pc -> atc {atcShelleyTransitionConfig = pc})

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ instance TranslateEra AllegraEra UTxOState where
127127
instance TranslateEra AllegraEra ShelleyInstantStake where
128128
translateEra _ = pure . coerce
129129

130+
instance TranslateEra AllegraEra ShelleyAccounts where
131+
translateEra _ = pure . coerce
132+
130133
instance TranslateEra AllegraEra DState where
131-
translateEra _ DState {..} = pure DState {..}
134+
translateEra ctx DState {dsAccounts = accountsShelley, ..} = do
135+
dsAccounts <- translateEra ctx accountsShelley
136+
pure DState {..}
132137

133138
instance TranslateEra AllegraEra CommitteeState where
134139
translateEra _ CommitteeState {..} = pure CommitteeState {..}

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class
2525
instance EraTest AllegraEra where
2626
zeroCostModels = emptyCostModels
2727

28+
mkTestAccountState = mkShelleyTestAccountState
29+
30+
accountsFromAccountsMap = shelleyAccountsFromAccountsMap
31+
32+
accountsToUMap = shelleyAccountsToUMap
33+
2834
instance ShelleyEraTest AllegraEra
2935

3036
instance AllegraEraTest AllegraEra

eras/alonzo/impl/cardano-ledger-alonzo.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ library
6262
Cardano.Ledger.Alonzo.Rules.Utxo
6363
Cardano.Ledger.Alonzo.Rules.Utxos
6464
Cardano.Ledger.Alonzo.Rules.Utxow
65+
Cardano.Ledger.Alonzo.State.Account
6566
Cardano.Ledger.Alonzo.State.CertState
6667
Cardano.Ledger.Alonzo.State.Stake
6768
Cardano.Ledger.Alonzo.TxCert

eras/alonzo/impl/golden/pparams-update.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"maxCollateralInputs": 45,
1919
"maxTxSize": 881284740,
2020
"maxValueSize": 39,
21-
"minPoolCost": 392044,
21+
"minPoolCost": 855261,
2222
"monetaryExpansion": 0.7810966919969065,
2323
"poolPledgeInfluence": 8.319022570290014789e16,
2424
"poolRetireMaxEpoch": 1843493333,
25-
"stakePoolDeposit": 3827864344574364691,
25+
"stakePoolDeposit": 275624,,
2626
"stakePoolTargetNum": 10900,
2727
"treasuryCut": 0.234167131785253734
28-
}
28+
}

0 commit comments

Comments
 (0)