Skip to content

Commit

Permalink
rustfmt: execute cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Mar 1, 2025
1 parent 9d43636 commit ca1bbe6
Show file tree
Hide file tree
Showing 320 changed files with 1,387 additions and 1,170 deletions.
32 changes: 19 additions & 13 deletions benches/benches/benchmarks/always_success.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::benchmarks::util::{gen_always_success_block, new_always_success_chain};
use ckb_store::{self, ChainStore};
use ckb_verification_traits::Switch;
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion};
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group};
use std::sync::Arc;

#[cfg(not(feature = "ci"))]
Expand All @@ -24,10 +24,12 @@ fn bench(c: &mut Criterion) {
let chains = new_always_success_chain(*i, 2);
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..20).for_each(|_| {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
Expand Down Expand Up @@ -72,10 +74,12 @@ fn bench(c: &mut Criterion) {
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let (ref chain3, ref shared3) = chains.0[2];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..5).for_each(|i| {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
Expand Down Expand Up @@ -149,10 +153,12 @@ fn bench(c: &mut Criterion) {
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let (ref chain3, ref shared3) = chains.0[2];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..5).for_each(|i| {
let block = gen_always_success_block(&mut blocks, &parent, shared2);
Expand Down
12 changes: 6 additions & 6 deletions benches/benches/benchmarks/overall.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
use crate::benchmarks::util::{create_2out_transaction, create_secp_tx, secp_cell};
use ckb_app_config::NetworkConfig;
use ckb_app_config::{BlockAssemblerConfig, TxPoolConfig};
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain::{ChainController, start_chain_services};
use ckb_chain_spec::consensus::{ConsensusBuilder, ProposalWindow};
use ckb_dao_utils::genesis_dao_data;
use ckb_jsonrpc_types::JsonBytes;
use ckb_network::{network::TransportType, Flags, NetworkController, NetworkService, NetworkState};
use ckb_network::{Flags, NetworkController, NetworkService, NetworkState, network::TransportType};
use ckb_shared::{Shared, SharedBuilder};
use ckb_store::ChainStore;
use ckb_types::{
U256,
bytes::Bytes,
core::{
capacity_bytes, BlockBuilder, BlockView, Capacity, EpochNumberWithFraction, FeeRate,
ScriptHashType, TransactionBuilder, TransactionView,
BlockBuilder, BlockView, Capacity, EpochNumberWithFraction, FeeRate, ScriptHashType,
TransactionBuilder, TransactionView, capacity_bytes,
},
packed::{Block, CellDep, CellInput, CellOutput, Header, OutPoint},
prelude::*,
utilities::difficulty_to_compact,
U256,
};
use ckb_verification::HeaderVerifier;
use ckb_verification_traits::Switch;
use ckb_verification_traits::Verifier;
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion};
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group};
use rand::random;
use std::sync::Arc;

Expand Down
9 changes: 4 additions & 5 deletions benches/benches/benchmarks/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
use crate::benchmarks::util::create_2out_transaction;
use ckb_app_config::{BlockAssemblerConfig, TxPoolConfig};
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain::{ChainController, start_chain_services};
use ckb_chain_spec::{ChainSpec, IssuedCell};
use ckb_jsonrpc_types::JsonBytes;
use ckb_resource::Resource;
use ckb_shared::{Shared, SharedBuilder, Snapshot};
use ckb_types::global::DATA_DIR;
use ckb_types::{
H160, H256,
bytes::Bytes,
core::{
capacity_bytes,
BlockView, Capacity, DepType, FeeRate, ScriptHashType, TransactionView, capacity_bytes,
cell::{resolve_transaction, setup_system_cell_cache},
BlockView, Capacity, DepType, FeeRate, ScriptHashType, TransactionView,
},
h160, h256,
packed::{CellDep, OutPoint, Script},
prelude::*,
H160, H256,
};
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion};
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group};
use std::collections::HashSet;

#[cfg(not(feature = "ci"))]
Expand Down
32 changes: 19 additions & 13 deletions benches/benches/benchmarks/secp_2in2out.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::benchmarks::util::{gen_secp_block, new_secp_chain};
use ckb_store::{self, ChainStore};
use ckb_verification_traits::Switch;
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion};
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group};
use std::sync::Arc;

#[cfg(not(feature = "ci"))]
Expand All @@ -24,10 +24,12 @@ fn bench(c: &mut Criterion) {
let chains = new_secp_chain(*txs_size, 2);
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..20).for_each(|_| {
let block = gen_secp_block(&mut blocks, &parent, shared2);
Expand Down Expand Up @@ -72,10 +74,12 @@ fn bench(c: &mut Criterion) {
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let (ref chain3, ref shared3) = chains.0[2];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..5).for_each(|i| {
let block = gen_secp_block(&mut blocks, &parent, shared2);
Expand Down Expand Up @@ -149,10 +153,12 @@ fn bench(c: &mut Criterion) {
let (ref chain1, ref shared1) = chains.0[0];
let (ref chain2, ref shared2) = chains.0[1];
let (ref chain3, ref shared3) = chains.0[2];
let mut blocks = vec![shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap()];
let mut blocks = vec![
shared1
.snapshot()
.get_block(&shared1.genesis_hash())
.unwrap(),
];
let mut parent = blocks[0].clone();
(0..5).for_each(|i| {
let block = gen_secp_block(&mut blocks, &parent, shared2);
Expand Down
9 changes: 4 additions & 5 deletions benches/benches/benchmarks/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain::{ChainController, start_chain_services};
use ckb_chain_spec::consensus::{ConsensusBuilder, ProposalWindow};
use ckb_crypto::secp::Privkey;
use ckb_dao::DaoCalculator;
Expand All @@ -8,20 +8,19 @@ use ckb_store::ChainStore;
use ckb_system_scripts::BUNDLED_CELL;
use ckb_test_chain_utils::always_success_cell;
use ckb_types::{
H160, H256, U256,
bytes::Bytes,
core::{
capacity_bytes,
cell::{resolve_transaction, OverlayCellProvider, TransactionsProvider},
BlockBuilder, BlockView, Capacity, EpochNumberWithFraction, HeaderView, ScriptHashType,
TransactionBuilder, TransactionView,
TransactionBuilder, TransactionView, capacity_bytes,
cell::{OverlayCellProvider, TransactionsProvider, resolve_transaction},
},
h160, h256,
packed::{
Byte32, CellDep, CellInput, CellOutput, OutPoint, ProposalShortId, Script, WitnessArgs,
},
prelude::*,
utilities::difficulty_to_compact,
H160, H256, U256,
};
use rand::random;
use std::collections::HashSet;
Expand Down
12 changes: 9 additions & 3 deletions block-filter/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use ckb_async_runtime::tokio::{self, task::block_in_place};
use ckb_logger::{debug, info, warn};
use ckb_shared::Shared;
use ckb_stop_handler::{new_tokio_exit_rx, CancellationToken};
use ckb_stop_handler::{CancellationToken, new_tokio_exit_rx};
use ckb_store::{ChainDB, ChainStore};
use ckb_types::{
core::HeaderView,
packed::{Byte32, CellOutput, OutPoint},
prelude::*,
utilities::{build_filter_data, FilterDataProvider},
utilities::{FilterDataProvider, build_filter_data},
};

const NAME: &str = "BlockFilter";
Expand Down Expand Up @@ -163,6 +163,12 @@ impl BlockFilter {
)
.expect("insert_block_filter should be ok");
db_transaction.commit().expect("commit should be ok");
debug!("Inserted filter data for block: {}, hash: {:#x}, filter data size: {}, transactions size: {}", header.number(), header.hash(), filter_data.len(), transactions_size);
debug!(
"Inserted filter data for block: {}, hash: {:#x}, filter data size: {}, transactions size: {}",
header.number(),
header.hash(),
filter_data.len(),
transactions_size
);
}
}
4 changes: 2 additions & 2 deletions chain/src/chain_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use ckb_error::{Error, InternalErrorKind};
use ckb_logger::{self, error};
use ckb_store::ChainDB;
use ckb_types::{
core::{service::Request, BlockView},
core::{BlockView, service::Request},
packed::Byte32,
};
use ckb_verification_traits::Switch;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;

/// Controller to the chain service.
///
Expand Down
4 changes: 2 additions & 2 deletions chain/src/chain_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

use crate::orphan_broker::OrphanBroker;
use crate::{LonelyBlock, ProcessBlockRequest};
use ckb_channel::{select, Receiver};
use ckb_channel::{Receiver, select};
use ckb_error::{Error, InternalErrorKind};
use ckb_logger::{self, debug, error, info, warn};
use ckb_shared::block_status::BlockStatus;
use ckb_shared::shared::Shared;
use ckb_stop_handler::new_crossbeam_exit_rx;
use ckb_types::core::{service::Request, BlockView};
use ckb_types::core::{BlockView, service::Request};
use ckb_verification::{BlockVerifier, NonContextualBlockTxsVerifier};
use ckb_verification_traits::Verifier;

Expand Down
4 changes: 2 additions & 2 deletions chain/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use crate::orphan_broker::OrphanBroker;
use crate::preload_unverified_blocks_channel::PreloadUnverifiedBlocksChannel;
use crate::utils::orphan_block_pool::OrphanBlockPool;
use crate::verify::ConsumeUnverifiedBlocks;
use crate::{chain_controller::ChainController, LonelyBlockHash, UnverifiedBlock};
use crate::{LonelyBlockHash, UnverifiedBlock, chain_controller::ChainController};
use ckb_channel::{self as channel, SendError};
use ckb_constant::sync::BLOCK_DOWNLOAD_WINDOW;
use ckb_logger::warn;
use ckb_shared::ChainServicesBuilder;
use ckb_stop_handler::register_thread;
use ckb_types::packed::Byte32;
use dashmap::DashSet;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::thread;

const ORPHAN_BLOCK_SIZE: usize = BLOCK_DOWNLOAD_WINDOW as usize;
Expand Down
2 changes: 1 addition & 1 deletion chain/src/init_load_unverified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use ckb_types::core::{BlockNumber, BlockView};
use ckb_types::packed;
use ckb_types::prelude::{Entity, FromSliceShouldBeOk, Pack, Reader};
use std::cmp;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;

pub(crate) struct InitLoadUnverified {
shared: Shared,
Expand Down
16 changes: 5 additions & 11 deletions chain/src/orphan_broker.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#![allow(missing_docs)]

use crate::utils::orphan_block_pool::{OrphanBlockPool, ParentHash};
use crate::{delete_unverified_block, LonelyBlockHash, VerifyResult};
use crate::{LonelyBlockHash, VerifyResult, delete_unverified_block};
use ckb_channel::Sender;
use ckb_error::InternalErrorKind;
use ckb_logger::internal::trace;
use ckb_logger::{debug, error, info};
use ckb_shared::block_status::BlockStatus;
use ckb_shared::Shared;
use ckb_shared::block_status::BlockStatus;
use ckb_store::ChainStore;
use ckb_types::{packed::Byte32, U256};
use ckb_types::{U256, packed::Byte32};
use dashmap::DashSet;
use std::sync::Arc;

Expand Down Expand Up @@ -53,9 +53,7 @@ impl OrphanBroker {
if !leader_is_pending_verify && !leader_status.contains(BlockStatus::BLOCK_STORED) {
trace!(
"orphan leader: {} not stored {:?} and not in is_pending_verify: {}",
leader_hash,
leader_status,
leader_is_pending_verify
leader_hash, leader_status, leader_is_pending_verify
);
return;
}
Expand Down Expand Up @@ -115,11 +113,7 @@ impl OrphanBroker {
if parent_is_pending_verify || parent_status.contains(BlockStatus::BLOCK_STORED) {
debug!(
"parent {} has stored: {:?} or is_pending_verify: {}, processing descendant directly {}-{}",
parent_hash,
parent_status,
parent_is_pending_verify,
block_number,
block_hash,
parent_hash, parent_status, parent_is_pending_verify, block_number, block_hash,
);
self.process_descendant(lonely_block);
} else if parent_status.eq(&BlockStatus::BLOCK_INVALID) {
Expand Down
Loading

0 comments on commit ca1bbe6

Please sign in to comment.