refactor(ops): pick CASM hash algorithm from settlement chain version#76
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, mirroring the issue fixed for `katana init rollup` in dojoengine/katana#570. `saya-ops core-contract declare*` hardcoded `use_blake2s: true` in `prepare_class*`, which would have failed against any pre-0.14.1 settlement chain. The declare path now reads the settlement chain's `starknet_version` from the latest block and selects Blake2s for >= 0.14.1, Poseidon otherwise. Verified end-to-end by declaring the Piltover core contract against api.cartridge.gg/x/starknet/sepolia (tx 0x3d0a1eafb039b3f6f81d9df5fe71892a9eb0101f746f685059b902fc410c374, ACCEPTED_ON_L2 / SUCCEEDED). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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_hashfrom Poseidon to Blake2s and rejects declares using the old algorithm.saya-ops core-contract declare*was hardcodinguse_blake2s: trueinprepare_class*, which would silently produce the wrong hash on any pre-0.14.1 settlement chain. This is the saya-side equivalent of dojoengine/katana#570.Approach
declare_contractanddeclare_contract_from_bytesnow query the settlement chain'sstarknet_versionfrom the latest block and pick Blake2s (HashVersion::V2) for>= 0.14.1, Poseidon (HashVersion::V1) otherwise. Theprepare_class*/casm_class_hash_from_bytesplumbing already accepted the flag — only the source of the value changed. No CLI surface change.Testing
api.cartridge.gg/x/starknet/sepolia— tx0x3d0a1eafb039b3f6f81d9df5fe71892a9eb0101f746f685059b902fc410c374,ACCEPTED_ON_L2/SUCCEEDED. Sepolia is post-0.14.1, so this would have been rejected before the fix.🤖 Generated with Claude Code