-
Notifications
You must be signed in to change notification settings - Fork 720
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
Reduce number of calls to toLedgerPParams #4903
Reduce number of calls to toLedgerPParams #4903
Conversation
1115ae1
to
916f76a
Compare
FWIW, from a user perspective (in plutus-apps), I'd be happy with this change. 👍 |
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.
Nice 👍 A few minor comments
cardano-api/src/Cardano/Api/Fees.hs
Outdated
@@ -236,31 +237,30 @@ estimateTransactionFee _ _ _ (ByronTx _) = | |||
-- | |||
evaluateTransactionFee :: forall era. | |||
IsShelleyBasedEra era | |||
=> ProtocolParameters | |||
=> Ledger.PParams (ShelleyLedgerEra era) |
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 probably the most sensible/least complicated way to go even if we are breaking the interface. We need to expose Ledger.PParams
via Cardano.Api.Shelley
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.
We also need to update the changelog with the breaking change.
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.
Change log updated.
-> Ledger.PParams (ShelleyLedgerEra era) | ||
-> BundledProtocolParameters era | ||
|
||
bundleProtocolParams :: CardanoEraStyle era -> ProtocolParameters -> BundledProtocolParameters era |
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.
We can refactor this by changing the type sig to bundleProtocolParams :: CardanoEra era -> ProtocolParameters -> BundledProtocolParameters era
and moving the call to cardanoEraStyle
into this function.
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.
Done!
3ae784b
to
9b36afb
Compare
@newhoggy Now that we can build this repo with ghc-9.2.5, do you check see if this problem was fixed?https://gitlab.haskell.org/ghc/ghc/-/issues/20036 I suspect the reason why I suspect that it was actually fixed. And if it is then we could switch back to the In case that ghc-8.10.7 is still important we could even do this to not mess up the older version: #if __GLASGOW_HASKELL__ >= 902
{-# INLINE noInlineMaybeToStrictMaybe #-}
#else
{-# NOINLINE noInlineMaybeToStrictMaybe #-}
#endif Edit - I attached my ddump-timings results for the module, but it would be better if you could confirm it 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.
LGTM! One minor comment.
9b36afb
to
1ae6005
Compare
65c0024
to
bc0539f
Compare
bc0539f
to
668f030
Compare
…n be computed once as passed around. Bundle ProtocolParameters and Ledger.PParams (ShelleyLedgerEra era) into BundledProtocolParams era so that both case be passed around together. The constructor arguments are lazy so that values that are expensive to compute aren't computed unecessarily. Update changelog
668f030
to
228889f
Compare
We call
toLedgerPParams
multiple times with the same arguments. This function is expensive.The PR calls
toLedgerPParams
once then re-uses the result. It is necessary to introduce new functions and change the signature of existing functions to do this.Resolves #4622