Skip to content

Commit

Permalink
chore(execution): add workspace lints (#1794)
Browse files Browse the repository at this point in the history
Lior banned `as` repo-wide, unless absolutely necessary.

Nearly all as uses can be replaced with [Try]From which doesn't
have implicit coercions like as (we encountered several bugs due to these coercions).

Motivation: we are standardizing lints across the repo and CI,
instead of each crate having separate sets of lints.

Co-Authored-By: Gilad Chase <gilad@starkware.com>
  • Loading branch information
giladchase and Gilad Chase authored Nov 5, 2024
1 parent fcc6b10 commit 2c166ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions crates/papyrus_execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ papyrus_test_utils.workspace = true
[package.metadata.cargo-machete]
# The `rand` crate is used in the `testing` feature, which is optional.
ignored = ["rand"]

[lints]
workspace = true
7 changes: 4 additions & 3 deletions crates/papyrus_execution/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use blockifier::execution::call_info::{
};
use blockifier::execution::entry_point::CallType as BlockifierCallType;
use blockifier::transaction::objects::{FeeType, TransactionExecutionInfo};
use blockifier::utils::u64_from_usize;
use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources as VmExecutionResources;
use indexmap::IndexMap;
Expand Down Expand Up @@ -368,7 +369,7 @@ fn vm_resources_to_execution_resources(
if count == 0 {
continue;
}
let count: u64 = count as u64;
let count = u64_from_usize(count);
match builtin_name {
BuiltinName::output => continue,
BuiltinName::pedersen => builtin_instance_counter.insert(Builtin::Pedersen, count),
Expand All @@ -391,9 +392,9 @@ fn vm_resources_to_execution_resources(
};
}
Ok(ExecutionResources {
steps: vm_resources.n_steps as u64,
steps: u64_from_usize(vm_resources.n_steps),
builtin_instance_counter,
memory_holes: vm_resources.n_memory_holes as u64,
memory_holes: u64_from_usize(vm_resources.n_memory_holes),
da_gas_consumed: StarknetApiGasVector { l1_gas, l2_gas, l1_data_gas },
gas_consumed: StarknetApiGasVector::default(),
})
Expand Down

0 comments on commit 2c166ff

Please sign in to comment.