Skip to content

feat(settlement): record SP1 proof-generation cost metrics - #626

Merged
kariy merged 1 commit into
mainfrom
feat/settlement-proof-cost-metric
Jul 4, 2026
Merged

feat(settlement): record SP1 proof-generation cost metrics#626
kariy merged 1 commit into
mainfrom
feat/settlement-proof-cost-metric

Conversation

@kariy

@kariy kariy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

Adds metrics for the cost of each SP1 proof generation — the actual figures the prover network bills — surfaced on the existing settlement metrics + Grafana dashboard.

New metrics (recorded per settled batch, prover-network only):

  • katana_settlement_sp1_proof_cycles — RISC-V cycles executed
  • katana_settlement_sp1_proof_gas_used — prover-network gas (PGU) billed
  • katana_settlement_sp1_proof_gas_price — gas price ($PROVE base units per PGU)

Dashboard: a Proof Cost group (Proof Cycles, Proof Gas Used, derived Proof Fee) appended to the Settlement row.

How it works

The cost is computed by the SP1 prover network but was discarded before reaching katana. The companion SDK change (cartridge-gg/amd-sev-snp-attestation-sdk#1, now merged) adds an optional ProofCost to RawProof (rides along on OnchainProof), populated by driving NetworkProver directly to capture the fulfilled request's billed figures. Here we bump the SDK rev and record the cost in the TEE backend — the only place the OnchainProof/cost is in scope — leaving the backend-agnostic settlement service untouched. Off-network/mock proving reports no cost, so recording is a no-op there.

Caveats

  • Network-mode only: cost is None for cpu/mock provers; can't be exercised by the mock test harness. Validated by compiling against the merged SDK commit; runtime figures require a live prover-network key.
  • Fee semantics: deduction_amount is a fulfiller-balance movement, not a requester invoice, so we record the raw gas_used/gas_price/cycles and derive fee in Grafana rather than trust one ambiguous number.

Dependency

Pins the SDK to the squash-merge commit of #1 on feat/sp1-v6-alloy14 (the branch katana already tracks).

Checks

  • DOCS_RS=1 cargo check -p katana-settlement (against the merged SDK commit) — clean
  • cargo +nightly-2025-02-20 fmt --all — clean
  • clippy (-p katana-settlement --all-targets, repo deny flags) — clean

🤖 Generated with Claude Code

@kariy
kariy force-pushed the feat/settlement-proof-cost-metric branch from aa1715a to 4d122c2 Compare July 4, 2026 02:25
…e log

Bumps the AMD SDK rev to pull the new ProofCost carrier on RawProof and
records the prover-network billed cost of each SP1 proof as
katana_settlement_sp1_proof_{cycles,gas_used,gas_price}. Recorded in the
TEE backend (the only place the OnchainProof/cost is in scope), so the
backend-agnostic settlement service is untouched. Off-network/mock
proving reports no cost, so the recording is a no-op there.

The metrics carry no block label (a block number is unbounded
cardinality), so the same cost is also emitted as a per-proof info log
carrying the settled block range (prev_block, block] — that's how a given
cost is attributed to the batch that incurred it.

Adds a Proof Cost group (cycles, gas used, derived fee) to the Settlement
row of the Grafana dashboard.

Requires cartridge-gg/amd-sev-snp-attestation-sdk#1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kariy
kariy force-pushed the feat/settlement-proof-cost-metric branch from 4d122c2 to 1874cea Compare July 4, 2026 02:50
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codec benchmark diff vs main

Benchmark Baseline (ns) Current (ns) Δ
CompiledClass(fixture)/compress 2716431 2677326 -1.44%
CompiledClass(fixture)/decompress 2805889 2824666 +0.67%
ExecutionCheckpoint/compress 31 33 +6.45%
ExecutionCheckpoint/decompress 24 26 +8.33%
PruningCheckpoint/compress 30 33 +10.00%
PruningCheckpoint/decompress 24 25 +4.17%
VersionedHeader/compress 605 631 +4.30%
VersionedHeader/decompress 845 904 +6.98%
StoredBlockBodyIndices/compress 73 80 +9.59%
StoredBlockBodyIndices/decompress 34 38 +11.76%
StorageEntry/compress 153 163 +6.54%
StorageEntry/decompress 147 175 +19.05%
ContractNonceChange/compress 146 160 +9.59%
ContractNonceChange/decompress 254 297 +16.93%
ContractClassChange/compress 191 201 +5.24%
ContractClassChange/decompress 265 310 +16.98%
ContractStorageEntry/compress 154 173 +12.34%
ContractStorageEntry/decompress 340 383 +12.65%
GenericContractInfo/compress 129 129 +0.00%
GenericContractInfo/decompress 105 108 +2.86%
Felt/compress 80 90 +12.50%
Felt/decompress 55 60 +9.09%
BlockHash/compress 80 93 +16.25%
BlockHash/decompress 56 60 +7.14%
TxHash/compress 80 90 +12.50%
TxHash/decompress 55 60 +9.09%
ClassHash/compress 79 90 +13.92%
ClassHash/decompress 55 61 +10.91%
CompiledClassHash/compress 80 90 +12.50%
CompiledClassHash/decompress 55 61 +10.91%
BlockNumber/compress 47 50 +6.38%
BlockNumber/decompress 24 24 +0.00%
TxNumber/compress 47 50 +6.38%
TxNumber/decompress 24 25 +4.17%
FinalityStatus/compress 1 0 -100.00%
FinalityStatus/decompress 10 10 +0.00%
TypedTransactionExecutionInfo/compress 18253 14732 -19.29%
TypedTransactionExecutionInfo/decompress 3557 3716 +4.47%
VersionedContractClass/compress 384 378 -1.56%
VersionedContractClass/decompress 806 839 +4.09%
MigratedCompiledClassHash/compress 144 167 +15.97%
MigratedCompiledClassHash/decompress 138 176 +27.54%
ContractInfoChangeList/compress 1366 1406 +2.93%
ContractInfoChangeList/decompress 2146 2311 +7.69%
BlockChangeList/compress 588 609 +3.57%
BlockChangeList/decompress 859 914 +6.40%
ReceiptEnvelope/compress 28103 26411 -6.02%
ReceiptEnvelope/decompress 5959 6602 +10.79%
TrieDatabaseValue/compress 166 151 -9.04%
TrieDatabaseValue/decompress 234 248 +5.98%
TrieHistoryEntry/compress 290 271 -6.55%
TrieHistoryEntry/decompress 263 286 +8.75%

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Runner: AMD EPYC 9V74 80-Core Processor (4 cores) · 15Gi RAM

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.07%. Comparing base (9bde0ae) to head (1874cea).
⚠️ Report is 483 commits behind head on main.

Files with missing lines Patch % Lines
crates/settlement/src/backend/tee/prover.rs 0.00% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
- Coverage   73.32%   68.07%   -5.25%     
==========================================
  Files         209      333     +124     
  Lines       23132    46637   +23505     
==========================================
+ Hits        16961    31748   +14787     
- Misses       6171    14889    +8718     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kariy
kariy merged commit 89628fa into main Jul 4, 2026
19 of 21 checks passed
@kariy
kariy deleted the feat/settlement-proof-cost-metric branch July 4, 2026 04:34
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