Skip to content

Commit

Permalink
Merge pull request #3368 from input-output-hk/lehins/conway-genesis-a…
Browse files Browse the repository at this point in the history
…s-translation-context

Set `ConwayGenesis` as `TranslationContext` for Conway
  • Loading branch information
lehins committed Apr 5, 2023
2 parents 302e46f + 64fa6d7 commit f10f06f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
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
}

0 comments on commit f10f06f

Please sign in to comment.