Skip to content

starknet_api: replace LazyLock Felt/ContractAddress with const from_hex_unchecked#14395

Open
Yoni-Starkware wants to merge 1 commit into
main-v0.14.3from
fix/lazylocks-to-hex-unchecked
Open

starknet_api: replace LazyLock Felt/ContractAddress with const from_hex_unchecked#14395
Yoni-Starkware wants to merge 1 commit into
main-v0.14.3from
fix/lazylocks-to-hex-unchecked

Conversation

@Yoni-Starkware

Copy link
Copy Markdown
Collaborator

Summary

  • Replace all LazyLock<Felt> statics that encode ASCII strings or compute simple values with const Felt = Felt::from_hex_unchecked(...)
  • Replace LazyLock<ContractAddress> statics that wrap known hex addresses with const ContractAddress = ContractAddress(PatriciaKey::from_hex_unchecked(...))
  • Remove all * dereferences at call sites since const Felt is Copy and doesn't require deref
  • Drop now-unused LazyLock, ascii_as_felt, and Felt::from_hex imports

Affected constants:

  • VALIDATE_RETDATA, STARKNET_BLOCK_HASH0/1, STARKNET_GAS_PRICES0, STARKNET_STATE_DIFF0
  • COMPILED_CLASS_V1, DECLARE, DEPLOY, DEPLOY_ACCOUNT, INVOKE, L1_HANDLER
  • QUERY_VERSION_BASE (was Felt::TWO.pow(128))
  • STRK_FEE_CONTRACT_ADDRESS, ETH_FEE_CONTRACT_ADDRESS

Test plan

  • cargo build -p starknet_api passes
  • cargo build -p apollo_rpc_execution passes
  • cargo build -p blockifier passes

🤖 Generated with Claude Code

…replace LazyLock Felt/ContractAddress with const from_hex_unchecked

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cursor

cursor Bot commented Jun 4, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches hashing, query-transaction versioning, and fee-token addresses used across execution and OS paths; values are intended to be bitwise-identical to the old lazy init, but any hex typo would be a consensus-level bug.

Overview
This PR replaces LazyLock-backed Felt and fee-contract ContractAddress values with const definitions built via Felt::from_hex_unchecked and PatriciaKey::from_hex_unchecked, so protocol constants (block-hash prefixes, tx-hash type tags, QUERY_VERSION_BASE, VALIDATE_RETDATA, COMPILED_CLASS_V1, STRK/ETH fee addresses, etc.) are fixed at compile time instead of initialized on first use.

Call sites drop * derefs and unwrap_or(*…) patterns in favor of direct Copy values. Unused LazyLock, ascii_as_felt, and related imports are removed where no longer needed.

Reviewed by Cursor Bugbot for commit e52e95c. Bugbot is set up for automated code reviews on this repo. Configure here.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Artifacts upload workflows:

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.

2 participants