You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NB:See `class GetPlutusScriptPurpose` to understand the purpose of the ledger constraints in `Witnessable thing era` constructor.
104
+
82
105
And the upshot is once we have `[(Witnessable thing era, AnyWitness era)]` these can be uniformly treated to construct the redeemer pointer map (`Redeemers era`):
@@ -112,7 +145,7 @@ data IndexedPlutusScriptWitness witnessable (lang :: L.Language) (purpose :: Plu
112
145
```
113
146
114
147
Wedo away with `cardano-api`'s `ScriptWitnessIndex` and directly use `cardano-ledger`'s `PlutusPurposeAsIx era` which is essentially the same thing.
115
-
The benefit here is we get to use ledger type classes to calculate the index of the plutus script witness thing we are interested in:
148
+
The benefit here is we get to use ledger type classes to produce the index of the plutus script witness thing we are interested in:
116
149
117
150
```haskell
118
151
classGetPlutusScriptPurposeerawhere
@@ -130,6 +163,8 @@ instance GetPlutusScriptPurpose era where
130
163
toPlutusScriptPurpose index WitProposal{} =L.mkProposingPurpose (L.AsIx index)
131
164
```
132
165
166
+
The ledger constraints in the `Witnessable thing era` data constructors allow us to directly construct the script witness index (`PlutusPurpose AsIx era`) with the `toPlutusScriptPurpose` class method. We no longer have to use the old api's `ScriptWitnessIndex` which is eventually converted into a `PlutusPurpose AsIx era`. This approach is more direct.
167
+
133
168
This ultimately allows us to collapse all of the different index calculation functions into a single function:
WhyPlutusRunnable?Mainly for deserialization benefits.The deserialization of this type looks at the major protocol version and the script language to determine if indeed the script is runnable.
198
+
WhyPlutusRunnable?Mainly for deserialization benefits.The deserialization of this type looks at the major protocol version and the script language to determine if indeed the script is runnable.This is the decode CBOR instance in `cardano-ledger`:
199
+
200
+
```haskell
201
+
instancePlutusLanguagel=>DecCBOR (PlutusRunnablel) where
202
+
decCBOR =do
203
+
plutus <- decCBOR
204
+
pv <- getDecoderVersion
205
+
either (fail.show) pure$ decodePlutusRunnable pv plutus
206
+
```
207
+
`decodePlutusRunnable` eventually calls a deserialization function in the `plutus` repo which will fail if
208
+
the plutus script version you are using is not available in a given era.
209
+
210
+
A ficticious example: The plutus team introduces PlutusV4. This plutus script version can only be used in the era after Conway (Conway + 1).
211
+
However a user tries to use a PlutusV4 script in Conway. Because we use `PlutusRunnable` to represent our plutus scripts we would get a deserialization error.
212
+
If we stuck with `ShortByteString` to represent plutus scripts, the error would only occur at transaction submission or when using `transaction build`.
213
+
This is a small QOL improvement as now if your script deserializes at least you know it's valid for a particular era.
0 commit comments