Skip to content

apollo_storage: add helper to build declared class component hashes for a block#14460

Merged
yoavGrs merged 1 commit into
mainfrom
yoav/declared-class-component-hashes-from-storage
Jun 14, 2026
Merged

apollo_storage: add helper to build declared class component hashes for a block#14460
yoavGrs merged 1 commit into
mainfrom
yoav/declared-class-component-hashes-from-storage

Conversation

@yoavGrs

@yoavGrs yoavGrs commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

apollo_committer: test new edge bottom in witnesses (#14388)

apollo_committer: reduce tests boilerplate (#14425)

apollo_propeller: added unit test infrastructure for testing behaviour (#12273)

Add unit-test infrastructure to exercise the apollo_propeller libp2p Behaviour in
isolation, driving it directly through its NetworkBehaviour interface without spinning
up a real swarm.

  • Add behaviour_test.rs (gated behind #[cfg(test)] from lib.rs) with two harnesses:

    • TestNode: wraps a Behaviour plus its PeerId and drives it via on_swarm_event,
      on_connection_handler_event, and poll.
    • TestEnvironment: holds a BTreeMap of nodes keyed by PeerId, with helpers to build
      a full mesh and register a single equal-weight committee over all nodes.
  • simulate_* helpers (simulate_connect_to, simulate_receive_unit, simulate_connect_all)
    inject swarm/handler events; expect_* helpers poll for and assert on emitted ToSwarm
    events under a timeout; next_with_timeout polls the behaviour with a timeout.

  • Named the event-injection helpers with a simulate_ prefix so call sites make clear they
    simulate swarm interactions rather than perform real ones, and to distinguish them from the
    expect_* assertion helpers (per review feedback).

  • Named the polling helper next_with_timeout rather than next_timeout, which reads as "the
    next timeout" instead of "the next event, with a timeout" (per review feedback).

apollo_storage: add OwnedDbWriteTransaction for persistent transactions (#14439)

apollo_storage: add helper to build declared class component hashes for a block

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

yoavGrs commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@yoavGrs yoavGrs self-assigned this Jun 11, 2026
@yoavGrs yoavGrs marked this pull request as ready for review June 11, 2026 08:36
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Read-only storage aggregation with a focused test; no write-path or auth changes.

Overview
Adds get_declared_class_hash_to_component_hashes in apollo_storage so callers can build the per-block declared_class_hash_to_component_hashes map expected by the OS block input from stored state diffs and Sierra classes.

For a given block it walks class_hash_to_compiled_class_hash in the state diff, keeps only Cairo 1 classes whose first declaration block matches that block (via get_class_definition_block_number), loads each Sierra class, and maps class hash → ContractClassComponentHashes from get_component_hashes(). Entries that only migrate an existing class’s compiled class hash are skipped.

A unit test covers fresh declaration vs migration across two blocks. ContractClassComponentHashes gains Eq/PartialEq in starknet_api for those assertions.

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

@yoavGrs yoavGrs changed the title apollo_committer: test new edge bottom in witnesses (#14388) apollo_storage: add helper to build declared class component hashes for a block Jun 11, 2026
@yoavGrs yoavGrs requested a review from itamar-starkware June 11, 2026 12:15
@yoavGrs yoavGrs force-pushed the yoav/declared-class-component-hashes-from-storage branch from b177114 to 849fe29 Compare June 14, 2026 07:12
Comment thread crates/apollo_storage/src/class.rs

Copy link
Copy Markdown
Contributor

PR description is weird...he is explaining other PRs

Comment thread crates/apollo_storage/src/class.rs

@itamar-starkware itamar-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read my non-blocking comments before merging.

…nent hashes for a block

Add `get_declared_class_hash_to_component_hashes`, mapping each Cairo 1 class
freshly declared in a block to its contract class component hashes (matching the
OS block input). Classes whose compiled class hash was merely migrated in the
block (declared in an earlier block) are excluded.

The helper takes `impl StateStorageReader + ClassStorageReader` rather than a
concrete transaction. Derive `Eq`/`PartialEq` for `ContractClassComponentHashes`
so the test can assert on the returned map directly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yoavGrs yoavGrs force-pushed the yoav/declared-class-component-hashes-from-storage branch from 849fe29 to 2903c18 Compare June 14, 2026 14:05

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@yoavGrs made 3 comments.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on itamar-starkware and yoavGrs).

Comment thread crates/apollo_storage/src/class.rs
Comment thread crates/apollo_storage/src/class.rs

@itamar-starkware itamar-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itamar-starkware reviewed 3 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on yoavGrs).

@yoavGrs yoavGrs added this pull request to the merge queue Jun 14, 2026
Merged via the queue into main with commit f012c83 Jun 14, 2026
27 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.

3 participants