stacks-network / stacks-network/stacks-core

Assert to check invariants and abort contract call

Open
#7,142 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

clarity-new-builtin clarity-next-candidate
Dominant language
Rust
Stars
3.1k
Forks
762
Avg merge
4d 6h
Merged PRs (30d)
76

Description

Clarity should have an assert construct that aborts the contract call when an invariant predicate is false.

Assertions are common in programming languages, including other Lisp dialects: Clojure has assert; Common Lisp has assert; Scheme has assert; Typed Racket has with-asserts;

Clarity already have an asserts! form, but instead of aborting the contract call, it returns an error from the current function. This is a foot gun for Clarity developers, inviting security flaws such as failing to handle severe errors. It is also inflexible, limiting assertions to functions that return a result type.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies the existing asserts! form but names no files, tests, or implementation entry point. Start by locating the Clarity language implementation and the current asserts! behavior, then trace how contract-call aborts are represented. Done means an assert construct aborts the contract call when its predicate is false.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.