Plutus Scripts Memory Units & Execution Steps used by Cardano transactions & blocks


Smart Contracts on Cardano are Plutus scripts. We often talk about the size of transactions and blocks compared to the maximum currently authorized by the protocol parameters, but scripts are also limited in CPU and memory units.

Here is the description of those 3 properties from Cardano docs:

  • The total on-chain transaction size in bytes: a simple transaction, for example, is around 300 bytes, one with metadata is around 650 bytes, and Plutus scripts are typically 4,000-8,000 bytes (future optimizations and improvements will reduce this).
  • The number of computational (CPU) steps that the script uses: each step represents 1 picosecond of execution time on a benchmark machine. Typical scripts should consume less than 1,000,000,000 (1 millisecond).
  • The number of memory units that the script uses: this represents the number of bytes that the script allocates. Typical scripts should consume less than 1,000,000 memory units (1MB of memory allocation).

Those 3 properties are needed to determine the transaction fees needed by scripts.

Both block and transactions are limited in size, execution and memory units, and the visualizations above show how blocks and transactions over the last 3 months compare with their current limits:

  • X axis represents the % of available memory units used
  • Y axis represents the % of available CPU units used
  • Color represents the % of available bytes used

We can see for example that blocks often use all their CPU & memory units available, but transactions are limited mainly by their memory, and very rarely by their CPU.

Current limits are:

Blocks:

  • max size: 90,112 bytes
  • max execution steps: 20,000,000,000
  • max memory units: 62,000,000

Transactions:

  • max size: 16,384 bytes
  • max execution steps: 10,000,000,000
  • max memory units: 14,000,000

Source:
https://gist.github.com/SmaugPool/e44dfc8ac202cf6f1eebc75ad778e153

8 Likes