Skip to content

apollo_starknet_os_program: apply v0.14.3 OS-core audit review comments#14870

Draft
Yoni-Starkware wants to merge 1 commit into
mainfrom
worktree-audit-v0.14.3-doc-fixes
Draft

apollo_starknet_os_program: apply v0.14.3 OS-core audit review comments#14870
Yoni-Starkware wants to merge 1 commit into
mainfrom
worktree-audit-v0.14.3-doc-fixes

Conversation

@Yoni-Starkware

@Yoni-Starkware Yoni-Starkware commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Applies the action items from the v0.14.3 OS audit review (PR #14827), over main.

Verified bytecode-neutral: after cargo clean -p apollo_starknet_os_program + full rebuild, the compiled os / virtual_os program hashes and bytecode lengths are unchanged. No fixture regeneration.

Audit comments addressed (8 of 10)

# File Change
1 naive_blake.cairo Document that felt_from_le_u32s assumes each limb is a valid u32; caller/Blake opcode guarantees it
2 naive_blake.cairo Document at entrypoints that limbs aren't guaranteed canonical (< PRIME)
4 naive_blake.cairo Document that per-limb u32 range is enforced by the Blake opcode, not the encoder
6 execution/syscall_impls.cairo Rewrite the sha512 relocation comment to mirror the sha256 one
7 os_config/os_config.cairo Trim the redundant config-hash elaboration sentence
8 os_config/os_config.cairo Drop the redundant tempvar hash_state = hash_state; in the if branch (compiler already aligns the stack) — confirmed no bytecode change
9 os_config/os_config.cairo Label the else-branch alignment tempvar
10 state/state.cairo Document why nothing can access the alias contract's storage before the separate squash

Not included

  • Add protoc #3calc_naive_blake_hash is unused on main, but it is not dead code: it was added via apollo_starknet_os_program,starknet_os: add calc_naive_blake_hash with unit test #13201 (with an #[ignore]d cross-check test whose TODO says "remove #[ignore] once calc_naive_blake_hash is used in the virtual OS program"), and its real consumer lives on the unmerged branch yonatan/virtual-os-blake-message-hash (Poseidon→Blake2s for virtual-OS L2→L1 message hashes). Kept as-is. (The reviewer's alternative — repurposing it into the config hash — would change the config-hash value, a protocol change, out of scope here.)
  • chore: fix codecove #5 — "document inside blake_with_opcode" targets the cairo-lang library (starkware/cairo/common/cairo_blake2s/blake2s.cairo), not this repo; belongs in the cairo-lang mirror PR.

Verification

cargo test -p apollo_starknet_os_program (after clean rebuild) — 6 passed / 0 failed: test_program_hashes, test_program_bytecode_lengths, test_os_constants, test_cairo0_formatting, test_virtual_os_swapped_files, test_get_code_snippet.

🤖 Generated with Claude Code

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

Documentation clarifications plus one redundant-code removal from the audit
review on PR #14827. Verified bytecode-neutral: after a clean rebuild the
compiled os / virtual_os program hashes and bytecode lengths are unchanged.

- naive_blake.cairo: document the u32 range-check and canonical-value
  assumptions of the felt<->u32 encoding helpers and their entrypoints.
- syscall_impls.cairo: align the sha512 relocation comment with sha256's.
- os_config.cairo: trim the config-hash comment; drop the redundant
  `tempvar hash_state = hash_state;` in the if branch (the compiler already
  aligns the stack) and label the remaining else-branch alignment tempvar.
- state.cairo: document why the alias contract's storage cannot be accessed
  before the separate squash.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Yoni-Starkware
Yoni-Starkware force-pushed the worktree-audit-v0.14.3-doc-fixes branch from 05741e7 to be78af9 Compare July 22, 2026 08:22
@Yoni-Starkware Yoni-Starkware changed the title apollo_starknet_os_program: document OS core assumptions from v0.14.3 audit apollo_starknet_os_program: apply v0.14.3 OS-core audit review comments Jul 22, 2026
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