fix(init): use Blake2s compiled class hash on Starknet >= 0.14.1#570
Merged
Conversation
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>
There was a problem hiding this comment.
⚠️ 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
Codec benchmark diff vs
|
| 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% |
|
Codecov Report❌ Patch coverage is
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. 🚀 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
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):
katana init rollupagainst a 0.14.1+ settlement chain (mainnet, and Sepolia post-upgrade) therefore fails — the Piltover Appchain declare submitsAppchain::CASM_HASH, a Poseidon hash baked in at compile time by thecontract!macro.Approach
The declare path now reads the settlement chain's protocol version from the latest block's
starknet_versionand picks the matching hash:>= 0.14.1— compile Sierra → CASM and hash with Blake2s viastarknet_api'sHashableCompiledClass(already a transitive dep through blockifier).Appchain::CASM_HASHconstant.🤖 Generated with Claude Code