Skip to content

Commit

Permalink
add Babbage to tx-generator (stubs)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcFontaine authored and Jimbo4350 committed Apr 6, 2022
1 parent 6729e16 commit 3f19137
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ assumeMapCosts _proxy = stepFunction [
ShelleyBasedEraMary -> 39
-- Unconfirmed ! update when alonzo is runnable.
ShelleyBasedEraAlonzo -> error "39"
ShelleyBasedEraBabbage -> error "39"

-- Bytestring costs are not LINEAR !!
-- Costs are piecewise linear for payload sizes [0..23] and [24..64].
Expand Down Expand Up @@ -127,6 +128,7 @@ metadataInEra (Just m) = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxMetadataInEra TxMetadataInAllegraEra m
ShelleyBasedEraMary -> TxMetadataInEra TxMetadataInMaryEra m
ShelleyBasedEraAlonzo -> TxMetadataInEra TxMetadataInAlonzoEra m
ShelleyBasedEraBabbage -> TxMetadataInEra TxMetadataInBabbageEra m

mkMetadata :: forall era . IsShelleyBasedEra era => Int -> Either String (TxMetadataInEra era)
mkMetadata 0 = Right $ metadataInEra Nothing
Expand All @@ -140,6 +142,7 @@ mkMetadata size
ShelleyBasedEraAllegra -> 39
ShelleyBasedEraMary -> 39
ShelleyBasedEraAlonzo -> 39 -- TODO: check minSize for Alonzo
ShelleyBasedEraBabbage -> 39 -- TODO: check minSize for Babbage
nettoSize = size - minSize

-- At 24 the CBOR representation changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback =
(ShelleyBasedEraAllegra, ShelleyTx _ tx') -> GenTxAllegra (mkShelleyTx tx')
(ShelleyBasedEraMary, ShelleyTx _ tx') -> GenTxMary (mkShelleyTx tx')
(ShelleyBasedEraAlonzo, ShelleyTx _ tx') -> GenTxAlonzo (mkShelleyTx tx')
(ShelleyBasedEraBabbage, ShelleyTx _ _tx') -> error "TODO:Babbage"

fromGenTxId :: GenTxId CardanoBlock -> TxId
fromGenTxId (Block.GenTxIdShelley (Mempool.ShelleyTxId i)) = fromShelleyTxId i
Expand Down
10 changes: 8 additions & 2 deletions bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ mkGenesisTransaction key _payloadSize ttl fee txins txouts
ShelleyBasedEraAllegra -> TxFeeExplicit TxFeesExplicitInAllegraEra fee
ShelleyBasedEraMary -> TxFeeExplicit TxFeesExplicitInMaryEra fee
ShelleyBasedEraAlonzo -> TxFeeExplicit TxFeesExplicitInAlonzoEra fee
ShelleyBasedEraBabbage -> TxFeeExplicit TxFeesExplicitInBabbageEra fee
validityUpperBound = case shelleyBasedEra @ era of
ShelleyBasedEraShelley -> TxValidityUpperBound ValidityUpperBoundInShelleyEra ttl
ShelleyBasedEraAllegra -> TxValidityUpperBound ValidityUpperBoundInAllegraEra ttl
ShelleyBasedEraMary -> TxValidityUpperBound ValidityUpperBoundInMaryEra ttl
ShelleyBasedEraAlonzo -> TxValidityUpperBound ValidityUpperBoundInAlonzoEra ttl

ShelleyBasedEraBabbage -> TxValidityUpperBound ValidityUpperBoundInBabbageEra ttl

mkTransaction :: forall era .
IsShelleyBasedEra era
=> SigningKey PaymentKey
Expand Down Expand Up @@ -132,6 +134,7 @@ mkFee f = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxFeeExplicit TxFeesExplicitInAllegraEra f
ShelleyBasedEraMary -> TxFeeExplicit TxFeesExplicitInMaryEra f
ShelleyBasedEraAlonzo -> TxFeeExplicit TxFeesExplicitInAlonzoEra f
ShelleyBasedEraBabbage -> TxFeeExplicit TxFeesExplicitInBabbageEra f

mkValidityUpperBound :: forall era .
IsShelleyBasedEra era
Expand All @@ -142,6 +145,7 @@ mkValidityUpperBound ttl = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxValidityUpperBound ValidityUpperBoundInAllegraEra ttl
ShelleyBasedEraMary -> TxValidityUpperBound ValidityUpperBoundInMaryEra ttl
ShelleyBasedEraAlonzo -> TxValidityUpperBound ValidityUpperBoundInAlonzoEra ttl
ShelleyBasedEraBabbage -> TxValidityUpperBound ValidityUpperBoundInBabbageEra ttl

mkTransactionGen :: forall era .
IsShelleyBasedEra era
Expand Down Expand Up @@ -206,7 +210,8 @@ mkTxOutValueAdaOnly l = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxOutAdaOnly AdaOnlyInAllegraEra l
ShelleyBasedEraMary -> TxOutValue MultiAssetInMaryEra $ lovelaceToValue l
ShelleyBasedEraAlonzo -> TxOutValue MultiAssetInAlonzoEra $ lovelaceToValue l

ShelleyBasedEraBabbage -> TxOutValue MultiAssetInBabbageEra $ lovelaceToValue l

txOutValueToLovelace :: TxOutValue era -> Lovelace
txOutValueToLovelace = \case
TxOutAdaOnly AdaOnlyInByronEra x -> x
Expand All @@ -222,3 +227,4 @@ txInModeCardano tx = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxInMode tx AllegraEraInCardanoMode
ShelleyBasedEraMary -> TxInMode tx MaryEraInCardanoMode
ShelleyBasedEraAlonzo -> TxInMode tx AlonzoEraInCardanoMode
ShelleyBasedEraBabbage -> TxInMode tx BabbageEraInCardanoMode
1 change: 1 addition & 0 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ withEra :: (forall era. IsShelleyBasedEra era => AsType era -> ActionM x) -> Act
withEra action = do
era <- get $ User TEra
case era of
AnyCardanoEra BabbageEra -> action AsBabbageEra
AnyCardanoEra AlonzoEra -> action AsAlonzoEra
AnyCardanoEra MaryEra -> action AsMaryEra
AnyCardanoEra AllegraEra -> action AsAllegraEra
Expand Down
2 changes: 2 additions & 0 deletions bench/tx-generator/src/Cardano/Benchmarking/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ genTx protocolParameters (collateral, collFunds) fee metadata witness inFunds ou
ShelleyBasedEraAllegra -> TxValidityNoUpperBound ValidityNoUpperBoundInAllegraEra
ShelleyBasedEraMary -> TxValidityNoUpperBound ValidityNoUpperBoundInMaryEra
ShelleyBasedEraAlonzo -> TxValidityNoUpperBound ValidityNoUpperBoundInAlonzoEra
ShelleyBasedEraBabbage -> TxValidityNoUpperBound ValidityNoUpperBoundInBabbageEra

newtype WalletScript era = WalletScript { runWalletScript :: IO (WalletStep era) }

Expand Down Expand Up @@ -232,3 +233,4 @@ mkTxOutValueAdaOnly l = case shelleyBasedEra @ era of
ShelleyBasedEraAllegra -> TxOutAdaOnly AdaOnlyInAllegraEra l
ShelleyBasedEraMary -> TxOutValue MultiAssetInMaryEra $ lovelaceToValue l
ShelleyBasedEraAlonzo -> TxOutValue MultiAssetInAlonzoEra $ lovelaceToValue l
ShelleyBasedEraBabbage -> TxOutValue MultiAssetInBabbageEra $ lovelaceToValue l

0 comments on commit 3f19137

Please sign in to comment.