stacks-network / stacks-network/stacks-core
Bug: `concretize` logic mis-handles `Trait` vs `Principal` types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.1k
- Forks
- 762
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 76
Description
While reviewing the concretize function in clarity, I noticed what appears to be a bug in the way it initializes and checks the is_principal flag.
Currently, the code initializes is_principal = true before iterating through the set of types. This means that if the set contains a Trait, the function will always throw an error, because the check assumes principals were already present even when they were not.
If the ListUnionType contains a Trait, the function may incorrectly raise an error.
This behavior looks unintended, since the initialization does not reflect the actual contents of the set.
Multiple traits are also silently collapsed, which may not be correct?
Impact:
Fixing this would change the type-checking behavior of Clarity. Because of this, a fix would likely be consensus-breaking (maybe?). Could we release a fix as part of Clarity 4?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in clarity/src/vm/types/signatures.rs around lines 829-871 and trace how concretize initializes and checks is_principal for ListUnionType inputs. Reproduce cases containing Trait, Principal, and multiple Traits, then add or update focused Clarity type-checking tests so the intended behavior is explicit and the possible consensus-breaking impact is reviewed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100