-
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
Integrate latest ledger dependencies #5013
Conversation
4e608b3
to
7479aca
Compare
3325f00
to
68e0cfa
Compare
LGTM |
68e0cfa
to
f1d99ff
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.
Thank you @lehins for propagating the changes from ledger. I just have a couple comments
- I think the
ProtocolParameter
related improvments that are not directly related to ledger changes should be in a separate PR. - I'd prefer to not use lenses if we don't have to. We're not updating the fields of deeply nested structures and I think the lenses further obfuscate the code vs record accessors which immediately give me information/context about the data structure I am updating.
There are many good refactors here 👍 . We should definitely organize a call next week so you can take us through the changes.
They are all related to the ledger changes, so they can't be extracted into a separate PR. PParams and PParamsUpdate have been completely redone in the latest version of ledger. Here is the relevant PR: IntersectMBO/cardano-ledger#3242
We have to. Every single field in almost every ledger type family is now to be manipulated by a dedicated lens.
In the matter of fact we are. This is how you'd add inputs to a transaction: > let addInputs tx ins = tx & bodyTxL . inputsTxBodyL <>~ ins
> :t addInputs
addInputs
:: EraTx era => Tx era -> Set (TxIn (EraCrypto era)) -> Tx era It is important to note that this function here will work for all eras. This is the power of lenses from ledger, not only that they allow to modify nested structure. Moreover. Both > let txTotalAda tx = fold $ fmap (\txOut -> txOut ^. coinTxOutL) (tx ^. bodyTxL . outputsTxBodyL)
> :t txTotalAda
txTotalAda :: EraTx era => Tx era -> Coin Same applies to PParams. For example here is a lens that will let you set and get protocol version from PParams for any era: > :t ppProtocolVersionL
ppProtocolVersionL :: EraPParams era => Lens' (PParams era) ProtVer If a field was added at a later era then it will be guarded by a specific type class that allows using the lens from specific era onwards, eg > :t ppCostModelsL
ppCostModelsL :: AlonzoEraPParams era => Lens' (PParams era) CostModels Before that we were using PParams with the hacky Long story short, lenses are the new designated way to deal with ledger types that can change across eras.
Thank you. Sounds good with me. |
372096a
to
ce36e79
Compare
FWIW, I think lenses are way easier than type families provided the lens API is discoverable. In your example, how easy is it to find all the accessors for the expression: For example you have |
Those are great questions! We have a proper |
cb79e12
to
b1b4e38
Compare
* Start using newer version of libsystemd-journal from CHaP with fixed bounds
e1374d9
to
4dbf214
Compare
* Account for recent changes in consensus and ledger * Reduce a whole lot of duplication * Move all orphan instances for types defined in cardano-base and cardano-ledger into their own respective packages * Fix a bug where only metadata from TxAuxData was hashed upon transaction body creation with `createTransactionBody` * Change representation of CostModel. It is no longer a mapping from param name to values, but instead a list with values, where order of value dictates the mapping to param names of a plutus cost model for a particular plutus version * ToJSON instance for CostModel and consequently for ProtocolParameters will now produce a list of values instead of a key value mapping.
4dbf214
to
b5265b5
Compare
The goal of this PR is to integrate latest changes in the cardano-ledger, which accrued over the period of the last few months. Most notable breaking changes in ledger are:
Besides integrating ledger this PR also:
CostModel
createTransactionBody
calculateMinimumUTxO
funciton: