diff --git a/crates/papyrus_network/src/db_executor/mod.rs b/crates/papyrus_network/src/db_executor/mod.rs index 109c3e4b1e..d260ba1831 100644 --- a/crates/papyrus_network/src/db_executor/mod.rs +++ b/crates/papyrus_network/src/db_executor/mod.rs @@ -6,8 +6,6 @@ use futures::channel::mpsc::Sender; use futures::future::{pending, poll_fn}; #[cfg(test)] use mockall::automock; -use papyrus_protobuf::converters::common::volition_domain_to_enum_int; -use papyrus_protobuf::converters::state_diff::DOMAIN; use papyrus_protobuf::protobuf; use papyrus_protobuf::sync::{ BlockHashOrNumber, @@ -259,96 +257,6 @@ impl FetchBlockDataFromDb for DataType { } } -// A wrapper struct for Vec so that we can implement traits for it. -pub struct StateDiffsResponseVec(pub Vec); - -impl From for StateDiffsResponseVec { - fn from(value: ThinStateDiff) -> Self { - let mut result = Vec::new(); - - for (contract_address, class_hash) in - value.deployed_contracts.into_iter().chain(value.replaced_classes.into_iter()) - { - result.push(protobuf::StateDiffsResponse { - state_diff_message: Some( - protobuf::state_diffs_response::StateDiffMessage::ContractDiff( - protobuf::ContractDiff { - address: Some(contract_address.into()), - class_hash: Some(class_hash.0.into()), - domain: volition_domain_to_enum_int(DOMAIN), - ..Default::default() - }, - ), - ), - }); - } - for (contract_address, storage_diffs) in value.storage_diffs { - if storage_diffs.is_empty() { - continue; - } - result.push(protobuf::StateDiffsResponse { - state_diff_message: Some( - protobuf::state_diffs_response::StateDiffMessage::ContractDiff( - protobuf::ContractDiff { - address: Some(contract_address.into()), - values: storage_diffs - .into_iter() - .map(|(key, value)| protobuf::ContractStoredValue { - key: Some((*key.0.key()).into()), - value: Some(value.into()), - }) - .collect(), - domain: volition_domain_to_enum_int(DOMAIN), - ..Default::default() - }, - ), - ), - }); - } - for (contract_address, nonce) in value.nonces { - result.push(protobuf::StateDiffsResponse { - state_diff_message: Some( - protobuf::state_diffs_response::StateDiffMessage::ContractDiff( - protobuf::ContractDiff { - address: Some(contract_address.into()), - nonce: Some(nonce.0.into()), - domain: volition_domain_to_enum_int(DOMAIN), - ..Default::default() - }, - ), - ), - }); - } - - for (class_hash, compiled_class_hash) in value.declared_classes { - result.push(protobuf::StateDiffsResponse { - state_diff_message: Some( - protobuf::state_diffs_response::StateDiffMessage::DeclaredClass( - protobuf::DeclaredClass { - class_hash: Some(class_hash.0.into()), - compiled_class_hash: Some(compiled_class_hash.0.into()), - }, - ), - ), - }); - } - for class_hash in value.deprecated_declared_classes { - result.push(protobuf::StateDiffsResponse { - state_diff_message: Some( - protobuf::state_diffs_response::StateDiffMessage::DeclaredClass( - protobuf::DeclaredClass { - class_hash: Some(class_hash.0.into()), - compiled_class_hash: None, - }, - ), - ), - }); - } - - Self(result) - } -} - pub fn split_thin_state_diff(thin_state_diff: ThinStateDiff) -> Vec { let mut state_diff_chunks = Vec::new(); let mut contract_addresses = std::collections::HashSet::new(); diff --git a/crates/papyrus_network/src/lib.rs b/crates/papyrus_network/src/lib.rs index 6ce5432a56..54ed83f92a 100644 --- a/crates/papyrus_network/src/lib.rs +++ b/crates/papyrus_network/src/lib.rs @@ -16,7 +16,6 @@ mod utils; use std::collections::{BTreeMap, HashMap}; use std::time::Duration; -use std::usize; use derive_more::Display; use enum_iterator::Sequence; diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 547bab56ed..7518814cba 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -376,7 +376,7 @@ pub fn get_test_block( keys: Option>>, ) -> Block { let mut rng = get_rng(); - let events_per_tx = if let Some(events_per_tx) = events_per_tx { events_per_tx } else { 0 }; + let events_per_tx = events_per_tx.unwrap_or_default(); get_rand_test_block_with_events( &mut rng, transaction_count, @@ -394,7 +394,7 @@ pub fn get_test_body( keys: Option>>, ) -> BlockBody { let mut rng = get_rng(); - let events_per_tx = if let Some(events_per_tx) = events_per_tx { events_per_tx } else { 0 }; + let events_per_tx = events_per_tx.unwrap_or_default(); get_rand_test_body_with_events(&mut rng, transaction_count, events_per_tx, from_addresses, keys) }