Skip to content

Commit

Permalink
Add cost model page in the user guide (#6582)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 authored Oct 18, 2024
1 parent 388ad69 commit c8a10ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
18 changes: 0 additions & 18 deletions doc/docusaurus/docs/delve-deeper/cost-model-parameters.md

This file was deleted.

20 changes: 20 additions & 0 deletions doc/docusaurus/docs/delve-deeper/cost-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
sidebar_position: 15
---

# Cost Model

The cost model is used to determine the portion of the transaction fee that accounts for Plutus script execution.
It assigns execution units, consisting of a CPU component and a memory component, to the execution of a Plutus script, which is then used to calculate the corresponding fee in Ada.

Cardano is designed for determinism.
The script execution fee, and indeed the entire transaction fee, can be accurately predicted off-chain before the transaction is submitted.
Unlike some other blockchains, there's no risk of a script incurring higher costs on-chain than expected.
On Cardano, the fee calculated when running the script locally is the exact fee charged on-chain[^1].

To learn more about the cost model, take a look at [An overview of the Plutus Core cost model](https://github.com/IntersectMBO/plutus/blob/master/doc/cost-model-overview/cost-model-overview.pdf).

---

[^1]: A transaction may of course be rejected for reasons such as some input UTXOs no longer exist, in which case the script won't be executed.
If the script is executed, the fee will be exactly as predicted.

1 comment on commit c8a10ed

@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: c8a10ed Previous: 388ad69 Ratio
validation-auction_1-1 289.3 μs 254.8 μs 1.14
validation-crowdfunding-success-2 236.8 μs 210.6 μs 1.12
validation-crowdfunding-success-3 236.5 μs 209.7 μs 1.13
validation-currency-1 270.2 μs 252.5 μs 1.07
validation-escrow-redeem_1-1 381.3 μs 351.3 μs 1.09
validation-escrow-redeem_1-2 539.8 μs 349.3 μs 1.55
validation-escrow-redeem_2-1 630.7 μs 409.7 μs 1.54
validation-escrow-redeem_2-2 627.9 μs 408.8 μs 1.54
validation-escrow-redeem_2-3 627.7 μs 409.7 μs 1.53
validation-escrow-refund-1 248.7 μs 156.2 μs 1.59
validation-future-increase-margin-1 384.4 μs 251.1 μs 1.53
validation-future-increase-margin-2 825.1 μs 565.4 μs 1.46
validation-future-increase-margin-3 822.5 μs 540.9 μs 1.52
validation-future-increase-margin-4 737.8 μs 490.3 μs 1.50
validation-future-increase-margin-5 1208 μs 822.4 μs 1.47
validation-future-pay-out-1 383.2 μs 251.7 μs 1.52
validation-future-pay-out-2 820.2 μs 539 μs 1.52
validation-future-pay-out-3 822.2 μs 651.1 μs 1.26
validation-future-settle-early-1 383 μs 358.2 μs 1.07
validation-future-settle-early-3 823.4 μs 765.1 μs 1.08
validation-game-sm-success_1-1 592.9 μs 554.5 μs 1.07
validation-game-sm-success_1-2 324.5 μs 284.6 μs 1.14
validation-game-sm-success_1-3 963.3 μs 908 μs 1.06
validation-game-sm-success_1-4 378.6 μs 332.5 μs 1.14
validation-game-sm-success_2-1 593 μs 552.8 μs 1.07
validation-game-sm-success_2-2 324.4 μs 285 μs 1.14
validation-game-sm-success_2-3 963.2 μs 911.4 μs 1.06
validation-game-sm-success_2-4 378.6 μs 332.3 μs 1.14
validation-game-sm-success_2-5 959.7 μs 911.2 μs 1.05
validation-game-sm-success_2-6 377.9 μs 332 μs 1.14
validation-multisig-sm-1 598.1 μs 560.7 μs 1.07
validation-multisig-sm-2 585.9 μs 486.6 μs 1.20
validation-multisig-sm-3 594.1 μs 544.4 μs 1.09
validation-multisig-sm-4 600.4 μs 560.1 μs 1.07
validation-multisig-sm-5 838.9 μs 792.1 μs 1.06
validation-multisig-sm-6 599.9 μs 560.8 μs 1.07
validation-multisig-sm-7 585.2 μs 492.2 μs 1.19
validation-multisig-sm-8 594.1 μs 551.2 μs 1.08
validation-ping-pong-1 496.8 μs 464.3 μs 1.07
validation-ping-pong-2 499.1 μs 464.8 μs 1.07
validation-ping-pong_2-1 312.9 μs 284.4 μs 1.10
validation-prism-1 271.6 μs 239.5 μs 1.13
validation-prism-2 635.1 μs 582.8 μs 1.09
validation-prism-3 556.7 μs 525.8 μs 1.06
validation-stablecoin_1-1 1362 μs 1297 μs 1.05
validation-stablecoin_1-2 317.9 μs 277.4 μs 1.15
validation-stablecoin_1-3 1571 μs 1491 μs 1.05
validation-stablecoin_1-4 337.9 μs 296.5 μs 1.14
validation-stablecoin_2-2 221.9 μs 196.5 μs 1.13
validation-stablecoin_2-4 245 μs 209 μs 1.17
validation-token-account-1 292.2 μs 190.3 μs 1.54
validation-token-account-2 517.6 μs 336.2 μs 1.54
validation-uniswap-1 619.3 μs 415.7 μs 1.49
validation-uniswap-2 345.4 μs 256.3 μs 1.35
validation-uniswap-3 2632 μs 1774 μs 1.48
validation-uniswap-4 544.5 μs 479.3 μs 1.14
validation-uniswap-5 1756 μs 1225 μs 1.43
validation-uniswap-6 514.5 μs 318.9 μs 1.61
validation-vesting-1 528.9 μs 348.3 μs 1.52
validation-decode-auction_2-2 742.9 μs 653.3 μs 1.14
validation-decode-auction_2-3 742.8 μs 568.9 μs 1.31
validation-decode-auction_2-4 740 μs 525.2 μs 1.41
validation-decode-auction_2-5 269.7 μs 189.9 μs 1.42
validation-decode-escrow-redeem_2-2 332.4 μs 305.7 μs 1.09
validation-decode-escrow-redeem_2-3 441.2 μs 306.1 μs 1.44
validation-decode-escrow-refund-1 441.7 μs 306.3 μs 1.44
validation-decode-future-increase-margin-1 268.4 μs 225.5 μs 1.19
validation-decode-future-increase-margin-2 441.2 μs 308.2 μs 1.43
validation-decode-future-increase-margin-3 443.5 μs 307.8 μs 1.44
validation-decode-future-increase-margin-4 944.7 μs 659.2 μs 1.43
validation-decode-future-increase-margin-5 948.8 μs 657.8 μs 1.44
validation-decode-future-pay-out-1 322.4 μs 225 μs 1.43
validation-decode-future-pay-out-2 450.5 μs 308.2 μs 1.46
validation-decode-future-pay-out-3 442.4 μs 308 μs 1.44
validation-decode-future-settle-early-3 409.8 μs 308.5 μs 1.33
validation-decode-future-settle-early-4 949.6 μs 657.7 μs 1.44
validation-decode-game-sm-success_1-1 724.4 μs 502.5 μs 1.44
validation-decode-game-sm-success_1-2 227.8 μs 158.5 μs 1.44
validation-decode-game-sm-success_1-3 720.6 μs 504.9 μs 1.43
validation-decode-game-sm-success_1-4 230.2 μs 158.9 μs 1.45
validation-decode-game-sm-success_2-1 724.7 μs 502.8 μs 1.44
validation-decode-game-sm-success_2-2 224.9 μs 158.5 μs 1.42
validation-decode-game-sm-success_2-3 720.5 μs 502.9 μs 1.43
validation-decode-game-sm-success_2-4 227.6 μs 158.6 μs 1.44
validation-decode-game-sm-success_2-5 719.3 μs 518.7 μs 1.39
validation-decode-multisig-sm-1 804.5 μs 555.8 μs 1.45
validation-decode-multisig-sm-2 802 μs 757.4 μs 1.06
validation-decode-multisig-sm-3 669.6 μs 556 μs 1.20
validation-decode-multisig-sm-4 604.7 μs 561.9 μs 1.08
validation-decode-multisig-sm-6 613.9 μs 561 μs 1.09
validation-decode-multisig-sm-7 755.5 μs 718.9 μs 1.05
validation-decode-ping-pong-2 672.5 μs 497.1 μs 1.35
validation-decode-stablecoin_1-2 228.5 μs 156.5 μs 1.46
validation-decode-stablecoin_1-3 1134 μs 830 μs 1.37
validation-decode-stablecoin_1-5 917.1 μs 829.5 μs 1.11
validation-decode-stablecoin_1-6 228.8 μs 157.7 μs 1.45
validation-decode-stablecoin_2-1 1185 μs 830.1 μs 1.43
validation-decode-stablecoin_2-2 226 μs 156 μs 1.45
validation-decode-stablecoin_2-3 1189 μs 828.5 μs 1.44
validation-decode-stablecoin_2-4 229.6 μs 158.6 μs 1.45
validation-decode-token-account-2 298.4 μs 268.8 μs 1.11
validation-decode-uniswap-1 329.7 μs 227.3 μs 1.45
validation-decode-uniswap-2 326 μs 228.1 μs 1.43
validation-decode-uniswap-3 1020 μs 711.9 μs 1.43
validation-decode-uniswap-4 250 μs 173.4 μs 1.44
validation-decode-uniswap-5 1020 μs 708.1 μs 1.44
validation-decode-uniswap-6 250.8 μs 172.4 μs 1.45
marlowe-semantics/383683bfcecdab0f4df507f59631c702bd11a81ca3841f47f37633e8aacbb5de 1080 μs 919.1 μs 1.18
marlowe-semantics/a9a853b6d083551f4ed2995551af287880ef42aee239a2d9bc5314d127cce592 719.6 μs 521.8 μs 1.38
marlowe-semantics/cdb9d5c233b288a5a9dcfbd8d5c1831a0bb46eec7a26fa31b80ae69d44805efc 1253 μs 880.2 μs 1.42
marlowe-semantics/ced1ea04649e093a501e43f8568ac3e6b37cd3eccec8cac9c70a4857b88a5eb8 912.3 μs 839.2 μs 1.09
marlowe-semantics/f2a8fd2014922f0d8e01541205d47e9bb2d4e54333bdd408cbe7c47c55e73ae4 783.7 μs 733.9 μs 1.07
marlowe-semantics/f339f59bdf92495ed2b14e2e4d3705972b4dda59aa929cffe0f1ff5355db8d79 6536 μs 4670 μs 1.40
marlowe-semantics/ffdd68a33afd86f8844c9f5e45b2bda5b035aa02274161b23d57709c0f8b8de6 1203 μs 956.6 μs 1.26
marlowe-role-payout/0004000402010401030101030100040000010104020201030001000204020401 268.6 μs 188 μs 1.43
marlowe-role-payout/0100000100010000000001000100010101000101000001000000010000010000 313.7 μs 257.7 μs 1.22
marlowe-role-payout/0202010002010100020102020102020001010101020102010001010101000100 215.1 μs 172.5 μs 1.25
marlowe-role-payout/0303020000020001010201060303040208070100050401080304020801030001 247.2 μs 173.2 μs 1.43
marlowe-role-payout/031d56d71454e2c4216ffaa275c4a8b3eb631109559d0e56f44ea8489f57ba97 292.7 μs 206.1 μs 1.42
marlowe-role-payout/03d730a62332c51c7b70c16c64da72dd1c3ea36c26b41cd1a1e00d39fda3d6cc 276.3 μs 194.9 μs 1.42
marlowe-role-payout/0403020000030204010000030001000202010101000304030001040404030100 257.6 μs 179.4 μs 1.44
marlowe-role-payout/0405010105020401010304080005050800040301010800080207080704020206 282 μs 198.4 μs 1.42
marlowe-role-payout/041a2c3b111139201a3a2c173c392b170e16370d300f2d28342d0f2f0e182e01 281.5 μs 198.6 μs 1.42
marlowe-role-payout/04f592afc6e57c633b9c55246e7c82e87258f04e2fb910c37d8e2417e9db46e5 326.8 μs 230 μs 1.42
marlowe-role-payout/057ebc80922f16a5f4bf13e985bf586b8cff37a2f6fe0f3ce842178c16981027 240.9 μs 170.5 μs 1.41
marlowe-role-payout/06317060a8e488b1219c9dae427f9ce27918a9e09ee8ac424afa33ca923f7954 253.7 μs 178.6 μs 1.42
marlowe-role-payout/07658a6c898ad6d624c37df1e49e909c2e9349ba7f4c0a6be5f166fe239bfcae 232.6 μs 177 μs 1.31
marlowe-role-payout/121a0a1b12030616111f02121a0e070716090a0e031c071419121f141409031d 238.4 μs 219.6 μs 1.09
marlowe-role-payout/159e5a1bf16fe984b5569be7011b61b5e98f5d2839ca7e1b34c7f2afc7ffb58e 243.6 μs 170.8 μs 1.43
marlowe-role-payout/195f522b596360690d04586a2563470f2214163435331a6622311f7323433f1c 237.2 μs 166.6 μs 1.42
marlowe-role-payout/1a20b465d48a585ffd622bd8dc26a498a3c12f930ab4feab3a5064cfb3bc536a 263.2 μs 186.1 μs 1.41
marlowe-role-payout/371c10d2526fc0f09dbe9ed59e44dcd949270b27dc42035addd7ff9f7e0d05e7 287 μs 265.6 μs 1.08

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

CC: @IntersectMBO/plutus-core

Please sign in to comment.