Skip to content

Commit

Permalink
chore: bump rust toolchain from 1.41.0 to 1.45.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape committed Aug 7, 2020
1 parent d96b93c commit 33a759e
Show file tree
Hide file tree
Showing 42 changed files with 78 additions and 78 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: rust
rust: 1.41.0
rust: 1.45.2
dist: xenial
sudo: true
cache:
Expand Down Expand Up @@ -91,8 +91,11 @@ matrix:
- rustup component add rustfmt --toolchain stable-x86_64-unknown-linux-gnu
- rustup component add clippy --toolchain stable-x86_64-unknown-linux-gnu
script:
- cargo +stable fmt --all -- --check
- cargo +stable clippy --all --all-targets --all-features -- ${CLIPPY_OPTS}
- mv rust-toolchain rust-toolchain.bak
- echo "stable" > rust-toolchain
- make fmt
- make clippy
- mv rust-toolchain.bak rust-toolchain
- name: Quick Check
if: 'tag IS NOT present AND (type = pull_request OR branch in (master, staging, staging2, trying) OR repo != nervosnetwork/ckb)'
os: linux
Expand Down Expand Up @@ -154,7 +157,7 @@ matrix:
if: 'tag IS present AND env(GITHUB_TOKEN) IS present'
language: ruby
addons: { apt: { packages: [] } }
env: REL_PKG=x86_64-unknown-linux-gnu.tar.gz BUILDER_IMAGE=nervos/ckb-docker-builder:xenial-rust-1.41.0
env: REL_PKG=x86_64-unknown-linux-gnu.tar.gz BUILDER_IMAGE=nervos/ckb-docker-builder:xenial-rust-1.45.2
script:
- mkdir -p $HOME/.cargo
- docker run --rm -it -w /ckb -v $(pwd):/ckb -v $HOME/.cargo:/root/.cargo -e OPENSSL_STATIC=1 -e OPENSSL_LIB_DIR=/usr/local/lib -e OPENSSL_INCLUDE_DIR=/usr/local/include/openssl $BUILDER_IMAGE make prod
Expand All @@ -165,7 +168,7 @@ matrix:
if: 'tag IS present AND env(GITHUB_TOKEN) IS present'
language: ruby
addons: { apt: { packages: [] } }
env: REL_PKG=x86_64-unknown-centos-gnu.tar.gz BUILDER_IMAGE=nervos/ckb-docker-builder:centos-7-rust-1.41.0
env: REL_PKG=x86_64-unknown-centos-gnu.tar.gz BUILDER_IMAGE=nervos/ckb-docker-builder:centos-7-rust-1.45.2
script:
- mkdir -p $HOME/.cargo
- docker run --rm -it -w /ckb -v $(pwd):/ckb -v $HOME/.cargo:/root/.cargo $BUILDER_IMAGE scl enable llvm-toolset-7 'make prod'
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ SHELL = /bin/sh
MOLC := moleculec
MOLC_VERSION := 0.6.0
VERBOSE := $(if ${CI},--verbose,)
CLIPPY_OPTS := -D warnings -D clippy::clone_on_ref_ptr -D clippy::enum_glob_use -D clippy::fallible_impl_from
CLIPPY_OPTS := -D warnings -D clippy::clone_on_ref_ptr -D clippy::enum_glob_use -D clippy::fallible_impl_from \
-A clippy::mutable_key_type
CKB_TEST_ARGS := -c 4
INTEGRATION_RUST_LOG := ckb-network=error

Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- template: devtools/azure/windows-dependencies.yml
parameters:
rustup_toolchain: '1.41.0-x86_64-pc-windows-msvc'
rustup_toolchain: '1.45.2-x86_64-pc-windows-msvc'
- pwsh: devtools/windows/make test
displayName: Run unit tests
env:
Expand All @@ -49,7 +49,7 @@ jobs:
steps:
- template: devtools/azure/windows-dependencies.yml
parameters:
rustup_toolchain: '1.41.0-x86_64-pc-windows-msvc'
rustup_toolchain: '1.45.2-x86_64-pc-windows-msvc'
- pwsh: devtools/windows/make CKB_TEST_SEC_COEFFICIENT=5 CKB_TEST_ARGS="--max-time 1200 -c 4" integration
displayName: Run integration tests
env:
Expand All @@ -63,7 +63,7 @@ jobs:
steps:
- template: devtools/azure/windows-dependencies.yml
parameters:
rustup_toolchain: '1.41.0-x86_64-pc-windows-msvc'
rustup_toolchain: '1.45.2-x86_64-pc-windows-msvc'
- pwsh: devtools/windows/make prod
displayName: Build
- script: |
Expand Down
1 change: 0 additions & 1 deletion ckb-bin/src/subcommand/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use ckb_instrument::{ProgressBar, ProgressStyle};
use ckb_shared::shared::{Shared, SharedBuilder};
use ckb_store::ChainStore;
use std::sync::Arc;
use tempfile;

pub fn replay(args: ReplayArgs) -> Result<(), ExitCode> {
let (shared, _table) = SharedBuilder::with_db_config(&args.config.db)
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.41.0 as ckb-docker-builder
FROM nervos/ckb-docker-builder:bionic-rust-1.45.2 as ckb-docker-builder

WORKDIR /ckb
COPY ./ .
Expand Down
2 changes: 1 addition & 1 deletion network/src/protocols/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn wait_connect_state(node: &Node, expect_num: usize) {
}
}

#[allow(clippy::block_in_if_condition_stmt)]
#[allow(clippy::blocks_in_if_conditions)]
fn wait_discovery(node: &Node) {
if !wait_until(100, || {
node.network_state
Expand Down
15 changes: 9 additions & 6 deletions rpc/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ckb_error::{Error as CKBError, InternalError, InternalErrorKind};
use ckb_error::{Error as CKBError, ErrorKind, InternalError, InternalErrorKind};
use ckb_tx_pool::error::Reject;
use jsonrpc_core::{Error, ErrorCode, Value};
use std::fmt::{Debug, Display};
Expand Down Expand Up @@ -95,15 +95,18 @@ impl RPCError {
}

pub fn from_ckb_error(err: CKBError) -> Error {
use ckb_error::ErrorKind::*;
match err.kind() {
Dao => Self::custom_with_error(RPCError::DaoError, err.unwrap_cause_or_self()),
OutPoint => Self::custom_with_error(RPCError::TransactionFailedToResolve, err),
Transaction => Self::custom_with_error(
ErrorKind::Dao => {
Self::custom_with_error(RPCError::DaoError, err.unwrap_cause_or_self())
}
ErrorKind::OutPoint => {
Self::custom_with_error(RPCError::TransactionFailedToResolve, err)
}
ErrorKind::Transaction => Self::custom_with_error(
RPCError::TransactionFailedToVerify,
err.unwrap_cause_or_self(),
),
Internal => {
ErrorKind::Internal => {
let internal_err = match err.downcast_ref::<InternalError>() {
Some(err) => err,
None => return Self::ckb_internal_error(err),
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.41.0
1.45.2
5 changes: 3 additions & 2 deletions sync/src/relayer/block_transactions_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ impl<'a> BlockTransactionsProcess<'a> {
crate::relayer::log_sent_metric(message.to_enum().item_name());
}

mem::replace(expected_transaction_indexes, missing_transactions);
mem::replace(expected_uncle_indexes, missing_uncles);
let _ignore_prev_value =
mem::replace(expected_transaction_indexes, missing_transactions);
let _ignore_prev_value = mem::replace(expected_uncle_indexes, missing_uncles);

if collision {
return StatusCode::CompactBlockMeetsShortIdsCollision.with_context(block_hash);
Expand Down
2 changes: 1 addition & 1 deletion sync/src/relayer/tests/block_transactions_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn test_accept_block() {

let block = BlockBuilder::default()
.transactions(vec![tx1, tx2.clone()])
.uncle(uncle.clone().as_uncle())
.uncle(uncle.as_uncle())
.build();
let prefilled = HashSet::from_iter(vec![0usize].into_iter());

Expand Down
2 changes: 1 addition & 1 deletion sync/src/relayer/tests/compact_block_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ fn test_accept_block() {
let block = BlockBuilder::default()
.header(header)
.transaction(TransactionBuilder::default().build())
.uncle(uncle.clone().as_uncle())
.uncle(uncle.as_uncle())
.build();

let uncle_hash = uncle.hash();
Expand Down
4 changes: 2 additions & 2 deletions sync/src/relayer/tests/reconstruct_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn test_reconstruct_transactions_and_uncles() {

let block = BlockBuilder::default()
.transactions(prepare.clone())
.uncles(vec![uncle.clone().as_uncle()])
.uncles(vec![uncle.as_uncle()])
.build();

let uncle_hash = uncle.hash();
Expand Down Expand Up @@ -139,7 +139,7 @@ fn test_reconstruct_invalid_uncles() {
.build();

let block = BlockBuilder::default()
.uncles(vec![uncle.clone().as_uncle()])
.uncles(vec![uncle.as_uncle()])
.build();

let uncle_hash = uncle.hash();
Expand Down
2 changes: 1 addition & 1 deletion sync/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl PeerState {
if *timeout >= now {
break;
}
timeouts.push(timeout.clone());
timeouts.push(*timeout);
all_txs.extend(txs.clone());
}
for timeout in timeouts {
Expand Down
2 changes: 1 addition & 1 deletion test/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Net {

let ptr = self as *const Self as *mut Self;
unsafe {
::std::mem::replace(&mut (*ptr).controller, controller);
let _ingore_prev_value = ::std::mem::replace(&mut (*ptr).controller, controller);
}
}

Expand Down
11 changes: 4 additions & 7 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl Node {

fn prepare_chain_spec(
&mut self,
modify_chain_spec: Box<dyn Fn(&mut ChainSpec) -> ()>,
modify_chain_spec: Box<dyn Fn(&mut ChainSpec)>,
) -> Result<(), Error> {
let integration_spec = include_bytes!("../integration.toml");
let always_success_cell = include_bytes!("../../script/testdata/always_success");
Expand Down Expand Up @@ -524,10 +524,7 @@ impl Node {
.map_err(Into::into)
}

fn rewrite_spec(
&self,
modify_ckb_config: Box<dyn Fn(&mut CKBAppConfig) -> ()>,
) -> Result<(), Error> {
fn rewrite_spec(&self, modify_ckb_config: Box<dyn Fn(&mut CKBAppConfig)>) -> Result<(), Error> {
// rewrite ckb.toml
let ckb_config_path = format!("{}/ckb.toml", self.working_dir());
let mut ckb_config: CKBAppConfig =
Expand All @@ -549,8 +546,8 @@ impl Node {

pub fn edit_config_file(
&mut self,
modify_chain_spec: Box<dyn Fn(&mut ChainSpec) -> ()>,
modify_ckb_config: Box<dyn Fn(&mut CKBAppConfig) -> ()>,
modify_chain_spec: Box<dyn Fn(&mut ChainSpec)>,
modify_ckb_config: Box<dyn Fn(&mut CKBAppConfig)>,
) {
let rpc_port = format!("{}", self.rpc_port);
let p2p_port = format!("{}", self.p2p_port);
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/alert/alert_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Spec for AlertPropagation {
);
}

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
let alert_config = self.alert_config.to_owned();
Box::new(move |config| {
config.network.discovery_local_address = true;
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/consensus/insufficient_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Spec for InsufficientReward {
// node.export("${backup}".to_string());
// }

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.params.initial_primary_epoch_reward = Capacity::shannons(2000_00000000);
spec_config.params.secondary_epoch_reward = Capacity::shannons(100_00000000);
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/dao/dao_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct WithdrawDAO;
impl Spec for WithdrawDAO {
crate::name!("withdraw_dao");

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.params.genesis_epoch_length = 2;
spec_config.params.epoch_duration_target = 2;
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct WithdrawDAOWithOverflowCapacity;
impl Spec for WithdrawDAOWithOverflowCapacity {
crate::name!("withdraw_dao_with_overflow_capacity");

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.params.genesis_epoch_length = 2;
spec_config.params.epoch_duration_target = 2;
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/dao/dao_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct DAOVerify;
impl Spec for DAOVerify {
crate::name!("dao_verify");

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.params.genesis_epoch_length = 20;
})
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/dao/satoshi_dao_occupied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Spec for DAOWithSatoshiCellOccupied {
DAOVerifier::init(node).verify();
}

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
let satoshi_cell = issue_satoshi_cell();
spec_config.genesis.issued_cells.push(satoshi_cell);
Expand Down Expand Up @@ -149,7 +149,7 @@ impl Spec for SpendSatoshiCell {
);
}

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
let satoshi_cell_occupied_ratio = self.satoshi_cell_occupied_ratio;
Box::new(move |spec_config| {
spec_config.genesis.issued_cells.push(issue_satoshi_cell());
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/indexer/genesis_issued_cells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Spec for GenesisIssuedCells {
}
}

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.genesis.issued_cells = vec![IssuedCell {
capacity: capacity_bytes!(5_000),
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/mining/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Spec for BootstrapCellbase {
)
}

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
Box::new(|config| {
config.block_assembler = Some(BlockAssemblerConfig {
code_hash: h256!("0xa2"),
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ pub trait Spec {

fn run(&self, net: &mut Net);

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|_| ())
}

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
// disable outbound peer service
Box::new(|config| {
config.network.connect_outbound_interval_secs = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/p2p/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Spec for Discovery {
);
}

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
// enable outbound peer service to connect discovered peers
Box::new(|config| {
config.network.connect_outbound_interval_secs = 1;
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/p2p/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Spec for WhitelistOnSessionLimit {

crate::setup!(num_nodes: 5, connect_all: false);

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
// disable outbound peer service
Box::new(|config| {
config.network.connect_outbound_interval_secs = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/relay/transaction_relay_low_fee_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Spec for TransactionRelayLowFeeRate {
assert!(!ret, "Transaction should not be relayed to node2");
}

fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
Box::new(|config| {
config.tx_pool.min_fee_rate = FeeRate::from_u64(1_000);
})
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/sync/chain_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Spec for ChainFork1 {
}

// workaround to disable node discovery
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig) -> ()> {
fn modify_ckb_config(&self) -> Box<dyn Fn(&mut CKBAppConfig)> {
Box::new(|config| config.network.connect_outbound_interval_secs = 100_000)
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/tx_pool/cellbase_maturity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Spec for CellbaseMaturity {
"Tx will be added to pending pool in N + {} block",
MATURITY - DEFAULT_TX_PROPOSAL_WINDOW.0
);
let tx_hash = node.rpc_client().send_transaction(tx.clone().data().into());
let tx_hash = node.rpc_client().send_transaction(tx.data().into());
assert_eq!(tx_hash, tx.hash());
node.assert_tx_pool_size(1, 0);

Expand All @@ -48,7 +48,7 @@ impl Spec for CellbaseMaturity {
node.assert_tx_pool_size(0, 0);
}

fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec) -> ()> {
fn modify_chain_spec(&self) -> Box<dyn Fn(&mut ChainSpec)> {
Box::new(|spec_config| {
spec_config.params.cellbase_maturity = MATURITY;
})
Expand Down
8 changes: 2 additions & 6 deletions test/src/specs/tx_pool/different_txs_with_same_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ impl Spec for DifferentTxsWithSameInput {
.as_advanced_builder()
.set_outputs(vec![output])
.build();
node0
.rpc_client()
.send_transaction(tx1.clone().data().into());
node0
.rpc_client()
.send_transaction(tx2.clone().data().into());
node0.rpc_client().send_transaction(tx1.data().into());
node0.rpc_client().send_transaction(tx2.data().into());

node0.generate_block();
node0.generate_block();
Expand Down
Loading

0 comments on commit 33a759e

Please sign in to comment.