Skip to content

Commit

Permalink
chore: update clippy errors for 06.16.2024 (#2110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahakShama authored Jun 16, 2024
1 parent 14ee3bb commit a3d53c4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 95 deletions.
92 changes: 0 additions & 92 deletions crates/papyrus_network/src/db_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -259,96 +257,6 @@ impl FetchBlockDataFromDb for DataType {
}
}

// A wrapper struct for Vec<StateDiffsResponse> so that we can implement traits for it.
pub struct StateDiffsResponseVec(pub Vec<protobuf::StateDiffsResponse>);

impl From<ThinStateDiff> 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<StateDiffChunk> {
let mut state_diff_chunks = Vec::new();
let mut contract_addresses = std::collections::HashSet::new();
Expand Down
1 change: 0 additions & 1 deletion crates/papyrus_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub fn get_test_block(
keys: Option<Vec<Vec<EventKey>>>,
) -> 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,
Expand All @@ -394,7 +394,7 @@ pub fn get_test_body(
keys: Option<Vec<Vec<EventKey>>>,
) -> 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)
}

Expand Down

0 comments on commit a3d53c4

Please sign in to comment.