Skip to content

Commit

Permalink
Rename and improve the Plutus foundation page (#6488)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 committed Sep 18, 2024
1 parent e56ab73 commit 2d3b78e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
sidebar_position: 10
---

# Plutus Core and Plutus Tx

Understanding the roles and relationships between different languages is key to the effective and efficient development of smart contracts.

## Untyped Plutus Core

Untyped Plutus Core (UPLC), also known simply as Plutus Core or Plutus, is a low-level, Turing-complete language based on untyped lambda calculus, a simple and well-established computational model that dates back to the 1930s.
Thanks to its simplicity and extensive academic research, the need for updates or modifications to the language over time is minimal, ensuring long-term stability.
It also facilitates the creation of simple, formally verified evaluators.

Along with UPLC and its evaluator, we provide a compiler from Plutus Tx, a subset of Haskell, to UPLC.
However, UPLC can be an easy compilation target for any language that supports functional-style programming, in particular immutable data and higher-order functions, both of which are widely adopted today in programming languages, and are particularly suited to Cardano's UTXO ledger model, where UTXOs are immutable.

UPLC is the code that runs on-chain, i.e., by every node validating the transaction, using an interpreter known as the CEK machine.
A UPLC program included in a Cardano transaction is often referred to as a Plutus script or a Plutus validator.

### Typed Plutus Core and Plutus IR

Typed Plutus Core (TPLC) is the intrinsically typed counterpart of UPLC.
It is based on higher-order polymorphic lambda calculus with isorecursive types (System Fωμ).
TPLC serves as a low-level intermediate representation (IR) for the Plutus Tx compiler.
TPLC is closely related to UPLC, and compiling TPLC into UPLC is simply a matter of erasing types.

Plutus IR (PIR) is a high-level IR also used by the Plutus Tx compiler.
It extends TPLC by adding recursive bindings and recursive data types.
The fact that recursion is explicit in PIR, rather than encoded using fixed point operators as in TPLC and UPLC, makes PIR significantly more readable than TPLC and UPLC.
When optimizing the cost or size of Plutus scripts written in Plutus Tx, it is usually useful to look into PIR.

## Plutus Tx

Plutus Tx, the primary focus of this user guide, is a high-level language for writing the validation logic of the contract, the logic that determines whether a transaction is allowed to perform things such as spending a UTXO, minting or burning assets, and more.
Plutus Tx is not a new language, but rather a subset of Haskell, and it is compiled into UPLC.

There are several other high-level languages available as alternatives to Plutus Tx, all of which compile to UPLC.
See [Overview of Languages Compiling to UPLC](../delve-deeper/languages.md) for more information.

## Further reading

The formal details of Plutus Core are in its [specification](https://github.com/IntersectMBO/plutus#specifications-and-design).

PIR is discussed in [_Unraveling recursion: compiling an IR with recursion to System F_](https://iohk.io/en/research/library/papers/unraveling-recursion-compiling-an-ir-with-recursion-to-system-f/).
39 changes: 0 additions & 39 deletions doc/docusaurus/docs/essential-concepts/plutus-foundation.md

This file was deleted.

2 changes: 1 addition & 1 deletion doc/docusaurus/docs/essential-concepts/plutus-platform.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 15
---

# Plutus platform
Expand Down

1 comment on commit 2d3b78e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Plutus Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 2d3b78e Previous: e56ab73 Ratio
validation-auction_1-2 650.4 μs 617.4 μs 1.05
validation-auction_1-3 856.6 μs 616.1 μs 1.39
validation-crowdfunding-success-2 223.6 μs 204.8 μs 1.09
validation-escrow-redeem_1-1 485.8 μs 341.7 μs 1.42
validation-escrow-redeem_1-2 487.1 μs 342.4 μs 1.42
validation-escrow-redeem_2-1 569.1 μs 399.1 μs 1.43
validation-escrow-redeem_2-2 569.4 μs 400.1 μs 1.42
validation-escrow-redeem_2-3 568.6 μs 401.9 μs 1.41
validation-escrow-refund-1 216.7 μs 152.4 μs 1.42
validation-future-increase-margin-1 345.3 μs 243.7 μs 1.42
validation-game-sm-success_1-1 544.8 μs 381.3 μs 1.43
validation-game-sm-success_1-2 277.1 μs 194.7 μs 1.42
validation-game-sm-success_1-3 896 μs 628 μs 1.43
validation-game-sm-success_1-4 315.6 μs 222.2 μs 1.42
validation-game-sm-success_2-1 545.2 μs 416.1 μs 1.31
validation-game-sm-success_2-2 277.6 μs 252.2 μs 1.10
validation-game-sm-success_2-3 893.3 μs 636 μs 1.40
validation-game-sm-success_2-4 314.6 μs 222.3 μs 1.42
validation-game-sm-success_2-5 896.4 μs 736.1 μs 1.22
validation-multisig-sm-1 556.6 μs 393.3 μs 1.42
validation-multisig-sm-2 542.1 μs 383.3 μs 1.41
validation-multisig-sm-3 548.4 μs 387.2 μs 1.42
validation-multisig-sm-4 551.3 μs 390 μs 1.41
validation-multisig-sm-5 781.9 μs 553.7 μs 1.41
validation-multisig-sm-6 554.3 μs 393.2 μs 1.41
validation-multisig-sm-7 542.3 μs 384 μs 1.41
validation-multisig-sm-8 547.5 μs 387.7 μs 1.41
validation-multisig-sm-9 552.8 μs 390.7 μs 1.41
validation-multisig-sm-10 781.8 μs 551.5 μs 1.42
validation-ping-pong-1 454.1 μs 321.8 μs 1.41
validation-ping-pong-2 454.8 μs 320.8 μs 1.42
validation-ping-pong_2-1 276 μs 195.9 μs 1.41
validation-prism-1 233.8 μs 165.1 μs 1.42
validation-prism-2 571.9 μs 405 μs 1.41
validation-prism-3 511.4 μs 360.9 μs 1.42
validation-pubkey-1 197.8 μs 151.7 μs 1.30
validation-stablecoin_1-1 1107 μs 936.4 μs 1.18
validation-decode-auction_1-3 756.6 μs 661.2 μs 1.14
validation-decode-auction_1-4 247 μs 209 μs 1.18
validation-decode-auction_2-1 225.8 μs 214.1 μs 1.05
validation-decode-auction_2-3 754.5 μs 693.6 μs 1.09
validation-decode-game-sm-success_2-3 736.6 μs 589.6 μs 1.25
validation-decode-game-sm-success_2-4 233.4 μs 171.3 μs 1.36
validation-decode-multisig-sm-1 706.1 μs 574.7 μs 1.23
validation-decode-multisig-sm-2 819.6 μs 619.7 μs 1.32
marlowe-semantics/0000020002010200020101020201000100010001020101020201010000020102 447.3 μs 360.6 μs 1.24
marlowe-role-payout/0101000100000101010000010101000100010101000001000001000000010101 260.6 μs 198.1 μs 1.32
marlowe-role-payout/01dcc372ea619cb9f23c45b17b9a0a8a16b7ca0e04093ef8ecce291667a99a4c 232.5 μs 163.1 μs 1.43
marlowe-role-payout/0201020201020000020000010201020001020200000002010200000101010100 260.7 μs 183 μs 1.42
marlowe-role-payout/0202010002010100020102020102020001010101020102010001010101000100 242.6 μs 170.4 μs 1.42
marlowe-role-payout/1a20b465d48a585ffd622bd8dc26a498a3c12f930ab4feab3a5064cfb3bc536a 265.6 μs 186.9 μs 1.42
marlowe-role-payout/211e1b6c10260c4620074d2e372c260d38643a3d605f63772524034f0a4a7632 252.1 μs 177.7 μs 1.42
marlowe-role-payout/21a1426fb3fb3019d5dc93f210152e90b0a6e740ef509b1cdd423395f010e0ca 266.1 μs 187.7 μs 1.42
marlowe-role-payout/224ce46046fab9a17be4197622825f45cc0c59a6bd1604405148e43768c487ef 242.5 μs 171 μs 1.42
marlowe-role-payout/332c2b1c11383d1b373e1315201f1128010e0e1518332f273f141b23243f2a07 231.6 μs 163.6 μs 1.42
marlowe-role-payout/3565ee025317e065e8555eef288080276716366769aad89e03389f5ec4ce26d7 256.4 μs 180.9 μs 1.42
marlowe-role-payout/3569299fc986f5354d02e627a9eaa48ab46d5af52722307a0af72bae87e256dc 237.7 μs 167.5 μs 1.42
marlowe-role-payout/36866914aa07cf62ef36cf2cd64c7f240e3371e27bb9fff5464301678e809c40 237.2 μs 167.1 μs 1.42
marlowe-role-payout/371c10d2526fc0f09dbe9ed59e44dcd949270b27dc42035addd7ff9f7e0d05e7 283.5 μs 200.1 μs 1.42
marlowe-role-payout/3897ef714bba3e6821495b706c75f8d64264c3fdaa58a3826c808b5a768c303d 245.7 μs 173.5 μs 1.42
marlowe-role-payout/4121d88f14387d33ac5e1329618068e3848445cdd66b29e5ba382be2e02a174a 284.1 μs 200.8 μs 1.41
marlowe-role-payout/4299c7fcf093a5dbfe114c188e32ca199b571a7c25cb7f766bf49f12dab308be 261.7 μs 184.4 μs 1.42
marlowe-role-payout/452e17d16222a427707fa83f63ffb79f606cc25c755a18b1e3274c964ed5ec99 292.6 μs 205.5 μs 1.42
marlowe-role-payout/46f8d00030436e4da490a86b331fa6c3251425fb8c19556080e124d75bad7bd6 238.6 μs 168.4 μs 1.42
marlowe-role-payout/47364cfaf2c00f7d633283dce6cf84e4fd4e8228c0a0aa50e7c55f35c3ecaa1c 239.2 μs 169.2 μs 1.41
marlowe-role-payout/49b8275d0cb817be40865694ab05e3cfe5fc35fb43b78e7de68c1f3519b536bd 247.4 μs 174.8 μs 1.42
marlowe-role-payout/4dd7755b6ca1f0c9747c1fc0ee4da799f6f1c07108e980bd9f820911ad711ff2 320.6 μs 226.2 μs 1.42
marlowe-role-payout/4fbcfdb577a56b842d6f6938187a783f71d9da7519353e3da3ef0c564e1eb344 295.2 μs 209 μs 1.41
marlowe-role-payout/5a0725d49c733130eda8bc6ed5234f7f6ff8c9dd2d201e8806125e5fbcc081f9 252.2 μs 178.3 μs 1.41
marlowe-role-payout/5d4c62a0671c65a14f6a15093e3efc4f1816d95a5a58fd92486bedaae8d9526b 279.8 μs 198.1 μs 1.41
marlowe-role-payout/5efe992e306e31cc857c64a62436ad2f9325acc5b4a74a8cebccdfd853ce63d2 245.2 μs 173.2 μs 1.42
marlowe-role-payout/622a7f3bc611b5149253c9189da022a9ff296f60a5b7c172a6dc286faa7284fa 286.4 μs 201.8 μs 1.42
marlowe-role-payout/a6f064b83b31032ea7f25921364727224707268e472a569f584cc6b1d8c017e8 239.1 μs 222.3 μs 1.08
marlowe-role-payout/a7cb09f417c3f089619fe25b7624392026382b458486129efcff18f8912bf302 238.4 μs 168.4 μs 1.42
marlowe-role-payout/a92b4072cb8601fa697e1150c08463b14ffced54eb963df08d322216e27373cb 218 μs 201.7 μs 1.08

This comment was automatically generated by workflow using github-action-benchmark.

CC: @IntersectMBO/plutus-core

Please sign in to comment.