Skip to content

Commit b605662

Browse files
committed
Merge branch 'master' of github.com:IntersectMBO/plutus into uplc2025
2 parents 0690a9a + fc78c36 commit b605662

File tree

595 files changed

+8216
-2878
lines changed

Some content is hidden

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

595 files changed

+8216
-2878
lines changed

.github/workflows/manual-benchmark.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ jobs:
2929
- name: Checkout
3030
uses: actions/checkout@v4.3.0
3131
with:
32-
# We need at least one commit before master to compare against
33-
fetch-depth: 5
32+
# It's possible that new commits get merged into master since the PR
33+
# was opened. We need a safe buffer to make sure that our use of merge-head
34+
# leter always finds the true parent of the first PR commit.
35+
fetch-depth: 100
3436

3537
- name: React With Rocket
3638
uses: actions/github-script@v7.1.0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ TestCert.*
120120
**/_site/**/**
121121
**/.jekyll-metadata
122122
**/.jekyll-cache
123+
worktrees

cardano-constitution/cardano-constitution.cabal

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: cardano-constitution
3-
version: 1.53.0.0
3+
version: 1.54.0.0
44
license: Apache-2.0
55
license-files:
66
LICENSE
@@ -86,10 +86,10 @@ library
8686
, base >=4.9 && <5
8787
, containers
8888
, filepath
89-
, plutus-core ^>=1.53
90-
, plutus-ledger-api ^>=1.53
91-
, plutus-tx ^>=1.53
92-
, plutus-tx-plugin ^>=1.53
89+
, plutus-core ^>=1.54
90+
, plutus-ledger-api ^>=1.54
91+
, plutus-tx ^>=1.54
92+
, plutus-tx-plugin ^>=1.54
9393
, regex-tdfa
9494
, safe
9595
, template-haskell
@@ -132,10 +132,10 @@ test-suite cardano-constitution-test
132132
, containers
133133
, directory
134134
, filepath
135-
, plutus-core ^>=1.53
135+
, plutus-core ^>=1.54
136136
, plutus-core:plutus-core-testlib
137-
, plutus-ledger-api ^>=1.53
138-
, plutus-tx ^>=1.53
137+
, plutus-ledger-api ^>=1.54
138+
, plutus-tx ^>=1.54
139139
, QuickCheck
140140
, serialise
141141
, tasty
@@ -152,4 +152,4 @@ executable create-json-envelope
152152
build-depends:
153153
, base
154154
, cardano-constitution
155-
, plutus-ledger-api ^>=1.53
155+
, plutus-ledger-api ^>=1.54
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Upcoming Features",
3+
"position": 75,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Features that are being developed and will be available in future versions of Plutus."
7+
}
8+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Builtin Arrays
6+
7+
:::danger Upcoming Feature
8+
**This is an upcoming feature that is not yet available for use.** The `BuiltinArray` type and related functions are currently under development and will be included in a future version of Plutus. This documentation is provided for preview purposes only.
9+
:::
10+
11+
For multiple lookups by index, `BuiltinArray` provides significantly better performance than lists. The key advantage is in the lookup operations themselves.
12+
13+
**Lookup Performance Comparison:**
14+
A single lookup at index 99 of a 100-element data structure shows that the CPU cost for lookup on a standard Plinth list (`[Integer]`, a sum-of-products type) is **206 times higher** than on a `BuiltinArray`.
15+
16+
**Important Considerations:**
17+
Currently, `BuiltinArray` creation is implemented as conversion from lists, which involves traversing the entire list. This conversion cost should be factored into your performance calculations - the dramatic lookup performance improvement needs to be amortized over multiple lookups to justify the conversion overhead.
18+
19+
As a rule of thumb, if you only need to perform a single lookup, the conversion cost may not be worthwhile. The benefits become apparent when performing several lookups on the same data structure.
20+
21+
**Future Development:**
22+
In future language versions, arrays are planned to be added to the `Data`-encoded `ScriptContext` precisely to avoid these high conversion costs, allowing arrays to be provided directly without requiring conversion from lists.
23+
24+
## Choosing Arrays vs Lists
25+
26+
When designing your data structures, consider your access patterns:
27+
28+
**Choose arrays when:**
29+
- You need multiple index-based lookups (e.g., `arr[42]`, `arr[17]`)
30+
- Your access pattern is primarily random access rather than sequential
31+
- The data structure size is relatively stable after creation
32+
- You're building lookup tables or similar structures
33+
34+
**Choose lists when:**
35+
- You primarily need sequential access (head/tail operations, pattern matching)
36+
- You frequently prepend elements (`:` operator)
37+
- Your access pattern is mostly single-pass iteration
38+
- You're following functional programming patterns that work naturally with lists
39+
40+
**Current limitations:**
41+
Note that you can't always choose arrays "from the start" because data often comes from external sources as lists (like elements in `ScriptContext`). This is why the conversion scenario is currently common, and why future versions plan to provide arrays directly in these contexts.
42+
43+
Functions for working with `BuiltinArray` are available in the `PlutusTx.Builtins` module:
44+
45+
```haskell
46+
import PlutusTx.Builtins
47+
( BuiltinArray
48+
, indexArray
49+
, listToArray
50+
, lengthOfArray
51+
)
52+
```
53+
54+
<details>
55+
<summary>Lookup comparison: SOP List vs. BuiltinList vs. BuiltinArray</summary>
56+
<LiteralInclude file="Example/Builtin/Array/Main.hs" language="haskell" />
57+
58+
Result of the evaluation:
59+
![BuiltinArray Performance Comparison](/code/Example/Builtin/Array/Screenshot.png)
60+
</details>

doc/docusaurus/docs/using-plinth/evaluating-plinth.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ sidebar_position: 12
88

99
However, it is also possible to evaluate `CompiledCode` without running a node. The Plutus evaluator, called the CEK Machine, can be used independently of the Cardano node for testing and troubleshooting. By evaluating Plinth programs locally, developers can not only obtain the immediate result of the code but also access the traces emitted during evaluation and the consumed execution budget.
1010

11+
:::info Version Information
12+
This functionality was released in version 1.47.
13+
:::
14+
1115
Let's consider the following example Plinth program:
1216
<LiteralInclude
1317
file="Example/Evaluation/Main.hs"
@@ -27,9 +31,12 @@ To compile it, use the `compile` function as described earlier in the [Compiling
2731
start="-- BEGIN CompiledCode"
2832
end="-- END CompiledCode" />
2933

30-
To evaluate `compiledCode`, add the `plutus-tx` and `plutus-ledger-api` dependencies to your cabal file:
34+
To evaluate `compiledCode`, add the following dependencies to your cabal file:
3135
```cabal
32-
build-depends: plutus-tx, plutus-ledger-api
36+
build-depends:
37+
plutus-tx,
38+
plutus-tx:plutus-tx-testlib,
39+
plutus-ledger-api
3340
```
3441

3542
This allows you to import the necessary functionality:

doc/docusaurus/docs/working-with-scripts/other-optimization-techniques.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ Traces can be expensive especially in terms of script sizes.
128128
It is advisable to use traces during development, but to remove them when deploying your scripts on mainnet.
129129
Traces can be removed via the `remove-trace` plugin flag.
130130

131+
## Using `BuiltinArray` for index-based lookups
132+
133+
For optimizing multiple index-based lookups, see the upcoming [Builtin Arrays](../upcoming-features/builtin-arrays.md) feature.
134+
135+
131136
## Using `error` for faster failure
132137

133138
Plutus scripts have access to one impure effect, `error`, which immediately terminates the script evaluation and will fail validation.

doc/docusaurus/docusaurus-examples.cabal

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ library docusaurus-code
4040

4141
build-depends:
4242
, base >=4.9 && <5
43-
, plutus-core ^>=1.53
44-
, plutus-ledger-api ^>=1.53
45-
, plutus-tx ^>=1.53
46-
, plutus-tx-plugin ^>=1.53
43+
, plutus-core ^>=1.54
44+
, plutus-ledger-api ^>=1.54
45+
, plutus-tx ^>=1.54
46+
, plutus-tx-plugin ^>=1.54
4747

4848
executable example-cip57
4949
import: lang, ghc-version-support, os-support
@@ -54,9 +54,9 @@ executable example-cip57
5454
build-depends:
5555
, base ^>=4.18
5656
, containers
57-
, plutus-ledger-api ^>=1.53
58-
, plutus-tx ^>=1.53
59-
, plutus-tx-plugin ^>=1.53
57+
, plutus-ledger-api ^>=1.54
58+
, plutus-tx ^>=1.54
59+
, plutus-tx-plugin ^>=1.54
6060

6161
executable example-evaluation
6262
import: lang, ghc-version-support, os-support
@@ -66,9 +66,30 @@ executable example-evaluation
6666
other-modules: Paths_docusaurus_examples
6767
build-depends:
6868
, base ^>=4.18
69-
, plutus-ledger-api ^>=1.53
70-
, plutus-tx ^>=1.53
71-
, plutus-tx-plugin ^>=1.53
69+
, plutus-ledger-api ^>=1.54
70+
, plutus-tx ^>=1.54
71+
, plutus-tx-plugin ^>=1.54
72+
, plutus-tx:plutus-tx-testlib
73+
, text
74+
75+
ghc-options:
76+
-Wno-missing-signatures -fno-full-laziness
77+
-fno-ignore-interface-pragmas -fno-omit-interface-pragmas
78+
-fno-spec-constr -fno-specialise -fno-strictness
79+
-fno-unbox-small-strict-fields -fno-unbox-strict-fields
80+
81+
executable example-builtin-array
82+
import: lang, ghc-version-support, os-support
83+
main-is: Example/Builtin/Array/Main.hs
84+
hs-source-dirs: static/code
85+
default-language: Haskell2010
86+
other-modules: Paths_docusaurus_examples
87+
build-depends:
88+
, base ^>=4.18
89+
, colourista
90+
, plutus-core ^>=1.54
91+
, plutus-tx ^>=1.54
92+
, plutus-tx-plugin ^>=1.54
7293
, plutus-tx:plutus-tx-testlib
7394
, text
7495

@@ -88,6 +109,6 @@ executable quickstart
88109
, base >=4.9 && <5
89110
, base16-bytestring
90111
, bytestring
91-
, plutus-ledger-api ^>=1.53
92-
, plutus-tx ^>=1.53
93-
, plutus-tx-plugin ^>=1.53
112+
, plutus-ledger-api ^>=1.54
113+
, plutus-tx ^>=1.54
114+
, plutus-tx-plugin ^>=1.54

0 commit comments

Comments
 (0)