Skip to content

Commit

Permalink
dev(block_import_refactoring): Misc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Aug 27, 2024
1 parent 3076e2d commit 421b121
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 25 deletions.
6 changes: 4 additions & 2 deletions crates/client/block_import/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use dc_db::DeoxysStorageError;
use starknet_core::types::Felt;
use std::borrow::Cow;

use starknet_core::types::Felt;

use dc_db::DeoxysStorageError;

#[derive(Debug, thiserror::Error)]
pub enum BlockImportError {
#[error("Transaction count and receipt count do not match: {receipts} receipts != {transactions} transactions")]
Expand Down
1 change: 0 additions & 1 deletion crates/client/block_import/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ mod error;
mod verify_apply;

pub use error::*;
pub use rayon::*;
pub use verify_apply::*;

pub struct BlockImporter {
Expand Down
2 changes: 1 addition & 1 deletion crates/client/block_import/src/verify_apply.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{borrow::Cow, sync::Arc};

use dp_rayon_pool::RayonPool;
use starknet_api::core::ChainId;
use starknet_core::types::Felt;
use starknet_types_core::hash::{Poseidon, StarkHash};
Expand All @@ -12,6 +11,7 @@ use dp_block::{
UnverifiedHeader, ValidatedCommitments,
};
use dp_convert::ToFelt;
use dp_rayon_pool::RayonPool;
use dp_validation::ValidationContext;

use crate::BlockImportError;
Expand Down
7 changes: 4 additions & 3 deletions crates/client/block_import/src/verify_apply/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use bitvec::order::Msb0;
use bitvec::vec::BitVec;
use bitvec::view::AsBits;
use bonsai_trie::id::BasicId;
use dc_db::DeoxysBackend;
use dc_db::{bonsai_identifier, DeoxysStorageError};
use dp_state_update::DeclaredClassItem;
use rayon::prelude::*;
use starknet_types_core::felt::Felt;
use starknet_types_core::hash::{Poseidon, StarkHash};

use dc_db::DeoxysBackend;
use dc_db::{bonsai_identifier, DeoxysStorageError};
use dp_state_update::DeclaredClassItem;

// "CONTRACT_CLASS_LEAF_V0"
const CONTRACT_CLASS_HASH_VERSION: Felt = Felt::from_hex_unchecked("0x434f4e54524143545f434c4153535f4c4541465f5630");

Expand Down
10 changes: 6 additions & 4 deletions crates/client/block_import/src/verify_apply/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use std::collections::HashMap;

use bitvec::order::Msb0;
use bitvec::vec::BitVec;
use bitvec::view::AsBits;
use bonsai_trie::id::BasicId;
use rayon::prelude::*;
use starknet_types_core::felt::Felt;
use starknet_types_core::hash::{Pedersen, StarkHash};

use dc_db::DeoxysBackend;
use dc_db::{bonsai_identifier, DeoxysStorageError};
use dp_block::{BlockId, BlockTag};
use dp_state_update::{ContractStorageDiffItem, DeployedContractItem, NonceUpdate, ReplacedClassItem, StorageEntry};
use rayon::prelude::*;
use starknet_types_core::felt::Felt;
use starknet_types_core::hash::{Pedersen, StarkHash};
use std::collections::HashMap;

#[derive(Debug, Default)]
struct ContractLeaf {
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives/block/src/deoxys_block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use starknet_types_core::felt::Felt;

use dp_chain_config::StarknetVersion;
use dp_receipt::TransactionReceipt;
use dp_transactions::Transaction;
use starknet_types_core::felt::Felt;

use crate::header::{Header, PendingHeader};
use crate::{BlockId, BlockTag};
Expand Down
7 changes: 4 additions & 3 deletions crates/primitives/block/src/header.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use core::num::NonZeroU128;
use dp_chain_config::StarknetVersion;
use dp_transactions::MAIN_CHAIN_ID;
use dp_transactions::V0_7_BLOCK_NUMBER;
use starknet_types_core::felt::Felt;
use starknet_types_core::hash::Pedersen;
use starknet_types_core::hash::Poseidon;
use starknet_types_core::hash::StarkHash as StarkHashTrait;

use dp_chain_config::StarknetVersion;
use dp_transactions::MAIN_CHAIN_ID;
use dp_transactions::V0_7_BLOCK_NUMBER;

/// Block status.
///
/// The status of the block.
Expand Down
17 changes: 9 additions & 8 deletions crates/primitives/block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ pub mod commitments;
pub mod deoxys_block;
pub mod header;

use bitvec::vec::BitVec;
pub use commitments::*;
pub use deoxys_block::*;
pub use header::*;

use std::mem;

use bitvec::vec::BitVec;
pub use primitive_types::{H160, U256};
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
use starknet_api::core::ChainId;
use starknet_types_core::felt::Felt;

use dp_state_update::StateDiff;
use dp_transactions::Transaction;

use std::mem;
use starknet_types_core::{
felt::Felt,
hash::{Pedersen, Poseidon, StarkHash},
};

use dp_chain_config::StarknetVersion;
use dp_class::{ConvertedClass, DeclaredClass, ToConvertedClasses};
use dp_convert::ToFelt;
use dp_receipt::TransactionReceipt;
use dp_state_update::StateDiff;
use dp_transactions::Transaction;
use dp_validation::{Validate, ValidationContext};
use starknet_types_core::hash::{Pedersen, Poseidon, StarkHash};

/// Block tag.
///
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/primitives/class/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use starknet_types_core::felt::Felt;

mod class_hash;
mod compile;
mod conversion;
mod convert;
mod into_starknet_core;

pub use class_hash::ClassHash;
pub use compile::ToCompiledClass;
pub use conversion::{ToConvertedClass, ToConvertedClasses};
pub use convert::{ToConvertedClass, ToConvertedClasses};

#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct ConvertedClass {
Expand Down

0 comments on commit 421b121

Please sign in to comment.