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

sozo: make inspect faster #3056

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions crates/dojo/world/src/local/artifact_to_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@
let entry = entry?;
let path = entry.path();
if path.is_file() {
if path.to_string_lossy().ends_with(".sierra.json") {
trace!("Ignored .sierra.json: {}", path.to_string_lossy().to_string());
continue;

Check warning on line 51 in crates/dojo/world/src/local/artifact_to_local.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo/world/src/local/artifact_to_local.rs#L50-L51

Added lines #L50 - L51 were not covered by tests
}

if let Ok(sierra) =
serde_json::from_reader::<_, SierraClass>(std::fs::File::open(&path)?)
serde_json::from_slice::<SierraClass>(std::fs::read(&path)?.as_slice())
{
let casm_path = PathBuf::from(
path.to_string_lossy()
Expand All @@ -56,9 +61,9 @@
);

let casm_class = if casm_path.exists() {
Some(serde_json::from_reader::<_, CompiledClass>(std::fs::File::open(
&casm_path,
)?)?)
Some(serde_json::from_slice::<CompiledClass>(
std::fs::read(&casm_path)?.as_slice(),
)?)

Check warning on line 66 in crates/dojo/world/src/local/artifact_to_local.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo/world/src/local/artifact_to_local.rs#L66

Added line #L66 was not covered by tests
} else {
None
};
Expand Down Expand Up @@ -161,6 +166,8 @@
with the version.",
name
);
} else {
dojo_resource_found = true;
}

break;
Expand Down Expand Up @@ -361,7 +368,7 @@
fn casm_class_hash_from_sierra_file<P: AsRef<Path>>(path: P) -> Result<Felt> {
let bytecode_max_size = usize::MAX;
let sierra_class: ContractClass =
serde_json::from_reader::<_, ContractClass>(std::fs::File::open(path)?)?;
serde_json::from_slice::<ContractClass>(std::fs::read(path)?.as_slice())?;
let casm_class =
CasmContractClass::from_contract_class(sierra_class, false, bytecode_max_size)?;
Ok(casm_class.compiled_class_hash())
Expand Down
Loading