Skip to content

Commit

Permalink
Merge pull request #3361 from input-output-hk/lehins/drop-alonzo-gene…
Browse files Browse the repository at this point in the history
…sis-from-conway-genesis

Drop alonzo genesis from conway genesis
  • Loading branch information
lehins committed Mar 29, 2023
2 parents ec86caf + cb0f630 commit d9cf28a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Add `RatifyFailure` to `ConwayNewEpochPredFailure` #3339
* Add `EncCBOR`/`DecCBOR` and `ToCBOR`/`FromCBOR` for `ConwayTallyPredFailure`
* Add `ToCBOR`/`FromCBOR` for `ConwayGovernance`
* Remove `cgAlonzoGenesis` from `ConwayGenesis`.

### `testlib`

Expand Down
4 changes: 2 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ instance (Crypto c, DSignable c (Hash c EraIndependentTxBody)) => API.ApplyBlock

instance Crypto c => API.CanStartFromGenesis (ConwayEra c) where
type AdditionalGenesisConfig (ConwayEra c) = ConwayGenesis c
fromShelleyPParams cg =
translateEra' (cgGenDelegs cg) . API.fromShelleyPParams (cgAlonzoGenesis cg)
fromShelleyPParams =
error "Unimplemented: Current interface is too limited and needs replacement for Conway to work"

instance Crypto c => ExtendedUTxO (ConwayEra c) where
txInfo = babbageTxInfo
Expand Down
30 changes: 13 additions & 17 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Cardano.Ledger.Conway.Genesis (
)
where

import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis, alonzoGenesisAesonPairs)
import Cardano.Ledger.Binary (
DecCBOR (..),
EncCBOR (..),
Expand All @@ -26,15 +25,13 @@ import Cardano.Ledger.Core
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Keys (GenDelegs (..))
import Data.Aeson (FromJSON (..), ToJSON, object, withObject, (.:))
import qualified Data.Aeson as Aeson (Value (Object))
import Data.Aeson.Types (KeyValue (..), ToJSON (..))
import Data.Unit.Strict (forceElemsToWHNF)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)

data ConwayGenesis c = ConwayGenesis
{ cgAlonzoGenesis :: !AlonzoGenesis
, cgGenDelegs :: !(GenDelegs c)
newtype ConwayGenesis c = ConwayGenesis
{ cgGenDelegs :: GenDelegs c
}
deriving (Eq, Generic, Show)

Expand All @@ -46,27 +43,26 @@ instance Crypto c => DecCBOR (ConwayGenesis c)
instance Crypto c => EncCBOR (ConwayGenesis c)

instance Crypto c => ToCBOR (ConwayGenesis c) where
toCBOR ConwayGenesis {cgAlonzoGenesis, cgGenDelegs} =
toEraCBOR @(ConwayEra c) $
encode $
Rec ConwayGenesis
!> To cgAlonzoGenesis
!> To cgGenDelegs
toCBOR cg@(ConwayGenesis _) =
let ConwayGenesis {cgGenDelegs} = cg
in toEraCBOR @(ConwayEra c) $
encode $
Rec ConwayGenesis
!> To cgGenDelegs

instance Crypto c => FromCBOR (ConwayGenesis c) where
fromCBOR =
eraDecoder @(ConwayEra c) $
decode $
RecD ConwayGenesis
<! From
<! From

instance Crypto c => ToJSON (ConwayGenesis c) where
toJSON (ConwayGenesis alonzoGenesis genDelegs) =
object (alonzoGenesisAesonPairs alonzoGenesis ++ ["genDelegs" .= toJSON genDelegs])
toJSON cg@(ConwayGenesis _) =
let ConwayGenesis {cgGenDelegs} = cg
in object ["genDelegs" .= toJSON cgGenDelegs]

instance Crypto c => FromJSON (ConwayGenesis c) where
parseJSON = withObject "ConwayGenesis" $ \obj -> do
alonzoGenesis <- parseJSON (Aeson.Object obj)
genDelegs <- forceElemsToWHNF obj .: "genDelegs"
pure $ ConwayGenesis alonzoGenesis genDelegs
cgGenDelegs <- forceElemsToWHNF obj .: "genDelegs"
pure $ ConwayGenesis {cgGenDelegs}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Test.Cardano.Ledger.Common
import Test.Cardano.Ledger.Mary.Arbitrary (genMintValues)

instance Crypto c => Arbitrary (ConwayGenesis c) where
arbitrary = ConwayGenesis <$> arbitrary <*> arbitrary
arbitrary = ConwayGenesis <$> arbitrary

instance Crypto c => Arbitrary (ConwayDCert c) where
arbitrary =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ module Test.Cardano.Ledger.Shelley.Serialisation.EraIndepGenerators (genCoherent
import qualified Cardano.Crypto.DSIGN as DSIGN
import qualified Cardano.Crypto.KES as KES
import Cardano.Crypto.Util (SignableRepresentation)
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.BaseTypes (
BlockNo (..),
SlotNo (..),
)
import Cardano.Ledger.Crypto (DSIGN, KES, VRF)
import Cardano.Ledger.Crypto (DSIGN, KES)
import Cardano.Ledger.Shelley.API hiding (SignedDSIGN)
import Cardano.Ledger.Shelley.Core
import Cardano.Protocol.TPraos.API (PraosCrypto)
Expand Down Expand Up @@ -43,7 +42,6 @@ genCoherentBlock ::
forall era.
( EraSegWits era
, Arbitrary (Tx era)
, VRF.Signable (VRF (EraCrypto era)) ~ SignableRepresentation
, KES.Signable (KES (EraCrypto era)) ~ SignableRepresentation
, DSIGN.Signable (DSIGN (EraCrypto era)) ~ SignableRepresentation
, PraosCrypto (EraCrypto era)
Expand Down
2 changes: 1 addition & 1 deletion libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/Out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-- +++ OK, passed 100 tests.
module Cardano.Ledger.Api.Tx.Out (
module Cardano.Ledger.Api.Tx.Address,
EraTxOut,
EraTxOut (TxOut),
mkBasicTxOut,

-- ** Value
Expand Down

0 comments on commit d9cf28a

Please sign in to comment.