Skip to content

snforge test fails with 'cycle during cost computation' when enable-gas = false and executable defined #4151

@feltroidprime

Description

@feltroidprime

Description

snforge test fails with "found an unexpected cycle during cost computation" when a package has both:

  1. [[target.executable]] defined in Scarb.toml
  2. enable-gas = false in Scarb.toml

This happens with any code - even a trivial fn foo() { 42 }.

Related Issue

This appears related to: software-mansion/scarb#2981

Minimal Reproduction

Repository: https://github.com/feltroidprime/snforge-cycle-repro

git clone https://github.com/feltroidprime/snforge-cycle-repro
cd snforge-cycle-repro
snforge test

Output:

[ERROR] found an unexpected cycle during cost computation
[ERROR] Error while compiling Sierra...

Minimal Files (45 lines total)

src/ntt.cairo:

pub fn foo() -> felt252 {
    42
}

Scarb.toml:

[package]
name = "cycle_repro"
version = "0.1.0"
edition = "2024_07"

[lib]

[[target.executable]]
name = "my_executable"
function = "cycle_repro::programs::bench_ntt::main"

[cairo]
enable-gas = false  # Remove this and tests pass

[dependencies]
cairo_execute = "2.15.1"

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.55.0" }
assert_macros = "2.15.1"

Workaround

Remove either:

  • The [[target.executable]] section, OR
  • The [cairo] enable-gas = false section

Environment

  • snforge 0.55.0
  • scarb 2.15.1
  • Cairo 2.15.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsnforge

Type

No type

Projects

Status

TODO

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions