Skip to content

fix(init): use Blake2s compiled class hash on Starknet >= 0.14.1#570

Merged
kariy merged 1 commit into
mainfrom
blake2s-casm-hash
May 13, 2026
Merged

fix(init): use Blake2s compiled class hash on Starknet >= 0.14.1#570
kariy merged 1 commit into
mainfrom
blake2s-casm-hash

Conversation

@kariy
Copy link
Copy Markdown
Member

@kariy kariy commented May 13, 2026

Summary

Starknet v0.14.1 switched the canonical compiled class hash from Poseidon to Blake2s, and declares using the old hash are rejected (per the release notes):

Declare transactions will now expect compiled_class_hash to be computed with the new hash function, and will be rejected otherwise.

katana init rollup against a 0.14.1+ settlement chain (mainnet, and Sepolia post-upgrade) therefore fails — the Piltover Appchain declare submits Appchain::CASM_HASH, a Poseidon hash baked in at compile time by the contract! macro.

Approach

The declare path now reads the settlement chain's protocol version from the latest block's starknet_version and picks the matching hash:

  • >= 0.14.1 — compile Sierra → CASM and hash with Blake2s via starknet_api's HashableCompiledClass (already a transitive dep through blockifier).
  • otherwise — use the existing precomputed Poseidon Appchain::CASM_HASH constant.

🤖 Generated with Claude Code

Starknet v0.14.1 switched the canonical compiled class hash from
Poseidon to Blake2s and rejects declares that still use the old hash.
`katana init rollup` against a 0.14.1+ settlement chain fails because
the Piltover declare submits the Poseidon hash baked in at compile time
by the `contract!` macro.

The declare path now reads the settlement chain's protocol version from
the latest block header and picks the matching hash: Blake2s for
>= 0.14.1, Poseidon otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: bbede2c Previous: c8d76b6 Ratio
GenericContractInfo/compress 144 ns/iter (± 2) 109 ns/iter (± 8) 1.32
FinalityStatus/compress 1 ns/iter (± 0) 0 ns/iter (± 0) +∞
TypedTransactionExecutionInfo/compress 18018 ns/iter (± 117) 10669 ns/iter (± 37) 1.69
VersionedContractClass/compress 372 ns/iter (± 4) 284 ns/iter (± 3) 1.31
ContractInfoChangeList/compress 1687 ns/iter (± 58) 1161 ns/iter (± 25) 1.45
BlockChangeList/compress 723 ns/iter (± 17) 509 ns/iter (± 101) 1.42
ReceiptEnvelope/compress 27449 ns/iter (± 280) 20236 ns/iter (± 1207) 1.36
TrieDatabaseValue/compress 167 ns/iter (± 1) 123 ns/iter (± 3) 1.36
TrieHistoryEntry/compress 312 ns/iter (± 1) 222 ns/iter (± 1) 1.41

This comment was automatically generated by workflow using github-action-benchmark.

CC: @kariy

@github-actions
Copy link
Copy Markdown

Codec benchmark diff vs main

Benchmark Baseline (ns) Current (ns) Δ
CompiledClass(fixture)/compress 2070455 2675132 +29.21%
CompiledClass(fixture)/decompress 2272571 2912113 +28.14%
ExecutionCheckpoint/compress 27 32 +18.52%
ExecutionCheckpoint/decompress 20 25 +25.00%
PruningCheckpoint/compress 27 32 +18.52%
PruningCheckpoint/decompress 20 26 +30.00%
VersionedHeader/compress 523 644 +23.14%
VersionedHeader/decompress 704 814 +15.63%
StoredBlockBodyIndices/compress 63 78 +23.81%
StoredBlockBodyIndices/decompress 31 36 +16.13%
StorageEntry/compress 124 154 +24.19%
StorageEntry/decompress 123 148 +20.33%
ContractNonceChange/compress 124 149 +20.16%
ContractNonceChange/decompress 204 238 +16.67%
ContractClassChange/compress 175 218 +24.57%
ContractClassChange/decompress 215 249 +15.81%
ContractStorageEntry/compress 135 159 +17.78%
ContractStorageEntry/decompress 271 314 +15.87%
GenericContractInfo/compress 109 144 +32.11%
GenericContractInfo/decompress 91 106 +16.48%
Felt/compress 71 81 +14.08%
Felt/decompress 49 57 +16.33%
BlockHash/compress 70 81 +15.71%
BlockHash/decompress 49 56 +14.29%
TxHash/compress 70 81 +15.71%
TxHash/decompress 49 57 +16.33%
ClassHash/compress 69 81 +17.39%
ClassHash/decompress 50 56 +12.00%
CompiledClassHash/compress 69 81 +17.39%
CompiledClassHash/decompress 50 56 +12.00%
BlockNumber/compress 39 47 +20.51%
BlockNumber/decompress 20 26 +30.00%
TxNumber/compress 39 47 +20.51%
TxNumber/decompress 20 25 +25.00%
FinalityStatus/compress 0 1 +Infinity%
FinalityStatus/decompress 10 12 +20.00%
TypedTransactionExecutionInfo/compress 10669 18018 +68.88%
TypedTransactionExecutionInfo/decompress 2872 3495 +21.69%
VersionedContractClass/compress 284 372 +30.99%
VersionedContractClass/decompress 677 776 +14.62%
MigratedCompiledClassHash/compress 124 149 +20.16%
MigratedCompiledClassHash/decompress 123 147 +19.51%
ContractInfoChangeList/compress 1161 1687 +45.31%
ContractInfoChangeList/decompress 1787 2262 +26.58%
BlockChangeList/compress 509 723 +42.04%
BlockChangeList/decompress 731 889 +21.61%
ReceiptEnvelope/compress 20236 27449 +35.64%
ReceiptEnvelope/decompress 5084 5969 +17.41%
TrieDatabaseValue/compress 123 167 +35.77%
TrieDatabaseValue/decompress 201 218 +8.46%
TrieHistoryEntry/compress 222 312 +40.54%
TrieHistoryEntry/decompress 226 252 +11.50%

@github-actions
Copy link
Copy Markdown

Runner: AMD EPYC 7763 64-Core Processor (4 cores) · 15Gi RAM

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.24%. Comparing base (9bde0ae) to head (bbede2c).
⚠️ Report is 414 commits behind head on main.

Files with missing lines Patch % Lines
bin/katana/src/cli/init/deployment.rs 0.00% 22 Missing ⚠️
crates/primitives/src/class.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #570      +/-   ##
==========================================
- Coverage   73.32%   68.24%   -5.08%     
==========================================
  Files         209      320     +111     
  Lines       23132    44798   +21666     
==========================================
+ Hits        16961    30573   +13612     
- Misses       6171    14225    +8054     

☔ View full report in Codecov by Sentry.
📢 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 612b52f into main May 13, 2026
18 of 21 checks passed
@kariy kariy deleted the blake2s-casm-hash branch May 13, 2026 21:26
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