compact-core:compact-circuit-costs

Analyze Compact circuit costs across proving, gas, and state dimensions.

37|9|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-circuit-costs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-core:compact-circuit-costs
Source: https://github.com/devrelaicom/midnight-expert/tree/main/plugins/compact-core/skills/compact-circuit-costs
Command: npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-circuit-costs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill documents and optimizes the three-dimensional cost model for Compact circuits, helping developers understand circuit/proving costs, runtime gas costs, and ledger state costs to build cost-efficient contracts.

Core Features & Use Cases

  • Cost modeling: explains how loop unrolling, hash choices (transient vs persistent), and ledger interactions affect circuit size and proving time.
  • Optimization guidance: provides practical strategies to minimize gate counts, reduce gas, and bound state growth.
  • Use Case: when designing a new Compact contract, use this skill to forecast costs and identify hot paths that blow up proofs, then apply mitigations.

Quick Start

Input your Compact circuit and return cost estimates, optimization suggestions, and a plan to reduce proving time.

Frequently Asked Questions about compact-core:compact-circuit-costs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize Compact circuit costs and reduce proving time?

To optimize Compact circuit costs, minimize gate counts by bounding loop unrolling, choosing transientHash over persistentHash where state persistence is unnecessary, and structuring maps and sealed fields to limit ledger writes.

What is the three-dimensional cost model used for Midnight Compact circuits?

The Midnight Compact circuit cost model spans three dimensions: circuit and proving costs driven by gate counts, runtime gas costs for execution, and state costs arising from ledger interactions and persistent writes.

When should I use transientHash instead of persistentHash in Compact contracts?

Use transientHash in Compact contracts when data does not require long-term ledger state persistence, which reduces state costs and circuit size; prefer persistentHash only when state survival across transactions is mandatory.

Why does loop unrolling affect Compact circuit gas costs and proving time?

Loop unrolling increases Compact circuit gas costs and proving time because it expands the circuit into static gates, multiplying the gate count and heavily inflating the proof generation workload during execution.

How do I monitor data points in Compact circuits to reduce gas and proving time?

Monitor data points including gate counts from unrolled loops, frequency of ledger writes, and hash usage patterns to identify hot paths, then apply heuristics like structuring maps efficiently to reduce gas and proving time.

Can I forecast Compact circuit costs before deploying a contract?

You can forecast Compact circuit costs by analyzing the circuit design to estimate proving costs, runtime gas, and state costs, identifying hot paths that blow up proofs, and applying mitigations to bound state growth.