Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ConwayGenesis as TranslationContext for Conway #3368

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Add `EncCBOR`/`DecCBOR` and `ToCBOR`/`FromCBOR` for `ConwayTallyPredFailure`
* Add `ToCBOR`/`FromCBOR` for `ConwayGovernance`
* Remove `cgAlonzoGenesis` from `ConwayGenesis`.
* Set `ConwayGenesis` as `TranslationContext`

### `testlib`

Expand Down
9 changes: 5 additions & 4 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Cardano.Ledger.Babbage.TxBody (BabbageTxOut (..), Datum (..))
import Cardano.Ledger.Binary (DecoderError)
import Cardano.Ledger.Conway.Core hiding (Tx)
import Cardano.Ledger.Conway.Era (ConwayEra)
import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..))
import Cardano.Ledger.Conway.Scripts ()
import Cardano.Ledger.Conway.Tx ()
import qualified Cardano.Ledger.Core as Core (Tx)
Expand Down Expand Up @@ -56,7 +57,7 @@ import Lens.Micro
-- being total. Do not change it!
--------------------------------------------------------------------------------

type instance TranslationContext (ConwayEra c) = API.GenDelegs c
type instance TranslationContext (ConwayEra c) = ConwayGenesis c

instance Crypto c => TranslateEra (ConwayEra c) NewEpochState where
translateEra ctxt nes =
Expand Down Expand Up @@ -112,16 +113,16 @@ instance Crypto c => TranslateEra (ConwayEra c) EpochState where
}

instance Crypto c => TranslateEra (ConwayEra c) API.LedgerState where
translateEra newGenDelegs ls =
translateEra conwayGenesis ls =
pure
API.LedgerState
{ API.lsUTxOState = translateEra' newGenDelegs $ API.lsUTxOState ls
{ API.lsUTxOState = translateEra' conwayGenesis $ API.lsUTxOState ls
, API.lsDPState = updateGenesisKeys $ API.lsDPState ls
}
where
updateGenesisKeys (DPState dstate pstate) = DPState dstate' pstate
where
dstate' = dstate {dsGenDelegs = newGenDelegs}
dstate' = dstate {dsGenDelegs = cgGenDelegs conwayGenesis}

instance Crypto c => TranslateEra (ConwayEra c) UTxOState where
translateEra ctxt us =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway (Conway)
import Cardano.Ledger.Conway.Core
import Cardano.Ledger.Conway.Delegation.Certificates (ConwayDCert (..))
import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..))
import Cardano.Ledger.Conway.Rules (ConwayLEDGER)
import Cardano.Ledger.Conway.Translation ()
import Cardano.Ledger.Conway.Tx (AlonzoTx (..))
Expand Down Expand Up @@ -205,5 +206,8 @@ exampleConwayNewEpochState =
emptyPParams
(emptyPParams & ppCoinsPerUTxOByteL .~ CoinPerByte (Coin 1))

exampleConwayGenesis :: GenDelegs c
exampleConwayGenesis = GenDelegs Map.empty
exampleConwayGenesis :: ConwayGenesis c
exampleConwayGenesis =
ConwayGenesis
{ cgGenDelegs = GenDelegs Map.empty
}