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

refactor: streamline class info object to match contract class #427

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Aug 13, 2024

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Aug 13, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

Join @ArniStarkware and the rest of your teammates on Graphite Graphite

@ArniStarkware ArniStarkware marked this pull request as ready for review August 13, 2024 11:19
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch 3 times, most recently from ad0e6f0 to 2f12b2a Compare August 14, 2024 15:34
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 51.85185% with 13 lines in your changes missing coverage. Please review.

Please upload report for BASE (arni/snapi/contract_class_refacrtor/class_info_new_method@85481c0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/papyrus_execution/src/lib.rs 25.00% 4 Missing and 2 partials ⚠️
crates/native_blockifier/src/py_transaction.rs 0.00% 5 Missing ⚠️
crates/blockifier/src/execution/contract_class.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@                                     Coverage Diff                                      @@
##             arni/snapi/contract_class_refacrtor/class_info_new_method     #427   +/-   ##
============================================================================================
  Coverage                                                             ?   62.70%           
============================================================================================
  Files                                                                ?      146           
  Lines                                                                ?    17999           
  Branches                                                             ?    17999           
============================================================================================
  Hits                                                                 ?    11287           
  Misses                                                               ?     5880           
  Partials                                                             ?      832           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@yair-starkware yair-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 2 of 5 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware)


crates/blockifier/src/execution/contract_class.rs line 49 at r3 (raw file):

/// We wrap the actual class in an Arc to avoid cloning the program when cloning the class.
// Note: when deserializing from a SN API class JSON string, the ABI field is ignored
// by serde, since it is not required for execution.

What is this referring to?

Code quote:

/// Represents a runnable Starknet contract class (meaning, the program is runnable by the VM).
/// We wrap the actual class in an Arc to avoid cloning the program when cloning the class.
// Note: when deserializing from a SN API class JSON string, the ABI field is ignored
// by serde, since it is not required for execution.

crates/gateway/src/compilation.rs line 3 at r3 (raw file):

use std::sync::Arc;

use blockifier::execution::contract_class::{ClassInfo, ContractClassV1};

Consider using as BlockifierContractClass

Code quote:

ContractClassV1

crates/papyrus_execution/src/lib.rs line 760 at r3 (raw file):

            )?);
            let class_info = ClassInfo::new(&class_v0, DEPRECATED_CONTRACT_SIERRA_SIZE, abi_length)
                .map_err(|err| ExecutionError::BadDeclareTransaction {

Is this error still in use?

Code quote:

ExecutionError::BadDeclareTransaction

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 2f12b2a to 52a0311 Compare August 15, 2024 10:44
Copy link
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.

Reviewable status: 2 of 5 files reviewed, 1 unresolved discussion (waiting on @yair-starkware)


crates/blockifier/src/execution/contract_class.rs line 49 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

What is this referring to?

The original intent was to document ContractClass:
https://reviewable.io/reviews/starkware-libs/blockifier/452

Done.


crates/gateway/src/compilation.rs line 3 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

Consider using as BlockifierContractClass

Done.


crates/papyrus_execution/src/lib.rs line 760 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

Is this error still in use?

No! 🥳
Removed.

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 52a0311 to 4edc527 Compare August 15, 2024 11:20
Copy link
Contributor

@yair-starkware yair-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 2 of 3 files at r4, all commit messages.
Reviewable status: 4 of 5 files reviewed, all discussions resolved (waiting on @ArniStarkware)


crates/blockifier/src/execution/contract_class.rs line 49 at r3 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

The original intent was to document ContractClass:
https://reviewable.io/reviews/starkware-libs/blockifier/452

Done.

I don't understand how the comment matches the type (where is the Arc?)

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 4edc527 to a24e9fd Compare August 18, 2024 09:16
@ArniStarkware ArniStarkware changed the base branch from main to arni/contract_class_refactor/docstring_fix August 18, 2024 09:16
@ArniStarkware
Copy link
Contributor Author

crates/blockifier/src/execution/contract_class.rs line 49 at r3 (raw file):

Previously, yair-starkware (Yair) wrote…

I don't understand how the comment matches the type (where is the Arc?)

You are correct.

This issue is now handled in #491. I think these are unrelated issues, and I hope the prep PR will be merged long before this one.

Copy link
Contributor

@yair-starkware yair-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:

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

@ArniStarkware ArniStarkware changed the base branch from arni/contract_class_refactor/docstring_fix to graphite-base/427 August 18, 2024 11:38
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from a24e9fd to 8c8184d Compare August 18, 2024 11:38
@ArniStarkware ArniStarkware changed the base branch from graphite-base/427 to main August 18, 2024 11:39
@ArniStarkware
Copy link
Contributor Author

crates/blockifier/src/execution/contract_class.rs line 502 at r5 (raw file):

    V0 { contract_class: ContractClassV0, abi_length: usize },
    V1 { contract_class: ContractClassV1, sierra_program_length: usize, abi_length: usize },
}

Is this cleaner, in your opinion?

Suggestion:

pub enum ClassInfo {
    V0 (ClassInfoV0),
    V1 (ClassInfoV1),
}

pub struct ClassInfoV0 {contract_class: ContractClassV0, abi_length: usize};
pub struct ClassInfoV1 {contract_class: ContractClassV1, sierra_program_length: usize, abi_length: usize };

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 8c8184d to 7b7cc8b Compare August 21, 2024 08:19
Copy link
Contributor

@yair-starkware yair-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 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)


crates/blockifier/src/execution/contract_class.rs line 502 at r5 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Is this cleaner, in your opinion?

No

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 7b7cc8b to e19524c Compare August 25, 2024 15:51
Copy link
Contributor

@yair-starkware yair-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:

Reviewed 5 of 5 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from e19524c to ca57611 Compare September 15, 2024 07:24
Copy link
Contributor

@yair-starkware yair-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 4 of 4 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from ca57611 to d458a7c Compare September 18, 2024 10:13
Copy link
Contributor

@yair-starkware yair-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 3 of 3 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from d458a7c to a013fb2 Compare September 30, 2024 07:48
@ArniStarkware
Copy link
Contributor Author

crates/blockifier/src/execution/contract_class.rs line 565 at r10 (raw file):

    V0 { contract_class: ContractClassV0, abi_length: usize },
    V1 { contract_class: ContractClassV1, sierra_program_length: usize, abi_length: usize },
}

This is the main innovation of this PR.
This, and deleting the combersom new class method.

Code quote:

pub enum ClassInfo {
    V0 { contract_class: ContractClassV0, abi_length: usize },
    V1 { contract_class: ContractClassV1, sierra_program_length: usize, abi_length: usize },
}

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch 2 times, most recently from a557ae3 to 9960a4b Compare October 7, 2024 06:46
@ArniStarkware ArniStarkware changed the base branch from main to arni/snapi/contract_class_refacrtor/class_info_new_method October 7, 2024 06:46
Copy link
Collaborator

@noaov1 noaov1 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 1 files at r11.
Reviewable status: 1 of 5 files reviewed, all discussions resolved (waiting on @yair-starkware)


crates/blockifier/src/execution/contract_class.rs line 565 at r10 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

This is the main innovation of this PR.
This, and deleting the combersom new class method.

Using two separate enums (ContractClass and ClassInfo) that mirror each other's structure can be redundant and can make the code harder to maintain, as any changes to ContractClass would need to be reflected in ClassInfo

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refacrtor/class_info_new_method branch from 32c4b2e to 112302a Compare October 7, 2024 07:23
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 9960a4b to 0c792be Compare October 7, 2024 07:23
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refacrtor/class_info_new_method branch from 112302a to 85481c0 Compare October 7, 2024 07:29
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 0c792be to 5120579 Compare October 7, 2024 07:29
@ArniStarkware
Copy link
Contributor Author

crates/blockifier/src/execution/contract_class.rs line 565 at r10 (raw file):

Previously, noaov1 (Noa Oved) wrote…

Using two separate enums (ContractClass and ClassInfo) that mirror each other's structure can be redundant and can make the code harder to maintain, as any changes to ContractClass would need to be reflected in ClassInfo

I split this PR into this one and #1215. PTAL.

@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refacrtor/class_info_new_method branch 2 times, most recently from d4d1890 to 955c47e Compare October 7, 2024 14:59
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refacrtor/class_info_new_method branch from 955c47e to 625fcaf Compare October 8, 2024 10:57
@ArniStarkware ArniStarkware force-pushed the arni/snapi/contract_class_refactor/class_info_streamline branch from 5120579 to 55a6aae Compare October 8, 2024 10:57
Copy link

github-actions bot commented Oct 8, 2024

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [34.382 ms 34.494 ms 34.647 ms]
change: [-5.9984% -3.5090% -1.3443%] (p = 0.00 < 0.05)
Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
7 (7.00%) high mild
6 (6.00%) high severe

@ArniStarkware
Copy link
Contributor Author

No longer relevant. It becomes harder to streamline now that there are three variants of contract class.

@ArniStarkware ArniStarkware deleted the arni/snapi/contract_class_refactor/class_info_streamline branch October 10, 2024 15:51
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2024
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