-
Notifications
You must be signed in to change notification settings - Fork 483
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
Why does the txInfoMint
Value
contain 0
lovelace?
#5039
Comments
There are generally no guarantees about the particular representation of |
Javascript libraries are however dependent on APIs like Blockfrost to submit transactions, and if those APIs decide to use a version of cardano-cli that always includes So in this case I could say that Blockfrost/cardano-cli must support 'both' ways, and somehow must detect that the minting script was originally executed without I think it really makes more sense to enforce normalization of any |
I'm sorry, I don't understand your objection. A system that claims to calculate the budget for scripts must behave the same as the Cardano node, otherwise it is wrong. It sounds like you've found a bug in whatever Blockfrost is using. |
Blockfrost uses cardano-cli to check the execution budget. During that check cardano-cli prepends 0 lovelace to the minted Value. This is obviously also what cardano-node does, so this isn't a bug. But doing this does incur unnecessary execution budget. Think of this as low-hanging fruit for optimization. |
Do you happen to know how much the additional cost is? |
I've seen about a 10% hit on cpu and mem budget for typical minting scripts. |
That's a lot of percent... You write:
Are there some versions of
This sounds like an argument in favor of normalizing the |
I am more convinced by the performance argument indeed. I'm surprised at the numbers, though, and I'd like to see some benchmarks. Perversely, I almost appreciate the current behaviour because it forces people to properly account for the fact that values might not be normalized. If we start normalizing them then we will likely have to commit to always being careful to do so, since people will start to assume it. |
@christianschmitz would you be interested in providing us with such benchmarks?
Also a very good point. But if we were to leave some |
The following issue was caused by not prepending the 0 lovelace value to The following two files can be used as benchmarks to compare a normalized
The difference is:
|
Thank you very much @christianschmitz, this is extremely helpful.
@michaelpj these are great numbers, I think the @christianschmitz's proposal is very worth a consideration. However, would the sums-of-products thing incorporate these changes? I.e. is it the parsing that is so expensive here? Or is it something else? |
So I don't think the sums-of-products CIP will influence this. |
@michaelpj have you by any chance spent some more time thinking about this issue? Maybe, you know, in the evening, when you sit with the family, but something deeply unsettling is disturbing your soul and makes you eventually stand up and shout "screw it! What about the zero lovelace issue?". Anyways, for now I'm going to mark this issue as "low priority", since it's what we've been doing for all optimization tickets. |
I have not been thinking about it and tbh I don't think it's going to make it to the top of the list soon. |
@christianschmitz Thank you for bring this up. This would actually be a ledger change, as ledger is responsible for populating the script context. We cannot change the behavior for |
The Hydra team also stumbled over this. We are +1 for making this an empty value instead. |
+1 for making this an empty value. Right now, the behavior is completely unintuitive, and introduces a ton of issues in development. You would expect to be able to check that nothing is minted with I don't think this is just an optimization issue, it is a developer experience issue. |
You can do this... if you have a correct equality function! |
With a correct equality function this should return false, because it is not actually the case the the value is empty. You can do this if you have a weird hacky equality function that checks that the normalized value is empty. Introducing arbitrary abstraction like that always leads to problems down the road because the user don't actually understand what is going on and what the equality function is doing. |
This issue has been resolved, see this comment. |
I noticed that when cardano-cli creates the
ScriptContext
to calculate the execution budget, eachValue
instance will always contain some lovelace, even thetxInfoMint
Value
.Of course the lovelace entry in
txInfoMint
will always be0
, so I was quite surprised to see that the0
lovelace entry is always prepended totxInfoMint
when creating theScriptContext
(was a particularly difficult to debug issue for the Helios execution budget calculator).Always including this is also seems wasteful, as minting policy contracts will usually do some iterating over all the entries in the
txInfoMint
map.Another reason not to include it is that it would be nice for the index of the asset being minted in
txInfoMint
to correspond directly with the Minting redeemer index.So my two questions:
txInfoMint
contain0
lovelace?0
lovelace be removed fromtxInfoMint
?The text was updated successfully, but these errors were encountered: