-
Notifications
You must be signed in to change notification settings - Fork 156
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
Reference scripts for PlutusV1
#3965
Comments
Couple more useful plots depicting the continuing popularity of PlutusV1 scripts: The total size of PlutusV1 scripts with respect to the total size of all blocks over time as a percentage. If, on this plot, we saw a trend of PlutusV1 scripts being used less and less over time, then we could have argued that with time this problem could have resolved itself. However, it does not seem to be the case. PlutusV1 is still a very popular language version and from the plot below it is clear that it still even more often than PlutusV2 |
@lehins Excellent analysis, thank you! I'm a bit disappointed that we'll have to artificially inflate prices (by around 0.3 ADA per transaction, by my calculations) just to avoid the (IMO very) remote chance that someone somewhere deployed a plutus v1 script that depends on the fee being large (which is already a dangerous script, since the protocol parameters could be updated regardless)... but if that's what is needed to get this merged, I'm more than happy to deal with it 😛 |
Does this mean that we'll see the blockchain database shrink by 60GB or is this a solution for future transactions? |
We can't rewrite history 😁Future transactions only. And only when users choose to switch using ref scripts.9:08 PM, January 3, 2024, "$conrad" ***@***.***>:
Does this mean that we'll see the blockchain database shrink by 60GB or is this a solution for future transactions?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
Отправлено из мобильной Яндекс.Почты: http://m.ya.ru/ymail
|
Thank you! But Cardano Node could, somehow, find a way of compressing this data, right? I.e., all redundant data (the repeated SCs) could be compressed to save space, no? |
@conraddit Probably not worth compressing it although it's possible. Other solutions like pruning and mithril can help us with the on-disk requirements as the chain continues to grow. |
I would say the best thing to focus on now is to prevent further growing the chain unnecessarily and improving performance by allowing Plutus v1 reference scripts |
@conraddit Also, see this comment regarding the on-disk space: cardano-foundation/CIPs#679 (comment) TL;DR: Deduplicating things on disk may be an additional local optimization the node can apply (though any time you "break up" the data in a block and require it to be re-assembled, you introduce a lot of complexity and risk) irrespective of the on-chain semantics described by the linked CIP. The far more urgent issue is the limitations for data on the wire. |
Great analysis! |
We did come to a conclusion that it is feasible and desirable to implement this feature for Conway |
I hope this change has more to do with insuring that SPOs get paid for the work the node has to do to lookup the reference input and deserialize the script (as the linked CIP suggests); and has nothing to do with using the fee field to infer inside a PlutusV1 script whether the script is in the witness set or provided via reference inputs. If it is the second case as suggested here, then this change does not prevent Plutus V1 scripts from being capable of infering whether they were provided in a witness set or in a reference input. You can still write a Plutus V1 script that achieves this by constructing the expected txbody from the script context with the missing components passed in via redeemers / token names, then hashing the result and validating that it matches the txId in the script context. You use this to validate against tx metadata or any other part of the transaction body that is inaccessible directly from the script context. |
Correct.
That is not possible in general, since CBOR is non canonical, so even if you have all of the information from the transaction, the hash of the body will depend on how that information was encoded. An example would be was variable length encoding or exact length encoding was used when encoding inputs in the transaction body. There is just no way to know this without looking at the actual binary version of the transaction, which Plutus does not have an access to. There is chance that you could be able to reconstruct the original transaction of the body from Plutus context and verify it with the hash of the body available to plutus, but if you can't, it doesn't mean you are missing some information. You might be just encoding the transaction in a different way. You could try all possibilities, but that would be too expensive. In any case, I don't think this is that big of a deal, because Plutus script would really have to go out of its way to try and infer where the script is coming from: Witness set vs reference input, which is not the case we really care about. Our concern is primarily ensuring we do not affect PlutusContext accidentally in a way that would affect execution of normal PlutusV1 scripts. Which does not seem to be a problem for enabling reference scripts for PlutusV1 |
You could pass in those encoding decisions in the redeemer. That being said, I think @colll78's point was more to highlight that it's a bit impractical to use a standard of "can we come up with any script that could conceivably be written to differentiate between the before and after" as a standard, and hopefully the standard we're using is at least a little closer to "is it very very unlikely that this will break any existing scripts?". It's encouraging to get confirmation that it is indeed closer to the later. |
You can pass the whole transaction body in serialized form in the redeemer 😄 I was merely trying to explain that there is no guarantee that a script can reliably reconstruct the transaction body just from the PlutusContext.
Absolutely. |
You cannot, there is a cyclic relationship between the redeemer and the Without this method, the original method of a script checking the txFee field to determine it is present in the reference inputs or witness set does not work, because the on-chain transaction size effects the fee, and the tx metadata effects the size, so there isn't any way to distinguish between whether the fee change difference is a result of tx metadata being present or if it is the result of scripts being included in the witness set. |
Moreover, there is also
Oh, yeah, I keep forgetting about
All of this would be necessary because the script would have to first reconstruct the That would be one complex script for no good reason. 🙂 |
As a side note, if you really had to, you could use this trick to validate the transaction metadata inside of a script heh |
You can actually just pass
That was the exact intended purpose for which this solution came to exist haha, shout out to @MicroProofs for his help iterating on this ( |
It has been brought to our attention that PlutusV1 scripts occupy around 40% of the whole blockchain since Alonzo. Natural solution to this problem is to enable reference scripts for PlutusV1 in Conway
Here is the relevant CIP: cardano-foundation/CIPs#679
The proposed solution in the above CIP is too complicated for no good reason. We can just enable the reference scripts. However this will require #3952 since we need mitigate the worries that @WhatisRT mentioned where one could use a fee field to infer inside a PlutusV1 script whether the script was provided in a witness set or in a reference input.
In order to confirm the report and the proposed solution of using reference scripts we did some investigation. We wrote a program that replays the chain and counts up the sizes of all of the Plutus scripts in all of the blocks per epoch starting from beginning of Alonzo until Christmas 2023. Here is the plot for the calculated data:
It is clear that reference scripts are a great solution to the problem.
This plot is just the zoomed version of only the PlutusV2 sizes:
The pie chart below depicts the percentage of the on-chain data occupied by PlutusV1 (red), PlutusV2 (yellow) the rest of the data (blue):
It was noted on Github that 60Gb overhead by scripts is not that big when comparing to other blockchains, which is true, but 41% of the total blockchain data is too much.
The text was updated successfully, but these errors were encountered: