-
Notifications
You must be signed in to change notification settings - Fork 721
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
tx-generator: stop supporting Byron and use more recent API way to handle eras #6087
base: master
Are you sure you want to change the base?
Conversation
7880076
to
615930a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScopedTypeVariables
could also be dropped, not that this should be held up for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a chance to switch return
to pure
in selectCollateralFunds
and interpretPayMode
if it wouldn't slow you down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can sneak more cleanups in here, that would be great e.g.
diff --git a/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs b/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs
index f412dcdc7..c401bd1c7 100644
--- a/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs
+++ b/bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs
@@ -1,7 +1,6 @@
-{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE NamedFieldPuns #-}
-{-# LANGUAGE RankNTypes #-}
-{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE ViewPatterns #-}
{- HLINT ignore "Use map" -}
@@ -49,9 +48,8 @@ genesisSecureInitialFund :: ()
genesisSecureInitialFund sbe networkId genesis srcKey destKey TxGenTxParams{txParamFee, txParamTTL}
= case genesisInitialFundForKey sbe networkId genesis srcKey of
Nothing -> Left $ TxGenError "genesisSecureInitialFund: no fund found for given key in genesis"
- Just (_, lovelace) ->
- let txOutValue = lovelaceToTxOutValue sbe $ lovelace - txParamFee
- in genesisExpenditure sbe networkId srcKey destAddr txOutValue txParamFee txParamTTL destKey
+ Just (_, lovelaceToTxOutValue sbe . subtract txParamFee -> txOutValue) ->
+ genesisExpenditure sbe networkId srcKey destAddr txOutValue txParamFee txParamTTL destKey
where
destAddr = keyAddress sbe networkId destKey
@@ -128,7 +126,7 @@ mkGenesisTransaction sbe key ttl fee txins txouts
(createAndValidateTransactionBody sbe txBodyContent)
where
txBodyContent = defaultTxBodyContent sbe
- & setTxIns (zip txins $ repeat $ BuildTxWith $ KeyWitness KeyWitnessForSpending)
+ & setTxIns (map (, BuildTxWith $ KeyWitness KeyWitnessForSpending) txins)
& setTxOuts txouts
& setTxFee (mkTxFee sbe fee)
& setTxValidityLowerBound TxValidityNoLowerBound
No need to hold up the show if it's too much of a bother.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be worth getting in there too:
@@ -75,9 +73,9 @@ genesisInitialFundForKey :: ()
-> SigningKey PaymentKey
-> Maybe (AddressInEra era, L.Coin)
genesisInitialFundForKey sbe networkId genesis key
- = find (isTxOutForKey . fst) (genesisInitialFunds sbe networkId genesis)
+ = find isTxOutForKey $ genesisInitialFunds sbe networkId genesis
where
- isTxOutForKey = (keyAddress sbe networkId key ==)
+ isTxOutForKey = (keyAddress sbe networkId key ==) . fst
genesisTxInput ::
NetworkId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NadiaYvette> I did the changes, except for the usage of ViewPatterns
. I think ViewPatterns
is a niche extension that augments the entry-level to a codebase, usually for little gain. Feel free to amend yourself!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I think ScopedTypeVariables
can go too wrt. extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍
This is great too. I can't do an approve/etc. yet because it says it's WIP & whatever went on with the flake and garnix checks, but the instant those bits are all cleared up, I'm ready to hit the approve button. |
These were not strictly necessary, as opposed to the previous commit.
615930a
to
851c531
Compare
@NadiaYvette> I acted on your comments and this is now ready to go IMO. You can ignore the Garnix and flake.nix checks. Those are not required yet as they are still being worked on. |
Convert to draft until @mgmeier confirms that we can drop Byron support. |
Note
On top of #6085
Description
IsShelleyBasedEra
, which is not the usual way to interact withcardano-api
anymore.ShelleyBasedEra era
witness instead.shelleyBasedEra
. Passing the witness around makes sure the era being used is consistent.Checklist
hlint
. See.github/workflows/check-hlint.yml
to get thehlint
versionstylish-haskell
. See.github/workflows/stylish-haskell.yml
to get thestylish-haskell
version