Skip to content

Commit bb9b5a1

Browse files
authored
PLT-1552: Better support for Plutus Core language versions (#5150)
* Rename defaultVersion to latestVersion * Add some more support for versions * Move Version Pretty instance to its module * Fixup applyProgram * Update plutus-ledger-api, update language for CIP-35 * Add version to PIR programs * Changelogs * Address some comments * Fixup plutus-core * Make applyProgram return a Maybe * More changelog * Comment
1 parent b94d0e0 commit bb9b5a1

File tree

224 files changed

+520
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+520
-294
lines changed

doc/read-the-docs-site/tutorials/AuctionValidator.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ auctionValidatorScript ::
193193
CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
194194
auctionValidatorScript params =
195195
$$(PlutusTx.compile [||auctionUntypedValidator||])
196-
`PlutusTx.applyCode` PlutusTx.liftCode params
196+
`PlutusTx.unsafeApplyCode` PlutusTx.liftCode params
197197
-- BLOCK9

doc/read-the-docs-site/tutorials/BasicPlutusTx.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ addOne = $$(compile [|| \(x:: Integer) -> x `addInteger` 1 ||])
116116
addOneToN :: Integer -> CompiledCode Integer
117117
addOneToN n =
118118
addOne
119-
-- 'applyCode' applies one 'CompiledCode' to another.
120-
`applyCode`
119+
-- 'unsafeApplyCode' applies one 'CompiledCode' to another.
120+
`unsafeApplyCode`
121121
-- 'liftCode' lifts the argument 'n' into a
122122
-- 'CompiledCode Integer'.
123123
liftCode n
@@ -167,9 +167,9 @@ makeLift ''EndDate
167167
pastEndAt :: EndDate -> Integer -> CompiledCode Bool
168168
pastEndAt end current =
169169
pastEnd
170-
`applyCode`
170+
`unsafeApplyCode`
171171
liftCode end
172-
`applyCode`
172+
`unsafeApplyCode`
173173
liftCode current
174174

175175
{- |

plutus-benchmark/cek-calibration/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ go n = zipl (mkList n) (rev $ mkList n)
6868

6969

7070
mkListProg :: Integer -> UPLC.Program NamedDeBruijn DefaultUni DefaultFun ()
71-
mkListProg n = Tx.getPlcNoAnn $ $$(Tx.compile [|| go ||]) `Tx.applyCode` Tx.liftCode n
71+
mkListProg n = Tx.getPlcNoAnn $ $$(Tx.compile [|| go ||]) `Tx.unsafeApplyCode` Tx.liftCode n
7272

7373
mkListTerm :: Integer -> UPLC.Term NamedDeBruijn DefaultUni DefaultFun ()
7474
mkListTerm n =

plutus-benchmark/ed25519-throughput/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ verifyInputs hash d =
170170
-- verification script to that.
171171
mkSigCheckScript :: Integer -> UProg
172172
mkSigCheckScript n =
173-
Tx.getPlcNoAnn $ $$(Tx.compile [|| verifyInputs builtinHash ||]) `Tx.applyCode` Tx.liftCode (mkInputsAsData n haskellHash)
173+
Tx.getPlcNoAnn $ $$(Tx.compile [|| verifyInputs builtinHash ||]) `Tx.unsafeApplyCode` Tx.liftCode (mkInputsAsData n haskellHash)
174174

175175
-- Printing utilities
176176
percentage :: (Integral a, Integral b) => a -> b -> Double

plutus-benchmark/lists/src/PlutusBenchmark/Lists/Sort/GhcSort.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ghcSortWorstCase = mergeSortWorstCase
7272

7373
mkGhcSortTerm :: [Integer] -> Term
7474
mkGhcSortTerm l =
75-
compiledCodeToTerm $ $$(Tx.compile [|| ghcSort ||]) `Tx.applyCode` Tx.liftCode l
75+
compiledCodeToTerm $ $$(Tx.compile [|| ghcSort ||]) `Tx.unsafeApplyCode` Tx.liftCode l
7676

7777
mkWorstCaseGhcSortTerm :: Integer -> Term
7878
mkWorstCaseGhcSortTerm = mkGhcSortTerm . ghcSortWorstCase

plutus-benchmark/lists/src/PlutusBenchmark/Lists/Sort/InsertionSort.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ insertionSortWorstCase n = [1..n]
2929

3030
mkInsertionSortTerm :: [Integer] -> Term
3131
mkInsertionSortTerm l =
32-
compiledCodeToTerm $ $$(Tx.compile [|| insertionSort ||]) `Tx.applyCode` Tx.liftCode l
32+
compiledCodeToTerm $ $$(Tx.compile [|| insertionSort ||]) `Tx.unsafeApplyCode` Tx.liftCode l
3333

3434
mkWorstCaseInsertionSortTerm :: Integer -> Term
3535
mkWorstCaseInsertionSortTerm = mkInsertionSortTerm . insertionSortWorstCase

plutus-benchmark/lists/src/PlutusBenchmark/Lists/Sort/MergeSort.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mergeSortWorstCase n = f [1..n]
5050

5151
mkMergeSortTerm :: [Integer] -> Term
5252
mkMergeSortTerm l =
53-
compiledCodeToTerm $ $$(Tx.compile [|| mergeSort ||]) `Tx.applyCode` Tx.liftCode l
53+
compiledCodeToTerm $ $$(Tx.compile [|| mergeSort ||]) `Tx.unsafeApplyCode` Tx.liftCode l
5454

5555
mkWorstCaseMergeSortTerm :: Integer -> Term
5656
mkWorstCaseMergeSortTerm = mkMergeSortTerm . mergeSortWorstCase

plutus-benchmark/lists/src/PlutusBenchmark/Lists/Sort/QuickSort.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ quickSortWorstCase n = reverse [1..n]
3434

3535
mkQuickSortTerm :: [Integer] -> Term
3636
mkQuickSortTerm l =
37-
compiledCodeToTerm $ $$(Tx.compile [|| quickSort ||]) `Tx.applyCode` Tx.liftCode l
37+
compiledCodeToTerm $ $$(Tx.compile [|| quickSort ||]) `Tx.unsafeApplyCode` Tx.liftCode l
3838

3939
mkWorstCaseQuickSortTerm :: Integer -> Term
4040
mkWorstCaseQuickSortTerm = mkQuickSortTerm . quickSortWorstCase

plutus-benchmark/lists/src/PlutusBenchmark/Lists/Sum/Compiled.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ sumRightScott l = foldRightScott (+) 0 l
3737
-- Compiling to PLC terms
3838

3939
mkSumLeftScottCode :: [Integer] -> Tx.CompiledCode Integer
40-
mkSumLeftScottCode l = $$(Tx.compile [|| sumLeftScott ||]) `Tx.applyCode` Tx.liftCode l
40+
mkSumLeftScottCode l = $$(Tx.compile [|| sumLeftScott ||]) `Tx.unsafeApplyCode` Tx.liftCode l
4141

4242
mkSumLeftScottTerm :: [Integer] -> Term
4343
mkSumLeftScottTerm l = compiledCodeToTerm $ mkSumLeftScottCode l
4444

4545
mkSumRightScottCode :: [Integer] -> Tx.CompiledCode Integer
46-
mkSumRightScottCode l = $$(Tx.compile [|| sumRightScott ||]) `Tx.applyCode` Tx.liftCode l
46+
mkSumRightScottCode l = $$(Tx.compile [|| sumRightScott ||]) `Tx.unsafeApplyCode` Tx.liftCode l
4747

4848
mkSumRightScottTerm :: [Integer] -> Term
4949
mkSumRightScottTerm l = compiledCodeToTerm $ mkSumRightScottCode l
@@ -69,13 +69,13 @@ sumRightBuiltin l = foldRightBuiltin B.addInteger 0 l
6969
-- Compiling to PLC terms
7070

7171
mkSumRightBuiltinCode :: [Integer] -> Tx.CompiledCode Integer
72-
mkSumRightBuiltinCode l = $$(Tx.compile [|| sumRightBuiltin ||]) `Tx.applyCode` Tx.liftCode (BI.BuiltinList l)
72+
mkSumRightBuiltinCode l = $$(Tx.compile [|| sumRightBuiltin ||]) `Tx.unsafeApplyCode` Tx.liftCode (BI.BuiltinList l)
7373

7474
mkSumRightBuiltinTerm :: [Integer] -> Term
7575
mkSumRightBuiltinTerm l = compiledCodeToTerm $ mkSumRightBuiltinCode l
7676

7777
mkSumLeftBuiltinCode :: [Integer] -> Tx.CompiledCode Integer
78-
mkSumLeftBuiltinCode l = $$(Tx.compile [|| sumLeftBuiltin ||]) `Tx.applyCode` Tx.liftCode (BI.BuiltinList l)
78+
mkSumLeftBuiltinCode l = $$(Tx.compile [|| sumLeftBuiltin ||]) `Tx.unsafeApplyCode` Tx.liftCode (BI.BuiltinList l)
7979

8080
mkSumLeftBuiltinTerm :: [Integer] -> Term
8181
mkSumLeftBuiltinTerm l = compiledCodeToTerm $ mkSumLeftBuiltinCode l
@@ -137,13 +137,13 @@ listToDataList l = Tx.dataToBuiltinData (go l)
137137
go (x:xs) = Tx.Constr 1 [Tx.I x, go xs]
138138

139139
mkSumRightDataCode :: [Integer] -> Tx.CompiledCode Integer
140-
mkSumRightDataCode l = $$(Tx.compile [|| sumRightData ||]) `Tx.applyCode` Tx.liftCode (listToDataList l)
140+
mkSumRightDataCode l = $$(Tx.compile [|| sumRightData ||]) `Tx.unsafeApplyCode` Tx.liftCode (listToDataList l)
141141

142142
mkSumRightDataTerm :: [Integer] -> Term
143143
mkSumRightDataTerm l = compiledCodeToTerm $ mkSumRightDataCode l
144144

145145
mkSumLeftDataCode :: [Integer] -> Tx.CompiledCode Integer
146-
mkSumLeftDataCode l = $$(Tx.compile [|| sumLeftData ||]) `Tx.applyCode` Tx.liftCode (listToDataList l)
146+
mkSumLeftDataCode l = $$(Tx.compile [|| sumLeftData ||]) `Tx.unsafeApplyCode` Tx.liftCode (listToDataList l)
147147

148148
mkSumLeftDataTerm :: [Integer] -> Term
149149
mkSumLeftDataTerm l = compiledCodeToTerm $ mkSumLeftDataCode l

plutus-benchmark/nofib/exe/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ main = do
315315
Primetest n -> if n<0 then Hs.error "Positive number expected"
316316
else print $ Prime.runPrimalityTest n
317317
DumpPLC pa ->
318-
traverse_ putStrLn $ unindent . prettyPlcClassicDebug . UPLC.mkDefaultProg . getTerm $ pa
318+
traverse_ putStrLn $ unindent . prettyPlcClassicDebug . UPLC.Program () PLC.latestVersion . getTerm $ pa
319319
where unindent d = map (dropWhile isSpace) $ (Hs.lines . Hs.show $ d)
320320
DumpFlatNamed pa ->
321-
writeFlatNamed . UPLC.mkDefaultProg . getTerm $ pa
321+
writeFlatNamed . UPLC.Program () PLC.latestVersion . getTerm $ pa
322322
DumpFlatDeBruijn pa ->
323-
writeFlatDeBruijn . UPLC.mkDefaultProg . toAnonDeBruijnTerm . getTerm $ pa
323+
writeFlatDeBruijn . UPLC.Program () PLC.latestVersion . toAnonDeBruijnTerm . getTerm $ pa
324324
SizesAndBudgets
325325
-> printSizesAndBudgets
326326
-- Write the output to stdout and let the user deal with redirecting it.

0 commit comments

Comments
 (0)