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

Get features from all targets #2570

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

cptartur
Copy link
Member

@cptartur cptartur commented Oct 7, 2024

Closes #2568
Closes #2567

Introduced changes

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

Copy link
Member

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

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

Only reviewed the logic

[nit] name_for_package is used only in a unittest, we can remove it
[nit] please move public stuff up in this file and private stuff below it, will be much easier to read

Ofc should be in a separate PR

crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
// TODO use const
let base_artifacts = contracts_paths
.iter()
.find(|paths| paths.test_type == Some("integration".to_string()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this prioritize None i.e. contracts from starknet-contract? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Logic was changed. But there's no case where we have contracts both from "starknet-contract" and from "integration". It's either first if we build with scarb build or the second when using scarb build --test.

Comment on lines 188 to 193
for artifact in other_artifacts {
let artifact = load_contracts_artifacts_and_source_sierra_paths(&artifact.path)?;
for (key, value) in artifact {
base_artifacts.entry(key).or_insert(value);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand correctly, this is only meant to be a fallback?
If so, isn't it extremely wasteful, that it compiles all contract files with USC before checking if you even need them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw. I still think it should be possible to compile all contract files in parallel with multiple usc processes.

Copy link
Member

@piotmag769 piotmag769 Oct 16, 2024

Choose a reason for hiding this comment

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

Good point, this part is not optimised very well. Imo worth a separate task

Copy link
Member Author

Choose a reason for hiding this comment

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

We can use par_iter to compile these in parallel, it should be safe.

Copy link
Member

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

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

Logic looks fine

crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +96 to +104
.other_files
.par_iter()
.map(load_contracts_artifacts_and_source_sierra_paths)
.collect::<Result<Vec<_>>>()?;

for artifact in compiled_artifacts {
for (key, value) in artifact {
base_artifacts.entry(key).or_insert(value);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It still compiles those files, just to most probably discard them anyway? 👀
Can't we check if we need specific contract artifact without compiling it first?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I think we can do that. I'll change it so it only compiles artifacts which names' didn't occur before.

crates/scarb-api/src/lib.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants