This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(native_blockifier): remove unused py objects (#1864)
- Loading branch information
1 parent
938d287
commit 78b6e20
Showing
5 changed files
with
69 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use std::collections::HashMap; | ||
|
||
use blockifier::abi::constants; | ||
use blockifier::bouncer::{BouncerConfig, BouncerWeights, BuiltinCount}; | ||
use cairo_vm::vm::runners::cairo_runner::ExecutionResources; | ||
use pyo3::prelude::*; | ||
|
||
// From Rust to Python. | ||
|
||
#[pyclass] | ||
#[derive(Clone, Default)] | ||
pub struct PyExecutionResources { | ||
#[pyo3(get)] | ||
pub n_steps: usize, | ||
#[pyo3(get)] | ||
pub builtin_instance_counter: HashMap<String, usize>, | ||
#[pyo3(get)] | ||
pub n_memory_holes: usize, | ||
} | ||
|
||
impl From<ExecutionResources> for PyExecutionResources { | ||
fn from(resources: ExecutionResources) -> Self { | ||
Self { | ||
n_steps: resources.n_steps, | ||
builtin_instance_counter: resources.builtin_instance_counter, | ||
n_memory_holes: resources.n_memory_holes, | ||
} | ||
} | ||
} | ||
|
||
// From Python to Rust. | ||
|
||
#[derive(Clone, Debug, FromPyObject)] | ||
pub struct PyBouncerConfig { | ||
pub full_total_weights_with_keccak: HashMap<String, usize>, | ||
pub full_total_weights: HashMap<String, usize>, | ||
} | ||
|
||
impl From<PyBouncerConfig> for BouncerConfig { | ||
fn from(py_bouncer_config: PyBouncerConfig) -> Self { | ||
BouncerConfig { | ||
block_max_capacity: hash_map_into_bouncer_weights( | ||
py_bouncer_config.full_total_weights.clone(), | ||
), | ||
block_max_capacity_with_keccak: hash_map_into_bouncer_weights( | ||
py_bouncer_config.full_total_weights_with_keccak.clone(), | ||
), | ||
} | ||
} | ||
} | ||
|
||
fn hash_map_into_bouncer_weights(mut data: HashMap<String, usize>) -> BouncerWeights { | ||
BouncerWeights { | ||
gas: data.remove(constants::L1_GAS_USAGE).expect("gas_weight must be present"), | ||
n_steps: data.remove(constants::N_STEPS_RESOURCE).expect("n_steps must be present"), | ||
message_segment_length: data | ||
.remove(constants::MESSAGE_SEGMENT_LENGTH) | ||
.expect("message_segment_length must be present"), | ||
state_diff_size: data | ||
.remove(constants::STATE_DIFF_SIZE) | ||
.expect("state_diff_size must be present"), | ||
n_events: data.remove(constants::N_EVENTS).expect("n_events must be present"), | ||
builtin_count: BuiltinCount::from(data), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
263 changes: 0 additions & 263 deletions
263
crates/native_blockifier/src/py_transaction_execution_info.rs
This file was deleted.
Oops, something went wrong.