Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_aarch64_build_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
ci-aarch64-cargo-
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev build-essential
- name: Build for aarch64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_benchmarks_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
sudo docker image prune --all --force
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt, clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev build-essential
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_integration_tests_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
sudo docker image prune --all --force
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt, clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev build-essential tor
- uses: actions/setup-go@v6
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
sudo docker image prune --all --force
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt, clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev build-essential procps wget
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_linters_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt, clippy
- uses: actions/setup-go@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_quick_checks_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
sudo docker image prune --all --force
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt, clippy
- uses: actions/setup-go@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_unit_tests_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
sudo docker image prune --all --force
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev build-essential
- name: Install nextest
uses: taiki-e/install-action@nextest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85.0
toolchain: 1.92.0
components: rustfmt,llvm-tools-preview
- run: sudo apt-get update && sudo apt-get install libssl-dev pkg-config libclang-dev -y && sudo apt-get install -y gcc-multilib build-essential
- name: unit coverage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
name: ckb_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc
path: ckb_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc
env:
BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.85.0
BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.92.0
REL_PKG: ${{ matrix.rel_pkg }}
CKB_CLI_VERSION: ${{ needs.get-ckb-cli-version.outputs.version }}

Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
name: ckb_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc
path: ckb_${{env.GIT_TAG_NAME }}_${{env.REL_PKG }}.asc
env:
BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.85.0
BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.92.0
REL_PKG: ${{ matrix.rel_pkg }}
CKB_CLI_VERSION: ${{ needs.get-ckb-cli-version.outputs.version }}

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
description = "CKB is the layer 1 of Nervos Network, a public/permissionless blockchain"
homepage = "https://github.com/nervosnetwork/ckb"
repository = "https://github.com/nervosnetwork/ckb"
rust-version = "1.85.0"
rust-version = "1.92.0"
default-run = "ckb"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion chain/src/chain_controller.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! CKB chain controller.
#![allow(missing_docs)]
#![allow(elided_named_lifetimes)]
#![allow(mismatched_lifetime_syntaxes)]

use crate::utils::orphan_block_pool::OrphanBlockPool;
use crate::{LonelyBlock, ProcessBlockRequest, RemoteBlock, TruncateRequest, VerifyResult};
Expand Down
4 changes: 2 additions & 2 deletions chain/src/init_load_unverified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl InitLoadUnverified {
.map(|(key_number_hash, _v)| {
let reader =
packed::NumberHashReader::from_slice_should_be_ok(key_number_hash.as_ref());
let unverified_block_hash = reader.block_hash().to_entity();
unverified_block_hash

reader.block_hash().to_entity()
})
.filter(|hash| self.shared.store().get_block_ext(hash).is_none())
.collect::<Vec<packed::Byte32>>();
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ fn test_chain_fork_by_first_received() {
chain3.gen_empty_block_with_diff(20u64, &mock_store);
}

for chain in vec![chain1.clone(), chain2.clone(), chain3.clone()] {
for chain in [chain1.clone(), chain2.clone(), chain3.clone()] {
for block in chain.blocks() {
chain_controller
.blocking_process_block_with_switch(Arc::new(block.clone()), Switch::DISABLE_ALL)
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/block_assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ fn test_candidate_uncles_retain() {

let block1_0 = gen_block(&block0_0.header(), 12, &epoch);
let block2_0 = gen_block(&block1_0.header(), 13, &epoch);
for block in vec![block1_0, block2_0.clone()] {
for block in [block1_0, block2_0.clone()] {
chain_controller
.blocking_process_block_with_switch(Arc::new(block), Switch::DISABLE_ALL)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/delay_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn test_full_dead_transaction() {
let dao = dao_data(
shared.consensus(),
&parent,
&[cellbase_tx.clone()],
std::slice::from_ref(&cellbase_tx),
&mock_store,
false,
);
Expand Down
16 changes: 8 additions & 8 deletions chain/src/tests/load_code_with_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ fn test_load_code_with_snapshot() {
let mut counter = 0;
loop {
let tx_status = tx_pool.get_tx_status(tx.hash());
if let Ok(Ok((status, _))) = tx_status {
if status == TxStatus::Pending {
break;
}
if let Ok(Ok((status, _))) = tx_status
&& status == TxStatus::Pending
{
break;
}
// wait tx_pool if got `None`
counter += 1;
Expand Down Expand Up @@ -273,10 +273,10 @@ fn _test_load_code_with_snapshot_after_hardfork(script_type: ScriptHashType) {
let mut counter = 0;
loop {
let tx_status = tx_pool.get_tx_status(tx.hash());
if let Ok(Ok((status, _))) = tx_status {
if status == TxStatus::Pending {
break;
}
if let Ok(Ok((status, _))) = tx_status
&& status == TxStatus::Pending
{
break;
}
// wait tx_pool if got `None`
counter += 1;
Expand Down
32 changes: 16 additions & 16 deletions chain/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,22 @@ impl ConsumeUnverifiedBlockProcessor {
)),
)?;

if let Some(ext) = self.shared.store().get_block_ext(&block.hash()) {
if let Some(verified) = ext.verified {
debug!(
"block {}-{} has been verified, previously verified result: {}",
block.number(),
block.hash(),
verified
);
return if verified {
Ok(false)
} else {
Err(InternalErrorKind::Other
.other("block previously verified failed")
.into())
};
}
if let Some(ext) = self.shared.store().get_block_ext(&block.hash())
&& let Some(verified) = ext.verified
{
debug!(
"block {}-{} has been verified, previously verified result: {}",
block.number(),
block.hash(),
verified
);
return if verified {
Ok(false)
} else {
Err(InternalErrorKind::Other
.other("block previously verified failed")
.into())
};
}

let cannon_total_difficulty =
Expand Down
54 changes: 26 additions & 28 deletions ckb-bin/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,19 @@ H256::from_str(&target[2..]).expect("default assume_valid_target for testnet mus
};
}

if let Some(ref assume_valid_targets) = config.network.sync.assume_valid_targets {
if let Some(first_target) = assume_valid_targets.first() {
if assume_valid_targets.len() == 1 {
if first_target
== &H256::from_slice(&[0; 32]).expect("must parse Zero h256 successful")
{
info!("Disable assume valid targets since assume_valid_targets is zero");
config.network.sync.assume_valid_targets = None;
} else {
info!(
"assume_valid_targets set to {:?}",
config.network.sync.assume_valid_targets
);
}
}
if let Some(ref assume_valid_targets) = config.network.sync.assume_valid_targets
&& let Some(first_target) = assume_valid_targets.first()
&& assume_valid_targets.len() == 1
{
if first_target == &H256::from_slice(&[0; 32]).expect("must parse Zero h256 successful")
{
info!("Disable assume valid targets since assume_valid_targets is zero");
config.network.sync.assume_valid_targets = None;
} else {
info!(
"assume_valid_targets set to {:?}",
config.network.sync.assume_valid_targets
);
}
}

Expand Down Expand Up @@ -418,13 +416,13 @@ H256::from_str(&target[2..]).expect("default assume_valid_target for testnet mus
#[cfg(feature = "with_sentry")]
fn chain_spec(&self) -> Result<ChainSpec, ExitCode> {
let result = self.config.chain_spec();
if let Ok(spec) = &result {
if self.is_sentry_enabled {
sentry::configure_scope(|scope| {
scope.set_tag("spec.name", &spec.name);
scope.set_tag("spec.pow", &spec.pow);
});
}
if let Ok(spec) = &result
&& self.is_sentry_enabled
{
sentry::configure_scope(|scope| {
scope.set_tag("spec.name", &spec.name);
scope.set_tag("spec.pow", &spec.pow);
});
}

result
Expand All @@ -440,12 +438,12 @@ H256::from_str(&target[2..]).expect("default assume_valid_target for testnet mus
pub fn consensus(&self) -> Result<Consensus, ExitCode> {
let result = consensus_from_spec(&self.chain_spec()?);

if let Ok(consensus) = &result {
if self.is_sentry_enabled {
sentry::configure_scope(|scope| {
scope.set_tag("genesis", consensus.genesis_hash());
});
}
if let Ok(consensus) = &result
&& self.is_sentry_enabled
{
sentry::configure_scope(|scope| {
scope.set_tag("genesis", consensus.genesis_hash());
});
}

result
Expand Down
8 changes: 4 additions & 4 deletions ckb-bin/src/subcommand/reset_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
target_files.push(args.network_secret_key_path);
}

if args.logs {
if let Some(dir) = args.logs_dir {
target_dirs.push(dir);
}
if args.logs
&& let Some(dir) = args.logs_dir
{
target_dirs.push(dir);
}

if !args.force && (!target_dirs.is_empty() || !target_files.is_empty()) {
Expand Down
52 changes: 25 additions & 27 deletions db-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ impl Migrations {
};
debug!("Current database version [{}]", db_version);

let migrations = self
let mut migrations = self
.migrations
.values()
.filter(|m| include_background || !m.run_in_background());

let latest_version = migrations
.last()
.next_back()
.unwrap_or_else(|| panic!("should have at least one version"))
.version();
debug!("Latest database version [{}]", latest_version);
Expand Down Expand Up @@ -201,19 +201,19 @@ impl Migrations {
}

fn is_non_empty_rdb(&self, db: &ReadOnlyDB) -> bool {
if let Ok(v) = db.get_pinned(COLUMN_META, META_TIP_HEADER_KEY) {
if v.is_some() {
return true;
}
if let Ok(v) = db.get_pinned(COLUMN_META, META_TIP_HEADER_KEY)
&& v.is_some()
{
return true;
}
false
}

fn is_non_empty_db(&self, db: &RocksDB) -> bool {
if let Ok(v) = db.get_pinned(COLUMN_META, META_TIP_HEADER_KEY) {
if v.is_some() {
return true;
}
if let Ok(v) = db.get_pinned(COLUMN_META, META_TIP_HEADER_KEY)
&& v.is_some()
{
return true;
}
false
}
Expand Down Expand Up @@ -288,14 +288,12 @@ impl Migrations {
/// Initial db version
pub fn init_db_version(&self, db: &RocksDB) -> Result<(), Error> {
let db_version = self.get_migration_version(db)?;
if db_version.is_none() {
if let Some(m) = self.migrations.values().last() {
info!("Init database version {}", m.version());
db.put_default(MIGRATION_VERSION_KEY, m.version())
.map_err(|err| {
internal_error(format!("failed to migrate the database: {err}"))
})?;
}
if db_version.is_none()
&& let Some(m) = self.migrations.values().last()
{
info!("Init database version {}", m.version());
db.put_default(MIGRATION_VERSION_KEY, m.version())
.map_err(|err| internal_error(format!("failed to migrate the database: {err}")))?;
}
Ok(())
}
Expand Down Expand Up @@ -334,17 +332,17 @@ impl Migrations {
}

fn check_migration_downgrade(&self, cur_version: &str) -> Result<(), Error> {
if let Some(m) = self.migrations.values().last() {
if m.version() < cur_version {
error!(
"Database downgrade detected. \
if let Some(m) = self.migrations.values().last()
&& m.version() < cur_version
{
error!(
"Database downgrade detected. \
The database schema version is newer than `ckb` schema version,\
please upgrade `ckb` to the latest version"
);
return Err(internal_error(
"Database downgrade is not supported".to_string(),
));
}
);
return Err(internal_error(
"Database downgrade is not supported".to_string(),
));
}
Ok(())
}
Expand Down
Loading
Loading