Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgade rust-toolchain to 1.75.0 #4356

Merged
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 @@ -45,7 +45,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- uses: actions/checkout@v3
- run: rustup component add rustfmt
- run: sudo apt-get update && sudo apt-get install libssl-dev pkg-config libclang-dev -y && sudo apt-get install -y gcc-multilib
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 @@ -52,7 +52,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- run: rustup component add rustfmt
- run: rustup component add clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev
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 @@ -57,7 +57,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- run: rustup component add rustfmt
- run: rustup component add clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- run: rustup component add rustfmt
- run: rustup component add clippy
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev
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 @@ -53,7 +53,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- uses: actions/checkout@v3
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check
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 @@ -53,7 +53,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- run: rustup component add rustfmt
- uses: actions/checkout@v3
- run: cargo fmt --all -- --check
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 @@ -53,7 +53,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.71.1
toolchain: 1.75.0
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev
- name: Install nextest
uses: taiki-e/install-action@nextest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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.71.1-openssl-3.1.3
BUILDER_IMAGE: nervos/ckb-docker-builder:bionic-rust-1.75.0
REL_PKG: ${{ matrix.rel_pkg }}

package-for-linux-aarch64:
Expand Down Expand Up @@ -163,7 +163,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.71.1-openssl-3.1.3
BUILDER_IMAGE: nervos/ckb-docker-builder:centos-7-rust-1.75.0
REL_PKG: ${{ matrix.rel_pkg }}

package-for-mac:
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.71.1"
rust-version = "1.75.0"

[build-dependencies]
ckb-build-info = { path = "util/build-info", version = "= 0.115.0-pre" }
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 @@ -175,7 +175,7 @@ fn test_block_template_message() {
.cellbase
.data
.witnesses
.get(0)
.first()
.unwrap()
.as_bytes(),
)
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb"
repository = "https://github.com/nervosnetwork/ckb"

[dependencies]
clap = { version = "4" }
clap = { version = "=4.4" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
serde_plain = "0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/list_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl TryFrom<ChainSpec> for SpecHashes {
cellbase
.outputs()
.into_iter()
.zip(cellbase.outputs_data().into_iter())
.zip(cellbase.outputs_data())
.skip(1),
)
.enumerate()
Expand Down
2 changes: 1 addition & 1 deletion docker/hub/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nervos/ckb-docker-builder:bionic-rust-1.71.1-openssl-3.1.3 as ckb-docker-builder
FROM nervos/ckb-docker-builder:bionic-rust-1.75.0 as ckb-docker-builder

WORKDIR /ckb
COPY ./ .
Expand Down
2 changes: 1 addition & 1 deletion docker/hub/Dockerfile-aarch64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nervos/ckb-docker-builder:aarch64-rust-1.71.1-openssl-3.1.3 as ckb-docker-builder
FROM nervos/ckb-docker-builder:aarch64-rust-1.75.0 as ckb-docker-builder

WORKDIR /ckb
COPY ./ .
Expand Down
33 changes: 14 additions & 19 deletions network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,25 +1124,20 @@ impl NetworkService {
}
start_sender.send(Ok(())).unwrap();
tokio::spawn(async move { p2p_service.run().await });
loop {
tokio::select! {
_ = receiver.cancelled() => {
info!("NetworkService receive exit signal, start shutdown...");
let _ = p2p_control.shutdown().await;
// Drop senders to stop all corresponding background task
drop(bg_signals);

info!("NetworkService shutdown now");
break;
},
else => {
let _ = p2p_control.shutdown().await;
// Drop senders to stop all corresponding background task
drop(bg_signals);

break;
},
}
tokio::select! {
_ = receiver.cancelled() => {
info!("NetworkService receive exit signal, start shutdown...");
let _ = p2p_control.shutdown().await;
// Drop senders to stop all corresponding background task
drop(bg_signals);

info!("NetworkService shutdown now");
},
else => {
let _ = p2p_control.shutdown().await;
// Drop senders to stop all corresponding background task
drop(bg_signals);
},
}
});
}
Expand Down
15 changes: 8 additions & 7 deletions network/src/peer_registry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Peer registry
use crate::network_group::Group;
use crate::peer_store::PeerStore;
use crate::{
errors::{Error, PeerError},
Expand Down Expand Up @@ -166,13 +167,13 @@ impl PeerRegistry {
// Group peers by network group
let evict_group = candidate_peers
.into_iter()
.fold(HashMap::new(), |mut groups, peer| {
groups
.entry(peer.network_group())
.or_insert_with(Vec::new)
.push(peer);
groups
})
.fold(
HashMap::new(),
|mut groups: HashMap<Group, Vec<&Peer>>, peer| {
groups.entry(peer.network_group()).or_default().push(peer);
groups
},
)
.values()
.max_by_key(|group| group.len())
.cloned()
Expand Down
4 changes: 2 additions & 2 deletions network/src/services/dns_seeding/seed_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ impl SeedRecord {
peer_id: Option<&PeerId>,
valid_until: u64,
) -> String {
vec![
[
ip.to_string(),
port.to_string(),
peer_id.map(PeerId::to_base58).unwrap_or_else(String::new),
peer_id.map(PeerId::to_base58).unwrap_or_default(),
valid_until.to_string(),
]
.join(&SEP.to_string())
Expand Down
2 changes: 1 addition & 1 deletion network/src/services/dns_seeding/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl SeedRecord {
sig[0..64].copy_from_slice(&signed_data[0..64]);
sig[64] = recid.to_i32() as u8;
let signature_string = bs58::encode(&sig[..]).into_string();
Ok(vec![data, signature_string].join(&SEP.to_string()))
Ok([data, signature_string].join(&SEP.to_string()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/src/tests/module/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn test_get_block_template_cache() {
let store = suite.shared.store();
let tip = store.get_tip_header().unwrap();
let tip_block = store.get_block(&tip.hash()).unwrap();
let previous_output = OutPoint::new(tip_block.transactions().get(0).unwrap().hash(), 0);
let previous_output = OutPoint::new(tip_block.transactions().first().unwrap().hash(), 0);

let input = CellInput::new(previous_output, 0);
let output = CellOutputBuilder::default()
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/tests/module/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn test_send_transaction_exceeded_maximum_ancestors_count() {
let store = suite.shared.store();
let tip = store.get_tip_header().unwrap();
let tip_block = store.get_block(&tip.hash()).unwrap();
let mut parent_tx_hash = tip_block.transactions().get(0).unwrap().hash();
let mut parent_tx_hash = tip_block.transactions().first().unwrap().hash();

// generate 30 child-spends-parent txs
for i in 0..130 {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.71.1
1.75.0
2 changes: 1 addition & 1 deletion spec/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ impl Consensus {
genesis_cellbase
.outputs()
.into_iter()
.zip(genesis_cellbase.outputs_data().into_iter())
.zip(genesis_cellbase.outputs_data())
.find(|(_, data)| data.raw_data() == secp_cell_data.as_ref())
.and_then(|(output, _)| {
output
Expand Down
2 changes: 1 addition & 1 deletion store/src/tests/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn freeze_blockv1_with_extension() {
let freezer = Freezer::open_in(&tmp_dir2).expect("tmp freezer");
let store = ChainDB::new_with_freezer(db, freezer.clone(), Default::default());

let extension: packed::Bytes = vec![1u8; 96].pack();
let extension: packed::Bytes = [1u8; 96].pack();
let raw = packed::RawHeader::new_builder().number(1u64.pack()).build();
let block = packed::BlockV1::new_builder()
.header(packed::Header::new_builder().raw(raw).build())
Expand Down
2 changes: 2 additions & 0 deletions sync/src/block_status.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::bad_bit_mask)]

use bitflags::bitflags;

bitflags! {
Expand Down
2 changes: 1 addition & 1 deletion sync/src/orphan_block_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl InnerPool {
let parent_hash = block.data().header().raw().parent_hash();
self.blocks
.entry(parent_hash.clone())
.or_insert_with(HashMap::default)
.or_default()
.insert(hash.clone(), block);
// Out-of-order insertion needs to be deduplicated
self.leaders.remove(&hash);
Expand Down
2 changes: 1 addition & 1 deletion sync/src/relayer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl Relayer {
if let Err(e) = fetch_txs {
return ReconstructionResult::Error(StatusCode::TxPool.with_context(e));
}
txs_map.extend(fetch_txs.unwrap().into_iter());
txs_map.extend(fetch_txs.unwrap());
}

let txs_len = compact_block.txs_len();
Expand Down
4 changes: 2 additions & 2 deletions sync/src/relayer/tests/block_transactions_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn test_collision_and_send_missing_indexes() {

let content = packed::GetBlockTransactions::new_builder()
.block_hash(block.header().hash())
.indexes(vec![1u32, 2u32].pack())
.indexes([1u32, 2u32].pack())
.build();
let message = packed::RelayMessage::new_builder().set(content).build();
let data = message.as_bytes();
Expand Down Expand Up @@ -427,7 +427,7 @@ fn test_missing() {

let content = packed::GetBlockTransactions::new_builder()
.block_hash(block.header().hash())
.indexes(vec![1, 2u32].pack())
.indexes([1, 2u32].pack())
.build();
let message = packed::RelayMessage::new_builder().set(content).build();

Expand Down
2 changes: 1 addition & 1 deletion sync/src/tests/orphan_block_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn test_leaders() {

let orphan_1 = pool.remove_blocks_by_parent(&blocks[14].hash());

let orphan_set: HashSet<BlockView> = orphan.into_iter().chain(orphan_1.into_iter()).collect();
let orphan_set: HashSet<BlockView> = orphan.into_iter().chain(orphan_1).collect();
let blocks_set: HashSet<BlockView> = blocks.into_iter().collect();
assert_eq!(orphan_set, blocks_set);
assert_eq!(pool.len(), 0);
Expand Down
11 changes: 4 additions & 7 deletions sync/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,7 @@ impl InflightBlocks {
.insert(block.clone(), unix_time_as_millis());
}

let download_scheduler = self
.download_schedulers
.entry(peer)
.or_insert_with(DownloadScheduler::default);
let download_scheduler = self.download_schedulers.entry(peer).or_default();
download_scheduler.hashes.insert(block)
}

Expand Down Expand Up @@ -1632,13 +1629,13 @@ impl UnknownTxHashPriority {
if self.peers.len() > 1 {
self.request_time = Instant::now();
self.peers.swap_remove(0);
self.peers.get(0).cloned()
self.peers.first().cloned()
} else {
None
}
} else {
self.requested = true;
self.peers.get(0).cloned()
self.peers.first().cloned()
}
}

Expand All @@ -1648,7 +1645,7 @@ impl UnknownTxHashPriority {

pub fn requesting_peer(&self) -> Option<PeerIndex> {
if self.requested {
self.peers.get(0).cloned()
self.peers.first().cloned()
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/relay/get_block_transactions_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Spec for MissingUncleRequest {

let content = packed::GetBlockTransactions::new_builder()
.block_hash(block.hash())
.uncle_indexes(vec![0u32].pack())
.uncle_indexes([0u32].pack())
.build();
let message = packed::RelayMessage::new_builder().set(content).build();

Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/sync/block_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Spec for GetBlockFilterHashes {
node.get_block_filter(header.hash()).data.into();
let parent_block_filter = node.get_block_filter(header.parent_hash());
let expected_parent_hash = blake2b_256(
&[
[
parent_block_filter.hash.0.as_slice(),
block_filter.calc_raw_data_hash().as_slice(),
]
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/tx_pool/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ impl Spec for RbfConcurrency {

let mut conflicts = vec![tx1];
// tx1 capacity is 100, set other txs to higer fee
let fees = vec![
let fees = [
capacity_bytes!(83),
capacity_bytes!(82),
capacity_bytes!(81),
Expand Down
2 changes: 1 addition & 1 deletion tx-pool/src/block_assembler/candidate_uncles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl CandidateUncles {
}
}

let set = self.map.entry(number).or_insert_with(HashSet::new);
let set = self.map.entry(number).or_default();
if set.len() < MAX_PER_HEIGHT {
let ret = set.insert(uncle);
if ret {
Expand Down
2 changes: 1 addition & 1 deletion tx-pool/src/component/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl OrphanPool {
for out_point in tx.input_pts_iter() {
self.by_out_point
.entry(out_point)
.or_insert_with(HashSet::default)
.or_default()
.insert(tx.proposal_short_id());
}

Expand Down
2 changes: 1 addition & 1 deletion util/app-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb"
repository = "https://github.com/nervosnetwork/ckb"

[dependencies]
clap = { version = "4", features = ["string", "wrap_help"] }
clap = { version = "=4.4", features = ["string", "wrap_help"] }
serde = { version = "1.0", features = ["derive"] }
serde_plain = "0.3.0"
serde_json = "1.0"
Expand Down
Loading
Loading