Skip to content

blockifier: replace flags in cairo native run config with enum#12717

Merged
ArniStarkware merged 1 commit intomain-v0.14.2from
arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation
Feb 25, 2026
Merged

blockifier: replace flags in cairo native run config with enum#12717
ArniStarkware merged 1 commit intomain-v0.14.2from
arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation

Conversation

@ArniStarkware
Copy link
Copy Markdown
Contributor

@ArniStarkware ArniStarkware commented Feb 18, 2026

Note

Medium Risk
Touches core contract class compilation/execution configuration and changes defaults/serialization, which can alter native compilation behavior at runtime if configs aren’t migrated correctly.

Overview
Refactors Cairo native execution configuration from two booleans (run_cairo_native, wait_on_native_compilation) into a single CairoNativeMode enum (off, wait_on_compilation, lazy_compilation) and wires this through CairoNativeRunConfig/ContractClassManagerConfig.

Updates the class manager startup and compilation flow to branch on the new mode (no worker in Off or WaitOnCompilation; async worker only in LazyCompilation), adjusts invariants/assertions, and migrates all tests and helper constructors to the new API.

Migrates node/deployment JSON configs and the config schema to the new cairo_native_run_mode field (defaulting to off in schema; lazy_compilation in provided app configs), and adds a compatibility mapping in native_blockifier’s Python config conversion from the old flags to the new enum.

Written by Cursor Bugbot for commit 82616a7. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor Author

ArniStarkware commented Feb 18, 2026

Comment thread crates/blockifier/src/state/native_class_manager.rs
Comment thread crates/blockifier/src/blockifier/config.rs Outdated
@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from 81d6d3a to 1f76a02 Compare February 18, 2026 20:10
@ArniStarkware ArniStarkware changed the base branch from arni/blockifier/native_class_manager/get_runnable_for_readablity to graphite-base/12717 February 19, 2026 13:09
@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from 1f76a02 to 922fbba Compare February 19, 2026 13:09
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 2 comments and resolved 2 discussions.
Reviewable status: 0 of 16 files reviewed, all discussions resolved.

Comment thread crates/blockifier/src/blockifier/config.rs Outdated
Comment thread crates/blockifier/src/state/native_class_manager.rs
@ArniStarkware ArniStarkware changed the base branch from graphite-base/12717 to main-v0.14.2 February 19, 2026 13:09
Comment thread crates/apollo_deployments/resources/app_configs/gateway_config.json Outdated
Comment thread crates/apollo_deployments/resources/app_configs/gateway_config.json Outdated
@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from 922fbba to a19e630 Compare February 19, 2026 13:16
Comment thread crates/blockifier/src/state/state_reader_and_contract_manager_test.rs Outdated
Comment thread crates/apollo_consensus_orchestrator_config/src/config.rs Outdated
@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from a19e630 to 00531e9 Compare February 19, 2026 13:54
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 1 comment.
Reviewable status: 0 of 17 files reviewed, all discussions resolved.


a discussion (no related file):
Collides with #12696.

Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware reviewed 1 file.
Reviewable status: 1 of 17 files reviewed, all discussions resolved.

@ArniStarkware
Copy link
Copy Markdown
Contributor Author

crates/blockifier/src/blockifier/config.rs line 299 at r4 (raw file):

    WaitOnCompilation,
    DontWaitOnCompilation,
}

Points of discussion:

  1. The name of the struct.
  2. The name of the variants.
  3. How should the variants serialize?

Code quote:

#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum RunCairoNativeOptions {
    Off,
    WaitOnCompilation,
    DontWaitOnCompilation,
}

@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from 00531e9 to 40616b3 Compare February 22, 2026 12:50
Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware left a comment

Choose a reason for hiding this comment

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

@avi-starkware reviewed 17 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ArniStarkware).


crates/blockifier/src/blockifier/config.rs line 299 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Points of discussion:

  1. The name of the struct.
  2. The name of the variants.
  3. How should the variants serialize?
  1. Can be CairoNativeMode
  2. The last variant can be CompilationWorkerThread instead, and I like WaitOnCompilation.
  3. Use "snake_case" for readability.

crates/blockifier/src/state/native_class_manager.rs line 165 at r5 (raw file):

            CompiledClasses::V0(_) => self.class_cache.set(class_hash, compiled_class),
            CompiledClasses::V1(compiled_class_v1, sierra_contract_class) => {
                if let CairoNativeRunMode::SynchronousCompilation = self.cairo_native_run_mode() {

Suggestion:

                if self.cairo_native_run_mode() == CairoNativeRunMode::SynchronousCompilation {

crates/blockifier/src/state/native_class_manager.rs line 186 at r5 (raw file):

                );

                if let CairoNativeRunMode::AsynchronousCompilation = self.cairo_native_run_mode() {

Suggestion:

                if self.cairo_native_run_mode() == CairoNativeRunMode::AsynchronousCompilation {

@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from 40616b3 to e51a471 Compare February 23, 2026 15:24
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 3 comments and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArniStarkware).


crates/blockifier/src/blockifier/config.rs line 299 at r4 (raw file):

Previously, avi-starkware (Avi Cohen) wrote…
  1. Can be CairoNativeMode
  2. The last variant can be CompilationWorkerThread instead, and I like WaitOnCompilation.
  3. Use "snake_case" for readability.

Done, except for 2.a. I don't like CompilationWorkerThread. That is not a "mode"...


crates/blockifier/src/state/native_class_manager.rs line 165 at r5 (raw file):

            CompiledClasses::V0(_) => self.class_cache.set(class_hash, compiled_class),
            CompiledClasses::V1(compiled_class_v1, sierra_contract_class) => {
                if let CairoNativeRunMode::SynchronousCompilation = self.cairo_native_run_mode() {

Done.


crates/blockifier/src/state/native_class_manager.rs line 186 at r5 (raw file):

                );

                if let CairoNativeRunMode::AsynchronousCompilation = self.cairo_native_run_mode() {

Done.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread crates/native_blockifier/src/py_objects.rs
Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware left a comment

Choose a reason for hiding this comment

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

@avi-starkware made 1 comment.
Reviewable status: 1 of 17 files reviewed, 1 unresolved discussion (waiting on ArniStarkware).


crates/blockifier/src/blockifier/config.rs line 299 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Done, except for 2.a. I don't like CompilationWorkerThread. That is not a "mode"...

It is just the terminology used in the native class manager. We call the thread responsible for compilation the "compilation worker".

The execution worker thread running the class either compiles the class itself and then runs it (in mode WaitOnCompilation), or sends a compilation request to the compilation worker thread and runs the casm in the VM instead of waiting.

We could call it DeferCompilation, DelegateCompilation, LazyCompilation, or something like that...

Comment thread crates/native_blockifier/src/py_objects.rs
@ArniStarkware ArniStarkware force-pushed the arni/blockifier/native_class_manager/config/replace_config_for_wait_on_native_compilation branch from e51a471 to 82616a7 Compare February 25, 2026 09:44
@ArniStarkware
Copy link
Copy Markdown
Contributor Author

crates/blockifier/src/blockifier/config.rs line 299 at r4 (raw file):

Previously, avi-starkware (Avi Cohen) wrote…

It is just the terminology used in the native class manager. We call the thread responsible for compilation the "compilation worker".

The execution worker thread running the class either compiles the class itself and then runs it (in mode WaitOnCompilation), or sends a compilation request to the compilation worker thread and runs the casm in the VM instead of waiting.

We could call it DeferCompilation, DelegateCompilation, LazyCompilation, or something like that...

Done.

Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware left a comment

Choose a reason for hiding this comment

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

@avi-starkware reviewed 16 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArniStarkware).

Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArniStarkware).

Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@avi-starkware made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArniStarkware).

@ArniStarkware ArniStarkware added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main-v0.14.2 with commit 57622ff Feb 25, 2026
24 of 26 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants