Skip to content

Commit 6c37635

Browse files
committed
Viable approach in the works. In process of removing UMap in favor of AccountStates
Simplify Transition and reuse it in shelley-test Add mkTestAccountState and addAccountState
1 parent 2ee717f commit 6c37635

File tree

186 files changed

+3217
-3093
lines changed

Some content is hidden

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

186 files changed

+3217
-3093
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ library
4646
Cardano.Ledger.Allegra.Rules.Ppup
4747
Cardano.Ledger.Allegra.Rules.Utxo
4848
Cardano.Ledger.Allegra.Rules.Utxow
49+
Cardano.Ledger.Allegra.State.Account
4950
Cardano.Ledger.Allegra.State.CertState
5051
Cardano.Ledger.Allegra.State.Stake
5152
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class
2222
) =>
2323
AllegraEraTest era
2424

25-
instance EraTest AllegraEra
25+
instance EraTest AllegraEra where
26+
mkTestAccountState = mkShelleyTestAccountState
27+
28+
accountsFromAccountsMap = shelleyAccountsFromAccountsMap
29+
30+
accountsToUMap = shelleyAccountsToUMap
2631

2732
instance ShelleyEraTest AllegraEra
2833

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ library
6161
Cardano.Ledger.Alonzo.Rules.Utxo
6262
Cardano.Ledger.Alonzo.Rules.Utxos
6363
Cardano.Ledger.Alonzo.Rules.Utxow
64+
Cardano.Ledger.Alonzo.State.Account
6465
Cardano.Ledger.Alonzo.State.CertState
6566
Cardano.Ledger.Alonzo.State.Stake
6667
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": 855059,
25+
"stakePoolDeposit": 275624,
2626
"stakePoolTargetNum": 10900,
2727
"treasuryCut": 0.234167131785253734
28-
}
28+
}

0 commit comments

Comments
 (0)