Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blockifier): add config to support choosing a single contract to compile natively #4523

Conversation

avivg-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@avivg-starkware avivg-starkware marked this pull request as ready for review February 27, 2025 10:42
Copy link
Contributor Author

avivg-starkware commented Feb 27, 2025

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

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/contract_to_compile_natively branch from d009bc0 to 8a5861c Compare February 27, 2025 10:46
@avivg-starkware
Copy link
Contributor Author

crates/native_blockifier/src/py_objects.rs line 195 at r1 (raw file):

    fn from(py_cairo_native_run_config: PyCairoNativeRunConfig) -> Self {
        // TODO(AvivG): should add assert testing class_hash is OK?
        let contract_to_compile_natively =

// Should add assert testing class_hash is OK?

Copy link
Contributor Author

@avivg-starkware avivg-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: 0 of 5 files reviewed, 2 unresolved discussions


crates/blockifier/src/state/native_class_manager.rs line 199 at r2 (raw file):

    /// `None` enables all, an empty list disables all, and listed contracts are compiled natively.
    /// TODO(AvivG): implement for list, currently only one contract is supported.
    fn compile_with_native(&self, class_hash: ClassHash) -> bool {

Considering this change. @noaov1 WDYT?

Suggestion:

compile_natively

@avivg-starkware avivg-starkware requested a review from noaov1 March 2, 2025 08:03
Copy link
Contributor Author

@avivg-starkware avivg-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: 0 of 5 files reviewed, 3 unresolved discussions (waiting on @noaov1)


config/sequencer/default_config.json line 98 at r2 (raw file):

  },
  "batcher_config.contract_class_manager_config.cairo_native_run_config.contract_to_compile_natively.#is_none": {
    "description": "Flag for an optional field.",

Should this description be fixed?

Code quote:

description": "Flag for an optional field.

Copy link
Contributor

@meship-starkware meship-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @AvivYossef-starkware and @noaov1)


crates/blockifier/src/state/native_class_manager.rs line 199 at r2 (raw file):

Previously, avivg-starkware wrote…

Considering this change. @noaov1 WDYT?

Compiling with native or using native is a more indicative name, IMO. It might not be clear what natively represents.


crates/blockifier/src/blockifier/config.rs line 148 at r2 (raw file):

    pub channel_size: usize,
    pub contract_to_compile_natively: Option<ClassHash>, /* if 'None' compile all contracts
                                                          * natively. */

Suggestion:

    pub contract_to_compile_with_native: Option<ClassHash>, /* if 'None' compile all contracts
                                                          * natively. */

crates/blockifier/src/blockifier/config.rs line 188 at r2 (raw file):

            ClassHash::default(),
            "contract_to_compile_natively",
            "The contract to compile natively.",

Suggestion:

"The contract to compile using Cario native compilation.",

Copy link
Contributor Author

@avivg-starkware avivg-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: all files reviewed, 4 unresolved discussions (waiting on @AvivYossef-starkware, @meship-starkware, and @noaov1)


crates/blockifier/src/state/native_class_manager.rs line 199 at r2 (raw file):

Previously, meship-starkware (Meshi Peled) wrote…

Compiling with native or using native is a more indicative name, IMO. It might not be clear what natively represents.

changed


crates/blockifier/src/blockifier/config.rs line 148 at r2 (raw file):

    pub channel_size: usize,
    pub contract_to_compile_natively: Option<ClassHash>, /* if 'None' compile all contracts
                                                          * natively. */

Done


crates/blockifier/src/blockifier/config.rs line 188 at r2 (raw file):

            ClassHash::default(),
            "contract_to_compile_natively",
            "The contract to compile natively.",

Done.

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/contract_to_compile_natively branch from 5615d50 to c9a99a5 Compare March 2, 2025 10:57
Copy link
Contributor

@AvivYossef-starkware AvivYossef-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: 0 of 5 files reviewed, 5 unresolved discussions (waiting on @meship-starkware and @noaov1)


crates/blockifier/src/blockifier/config.rs line 147 at r3 (raw file):

    pub wait_on_native_compilation: bool,
    pub channel_size: usize,
    pub contract_to_compile_with_native: Option<ClassHash>, /* if 'None' compile all contracts

Im not sure I undestand,
if contract_to_compile_with_native=class_hash "0x1" we compile everything beside "0x1" to Casm and if `contract_to_compile_with_native=None we compile everything to Native?

Copy link
Contributor

@AvivYossef-starkware AvivYossef-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: 0 of 5 files reviewed, 7 unresolved discussions (waiting on @avivg-starkware, @meship-starkware, and @noaov1)


crates/native_blockifier/src/py_objects.rs line 195 at r1 (raw file):

Previously, avivg-starkware wrote…

// Should add assert testing class_hash is OK?

How can you test it?
What do you mean by ok?


crates/blockifier/src/state/native_class_manager.rs line 120 at r3 (raw file):

            CachedClass::V0(_) => self.cache.set(class_hash, compiled_class),
            CachedClass::V1(compiled_class_v1, sierra_contract_class) => {
                if !self.compile_with_native(class_hash) {

This means that we won't compile any other contract to native even if wait_on_native_compilation is set to true. Is this the desired behavior?


crates/blockifier/src/state/native_class_manager.rs line 197 at r3 (raw file):

    /// Determines if a contract should be compiled natively based on the allowlist.
    /// `None` enables all, an empty list disables all, and listed contracts are compiled natively.

Right Now we don't have a list,
so adjust the docstring.


config/sequencer/default_config.json line 101 at r3 (raw file):

    "privacy": "TemporaryValue",
    "value": true
  },

Try this

  "batcher_config.contract_class_manager_config.cairo_native_run_config.contract_to_compile_with_native": {
    "description": "The contract to compile using Cario native compilation.",
    "privacy": "Public",
    "value": null
  },

Code quote:

  "batcher_config.contract_class_manager_config.cairo_native_run_config.contract_to_compile_with_native": {
    "description": "The contract to compile using Cario native compilation.",
    "privacy": "Public",
    "value": "0x0"
  },
  "batcher_config.contract_class_manager_config.cairo_native_run_config.contract_to_compile_with_native.#is_none": {
    "description": "Flag for an optional field.",
    "privacy": "TemporaryValue",
    "value": true
  },

@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2025
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.

4 participants