-
Notifications
You must be signed in to change notification settings - Fork 155
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
Problematic cost model serialization #2902
Comments
I talked with @Soupstraw , @bezirg, and @michaelpj, we made this plan: The Plan
How this works, new language built-insSuppose version During major protocol
During major protocol
How this works, new Plutus versionsSuppose version During major protocol
|
... which might be an error. Do we need to store the underlying
This only applies for node |
Won't it be rejected before that for simply not being recognized as a known language by node
This is currently not happening: we should change this. We're currently relying on the absence of the cost model to disable a version. Although in the scenario you mention, node |
I agree with @michaelpj on this. The ledger calls into the
I think we can enforce this on plutus-master by having a simple extra check inside
Yes, an extra guard on our side can be helpful in case of mismatch of plutus code version with ledger code version |
@JaredCorduan your logic makes sense.
The problem and this thing with the type families I don't get at all, so no ideas from my side. |
@JaredCorduan If we add a check on our side to reject language versions that shouldn't be enabled in particular protocol versions, we have a choice about whether we include it in |
a) if we make it phase1 error, we preclude submitting+executing any new-language scrips until HF. I don't know if there is a use-case to do (b). |
I guess it maybe prevents you from submitting a reference script with a new language version before the HF? Does the ledger deserialization refuse to deserialize transactions containing newer scripts from newer languages before the HF? |
exactly
good catch, thank you! I will edit The Plan.
yes, another good catch! I'll edit that as well.
I also much prefer if Plutus could gaurd this for us as well, otherwise it depends on the timing of the updates (ie the governance has to remember that they must never update the new cost model an epoch before the HF vote, etc).
yea, no worries, this is a problem on the ledger side
That would be great. If we want to allow folks to create reference scripts in advance for unreleased languages, we would need a similar scheme for transaction outputs as we've just made for the cost models. It's the same problem: the current serialization scheme for transaction outputs does not allow for new languages in reference scripts, and we can only guarantee that folks have the new software after a hard fork. Having the Let me leave future Jared some proof that the current serialization scheme is not flexible: Babbage uses the same script type as alonzo: Reference scripts are just deserialized as cbor-in-cbor scripts: Alonzo script type deserialization is not flexible wrt languages: |
Absolutely. We can add this to our not-yet-existent list of guiding principles. (it's not dogma, everything is still open for discussion, though). |
I think I would actively prefer it if they can't :D |
That's definitely my preference as well, I was just trying to tease out the implications (a weak form of a proof by contradiction :) ) |
the last piece of the puzzle here will be solved by #3014 🙌 (namely how to gracefully change the serialization at a hardfork boundary) |
🤣 this was accidentally and automatically resolved by me saying:
|
@JaredCorduan AI at its finest. Joking, it was a regex "AI" |
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
Starting in version 9, 'CostModels' can now be deserialized from any map from Word8 values to lists of integers. Only valid cost models are actual converted to cost models. resolves #2902
🎉 |
@lehins and I had a discussion on this, and the conclusion is that there are a few problems with the "How this works, new language built-ins" part, and it doesn't currently work:
|
So, what we have discussed in this context is I think:
Does that sound about right? |
Also it would be super if we could somehow set up a test for this. I don't know if the ledger has cross-hard-fork tests? |
I think your first two points are related to the case where we add a new Plutus version, but the problem here is with adding new builtins to an existing Plutus version.
The solution outlined above says: "If mkEvaluationContext receives fewer integers than it needs (for a given version of Plutus), it will return an error message". And this has always been how it works. If we change |
We'll also need to make sure there's no significant performance overhead if we need to check the condition at script evaluation time. |
Right, so it is more subtle. Perhaps the tightest solution is to fail iff we are missing parameters that are needed for a builtin in the script at hand. But that's tricky. One way we could do it would be to set any missing parameters to |
Ok, we might have a solution for this, which would require minimal amount of work. The most important part of the solution is for This would mean that plutus script execution could receive I also suggested we implement an optional primitive like that right now, which would work if we had 234 parameters in PV9. This would actually allow us to write some tests for this behavior before we hard fork into Conway. |
By the way, The Plan above says:
I believe both are phase-1 failures, not phase-2. |
Yes, that will be either In both cases that will have to be plutus script deserialization failure |
The current cost model serialization scheme is problematic:
https://github.com/input-output-hk/cardano-ledger/blob/2505b7f103c78ee5a230b3e302e31d9607fffbd5/eras/babbage/test-suite/cddl-files/babbage.cddl#L324-L327
The are two problems:
V3
cost model in the same protocol parameter update that initiates a hard fork. We can only count on nodes to be updated after a hard fork (chainChecks provides this fantastic guarantee), and so nodes that have not updated would not be able to deserialize aV3
cost model. This is operationally annoying for us, and also means we have to wait an extra epoch to use new versions of Plutus.We need a more flexible serialization scheme that address these two problems. Note that the ledger deserializes the CBOR list of integers into a map by using keys provided to us by the Plutus library (where the list is assumed to be ordered corresponding to the alphabetical sorting of the key).
The text was updated successfully, but these errors were encountered: