Skip to content

Conversation

@unclekaldoteth
Copy link

Summary

This PR adds execution cost information to all Clarity functions in the reference documentation, addressing Issue #1671.

Changes

1. Added Cost Legend Section

Added a new "Understanding Clarity Function Costs" section explaining:

  • Cost dimensions: Runtime, Read Count, Read Length, Write Count, Write Length
  • Cost types: Static, Linear, NLogN
  • Cost notation: How to interpret formulas like 11n + 125

2. Added Cost Info to 60+ Functions

Each function now includes a **cost:** field with:

  • Runtime cost formula
  • I/O costs where applicable (reads/writes)
  • Clear explanation of what n represents

Functions Updated

Arithmetic, Comparison, Boolean/Bitwise, Control Flow, Sequences, Tuples, Options/Responses, Hashing, Crypto, STX/FT/NFT operations, Type Conversion, and more.

Cost Data Source

  • stackslib/src/chainstate/stacks/boot/costs-4.clar
  • stackslib/src/chainstate/stacks/boot/costs_3.rs
  • Version: Clarity 4 (Nakamoto upgrade)

Closes #1671

- Add comprehensive cost legend explaining cost dimensions and types
- Add cost information to 60+ Clarity functions
- Costs extracted from Clarity 4 (costs-4.clar/costs_3.rs)

Closes stacks-network#1671
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion] Add costs to functions in the Clarity Functions reference docs

2 participants