feat(settlement): record SP1 proof-generation cost metrics - #626
Merged
Conversation
kariy
force-pushed
the
feat/settlement-proof-cost-metric
branch
from
July 4, 2026 02:25
aa1715a to
4d122c2
Compare
…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
force-pushed
the
feat/settlement-proof-cost-metric
branch
from
July 4, 2026 02:50
4d122c2 to
1874cea
Compare
Codec benchmark diff vs
|
| 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% |
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 executedkatana_settlement_sp1_proof_gas_used— prover-network gas (PGU) billedkatana_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
ProofCosttoRawProof(rides along onOnchainProof), populated by drivingNetworkProverdirectly 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 theOnchainProof/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
Nonefor 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.deduction_amountis a fulfiller-balance movement, not a requester invoice, so we record the rawgas_used/gas_price/cyclesand 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) — cleancargo +nightly-2025-02-20 fmt --all— clean-p katana-settlement --all-targets, repo deny flags) — clean🤖 Generated with Claude Code