Skip to content

Fix: deterministic static costs#2322

Open
brady-stacks wants to merge 4 commits intostx-labs:mainfrom
brady-stacks:fix/narrowed-static-cost-calls
Open

Fix: deterministic static costs#2322
brady-stacks wants to merge 4 commits intostx-labs:mainfrom
brady-stacks:fix/narrowed-static-cost-calls

Conversation

@brady-stacks
Copy link
Copy Markdown
Contributor

@brady-stacks brady-stacks commented Mar 23, 2026

The static cost returned for functions called with deterministic inputs was previously using the type size range of the function called, not the arguments received. This narrows the scope to get exact costs where possible

Example previously failing with inaccurate max cost (add-u1):

(define-data-var count uint u0)

(define-private (add (n uint))
  (begin
    (var-set count (+ (var-get count) n))
  )
)

(define-public (add-many-64 (ns (list 64 uint)))
  (begin
    (map add ns)
    (ok true)
  )
)

(define-public (add-u1)
  (add-many-64 (list u1))
)

@brady-stacks brady-stacks changed the title Fix deterministic static costs Fix: deterministic static costs Mar 23, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 96.06299% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...arity-static-cost/src/static_cost/cost_analysis.rs 95.83% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant