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(starknet_integration_tests): move classes outside #4010

Merged
merged 1 commit into from
Feb 9, 2025

Conversation

yair-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

graphite-app bot commented Feb 6, 2025

Graphite Automations

"Yair - Auto-assign" took an action on this PR • (02/06/25)

1 assignee was added to this PR based on Yair's automation.

Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)


crates/starknet_integration_tests/src/state_reader.rs line 58 at r1 (raw file):

    pub class_manager_storage_handles: TempDirHandlePair,
}

Any way to prevent some of the clones? Those tests (and CI in general) are long as it is. 😅

Copy link
Contributor

@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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @yair-starkware)


crates/starknet_integration_tests/src/state_reader.rs line 172 at r1 (raw file):

    pub cairo0_contract_classes: Vec<(ClassHash, DeprecatedContractClass)>,
    pub sierra_vec: Vec<(ClassHash, SierraContractClass)>,
    pub cairo1_contract_classes: Vec<(ClassHash, CasmContractClass)>,

Why do we need both Sierra classes and Casm classes?
Are Sierra classes only used for declares and Casm for everything else?

I see this variable is later unpacked as cairo1_sierra. Keep the name consistent throughout (This part is non-blocking).

Suggestion:

    pub cairo1_sierra_classes: Vec<(ClassHash, SierraContractClass)>,
    pub cairo1_contract_classes: Vec<(ClassHash, CasmContractClass)>,

Copy link
Collaborator

@elintul elintul 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 1 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @yair-starkware)


crates/starknet_integration_tests/src/state_reader.rs line 172 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Why do we need both Sierra classes and Casm classes?
Are Sierra classes only used for declares and Casm for everything else?

I see this variable is later unpacked as cairo1_sierra. Keep the name consistent throughout (This part is non-blocking).

We need both in the sequencer's flow; we don't have declares yet (and even when we will, we need a set of precompiled classes to start from) so we need to feed both to the system. We could have compiled Sierra in the setup of the test, but wanted to save time; it's long as it is.

@yair-starkware yair-starkware force-pushed the yair/extract_preset_contracts branch from b1c7c76 to 69504b4 Compare February 9, 2025 09:59
@yair-starkware yair-starkware force-pushed the yair/prepare_all_classes branch from 9eb9e9e to c499508 Compare February 9, 2025 09:59
Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 4 unresolved discussions (waiting on @ArniStarkware and @yair-starkware)


crates/starknet_integration_tests/src/state_reader.rs line 172 at r3 (raw file):

    pub cairo0_contract_classes: Vec<(ClassHash, DeprecatedContractClass)>,
    pub sierra_vec: Vec<(ClassHash, SierraContractClass)>,
    pub cairo1_contract_classes: Vec<(ClassHash, CasmContractClass)>,

Either this, or cairo1_sierras, but they are coupled, so putting them together makes sense.

Suggestion:

    pub cairo0_casms: Vec<(ClassHash, DeprecatedContractClass)>,
    pub cairo1_classes: Vec<(ClassHash, (SierraContractClass, CasmContractClass))>,

crates/starknet_integration_tests/src/state_reader.rs line 177 at r3 (raw file):

impl TestClasses {
    pub fn new(
        test_defined_accounts: Vec<AccountTransactionGenerator>,

Then to .iter(), so save cloneing.

Suggestion:

&[AccountTransactionGenerator],

Copy link
Collaborator

@elintul elintul 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 r2.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ArniStarkware and @yair-starkware)


crates/starknet_integration_tests/src/state_reader.rs line 197 at r3 (raw file):

    storage_writer: &mut StorageWriter,
    chain_info: &ChainInfo,
    test_defined_accounts: Vec<AccountTransactionGenerator>,

Suggestion:

test_defined_accounts: &[AccountTransactionGenerator],

@yair-starkware yair-starkware force-pushed the yair/prepare_all_classes branch from c499508 to ae91ded Compare February 9, 2025 11:07
@yair-starkware yair-starkware changed the base branch from yair/extract_preset_contracts to main February 9, 2025 11:07
@yair-starkware yair-starkware force-pushed the yair/prepare_all_classes branch from ae91ded to 507076a Compare February 9, 2025 11:08
Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @elintul)


crates/starknet_integration_tests/src/state_reader.rs line 58 at r1 (raw file):

Previously, elintul (Elin) wrote…

Any way to prevent some of the clones? Those tests (and CI in general) are long as it is. 😅

Added todo


crates/starknet_integration_tests/src/state_reader.rs line 172 at r1 (raw file):

Previously, elintul (Elin) wrote…

We need both in the sequencer's flow; we don't have declares yet (and even when we will, we need a set of precompiled classes to start from) so we need to feed both to the system. We could have compiled Sierra in the setup of the test, but wanted to save time; it's long as it is.

merged the vecs


crates/starknet_integration_tests/src/state_reader.rs line 172 at r3 (raw file):

Previously, elintul (Elin) wrote…

Either this, or cairo1_sierras, but they are coupled, so putting them together makes sense.

Done


crates/starknet_integration_tests/src/state_reader.rs line 177 at r3 (raw file):

Previously, elintul (Elin) wrote…

Then to .iter(), so save cloneing.

Done


crates/starknet_integration_tests/src/state_reader.rs line 197 at r3 (raw file):

    storage_writer: &mut StorageWriter,
    chain_info: &ChainInfo,
    test_defined_accounts: Vec<AccountTransactionGenerator>,

Done

Copy link
Collaborator

@elintul elintul 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 r4, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ArniStarkware and @elintul)


crates/starknet_integration_tests/src/state_reader.rs line 261 at r4 (raw file):

                    contract.class_hash(),
                    (sierra, serde_json::from_str(&contract.raw_class()).unwrap()),
                );

Easier to read.

Suggestion:

                let sierra = contract.sierra();
                let casm = serde_json::from_str(&contract.raw_class()).unwrap());
                cairo1_contract_classes.insert(contract.class_hash(), (sierra, casm));

crates/starknet_integration_tests/src/state_reader.rs line 268 at r4 (raw file):

    (
        cairo0_contract_classes.into_iter().collect(),
        cairo1_contract_classes.into_iter().map(|(ch, (s, c))| (ch, s, c)).collect(),

Why flatten?

Code quote:

map(|(ch, (s, c))| (ch, s, c))

crates/starknet_integration_tests/src/state_reader.rs line 285 at r4 (raw file):

    let mut write_txn = storage_writer.begin_rw_txn().unwrap();

    let mut sierra_vec = vec![];

Suggestion:

let mut sierras = Vec::with_capacity(cairo1_contract_classes.len());

@yair-starkware yair-starkware force-pushed the yair/prepare_all_classes branch 3 times, most recently from 06b8e96 to e474961 Compare February 9, 2025 11:24
Copy link
Collaborator

@elintul elintul 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 1 of 1 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)

@yair-starkware yair-starkware force-pushed the yair/prepare_all_classes branch from e474961 to dc72e95 Compare February 9, 2025 11:25
Copy link
Contributor Author

@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.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)


crates/starknet_integration_tests/src/state_reader.rs line 261 at r4 (raw file):

Previously, elintul (Elin) wrote…

Easier to read.

Done


crates/starknet_integration_tests/src/state_reader.rs line 268 at r4 (raw file):

Previously, elintul (Elin) wrote…

Why flatten?

Removed


crates/starknet_integration_tests/src/state_reader.rs line 285 at r4 (raw file):

    let mut write_txn = storage_writer.begin_rw_txn().unwrap();

    let mut sierra_vec = vec![];

Done

Copy link
Collaborator

@elintul elintul 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, 1 unresolved discussion (waiting on @ArniStarkware)

Copy link
Contributor

@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.

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yair-starkware)

@yair-starkware yair-starkware added this pull request to the merge queue Feb 9, 2025
Copy link
Collaborator

@elintul elintul 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 @yair-starkware)

Merged via the queue into main with commit d1c4b7c Feb 9, 2025
9 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.

4 participants