Skip to content

refactor(ops): pick CASM hash algorithm from settlement chain version#76

Merged
kariy merged 1 commit into
mainfrom
fix/ops-blake2s-casm-hash
May 14, 2026
Merged

refactor(ops): pick CASM hash algorithm from settlement chain version#76
kariy merged 1 commit into
mainfrom
fix/ops-blake2s-casm-hash

Conversation

@kariy
Copy link
Copy Markdown
Member

@kariy kariy commented May 14, 2026

Summary

Starknet v0.14.1 switched the canonical compiled_class_hash from Poseidon to Blake2s and rejects declares using the old algorithm. saya-ops core-contract declare* was hardcoding use_blake2s: true in prepare_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_contract and declare_contract_from_bytes now query the settlement chain's starknet_version from the latest block and pick Blake2s (HashVersion::V2) for >= 0.14.1, Poseidon (HashVersion::V1) otherwise. The prepare_class* / casm_class_hash_from_bytes plumbing already accepted the flag — only the source of the value changed. No CLI surface change.

Testing

  • Unit tests cover the version comparator (positive, negative, and unparseable inputs).
  • End-to-end: declared the Piltover core contract against api.cartridge.gg/x/starknet/sepolia — tx 0x3d0a1eafb039b3f6f81d9df5fe71892a9eb0101f746f685059b902fc410c374, ACCEPTED_ON_L2 / SUCCEEDED. Sepolia is post-0.14.1, so this would have been rejected before the fix.

🤖 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,
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>
@kariy kariy changed the title fix(ops): pick CASM hash algorithm from settlement chain version refactor(ops): pick CASM hash algorithm from settlement chain version May 14, 2026
@kariy kariy merged commit 8a5dc79 into main May 14, 2026
5 of 7 checks passed
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