Skip to content

Commit

Permalink
Update rust version (exonum#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc authored and aleksuss committed Jan 4, 2019
1 parent 16ff63d commit 0a5350f
Show file tree
Hide file tree
Showing 62 changed files with 264 additions and 229 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ addons:
- zlib1g-dev

rust:
- 1.30.0
- 1.31.1

cache:
directories:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
install:
- cargo deadlinks -V | grep $DEADLINKS_VERS || cargo install cargo-deadlinks --vers $DEADLINKS_VERS --force
- cargo install --list
- rustup component add rustfmt-preview
- rustup component add rustfmt
- rustfmt -V
- nvm install 8 && nvm use 8
- npm install
Expand Down Expand Up @@ -131,16 +131,15 @@ jobs:

# Clippy linting.
- name: clippy
rust: nightly-2018-11-28
install:
- cargo clippy --version || rustup component add clippy-preview --toolchain=nightly-2018-11-28
- rustup component add clippy
- cargo clippy --version
script:
- cargo clippy --all -- -D warnings

# Benchmarks (compilation only).
- name: benchmarks
rust: nightly-2018-11-28
rust: nightly-2018-12-30
script:
- RUST_LOG=off cargo check --benches --features "long_benchmarks"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Docs.rs](https://docs.rs/exonum/badge.svg)](https://docs.rs/exonum)
[![License: Apache-2.0](https://img.shields.io/github/license/exonum/exonum.svg)](LICENSE.md)
[![LoC](https://tokei.rs/b1/github/exonum/exonum)](https://github.com/exonum/exonum)
![rust 1.30.0+ required](https://img.shields.io/badge/rust-1.30.0+-blue.svg?label=Required%20Rust)
![rust 1.31.1+ required](https://img.shields.io/badge/rust-1.31.1+-blue.svg?label=Required%20Rust)

**Community:**
[![Join the chat at https://gitter.im/exonum/exonum](https://img.shields.io/gitter/room/exonum/exonum.svg?label=Chat)](https://gitter.im/exonum/exonum)
Expand Down
12 changes: 8 additions & 4 deletions components/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fn get_proto_files<P: AsRef<Path>>(path: &P) -> Vec<PathBuf> {
} else {
None
}
}).collect()
})
.collect()
}

/// Workaround for https://github.com/stepancheg/rust-protobuf/issues/324
Expand All @@ -67,7 +68,8 @@ fn generate_mod_rs<P: AsRef<Path>, Q: AsRef<Path>>(
} else {
format!("pub mod {};\n", mod_name)
}
}).collect::<String>()
})
.collect::<String>()
};
let dest_path = out_dir.as_ref().join(mod_file);
let mut file = File::create(dest_path).expect("Unable to create output file");
Expand Down Expand Up @@ -135,12 +137,14 @@ where
s.as_ref()
.to_str()
.expect("Include dir name is not convertible to &str")
}).collect::<Vec<_>>(),
})
.collect::<Vec<_>>(),
customize: Customize {
serde_derive: Some(true),
..Default::default()
},
}).expect("protoc");
})
.expect("protoc");

// rerun build.rs if .proto files changed.
println!(
Expand Down
9 changes: 3 additions & 6 deletions components/crypto/src/crypto_lib/sodiumoxide/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ pub const SECRET_KEY_LENGTH: usize = 32;
/// let (pk, sk) = exonum_crypto::gen_keypair();
/// let (public_key, secret_key) = exonum_crypto::x25519::into_x25519_keypair(pk, sk).unwrap();
/// ```
#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::needless_pass_by_value)
)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_pass_by_value))]
pub fn into_x25519_keypair(
pk: crypto_PublicKey,
sk: crypto_SecretKey,
Expand Down Expand Up @@ -178,5 +175,5 @@ implement_x25519_type! {
struct SecretKey, Curve25519Scalar, SECRET_KEY_LENGTH
}

implement_index_traits!{ PublicKey }
implement_index_traits!{ SecretKey }
implement_index_traits! { PublicKey }
implement_index_traits! { SecretKey }
18 changes: 8 additions & 10 deletions components/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,10 @@ fn get_exonum_types_prefix(attrs: &[Attribute]) -> impl quote::ToTokens {
lit: Lit::Str(path),
ident,
..
}
if ident == CRATE_PATH_ATTRIBUTE =>
{
Some(
path.parse::<Path>()
.expect("failed to parse crate path in the attribute"),
)
}
} if ident == CRATE_PATH_ATTRIBUTE => Some(
path.parse::<Path>()
.expect("failed to parse crate path in the attribute"),
),
_ => None,
});

Expand All @@ -126,7 +122,8 @@ fn get_exonum_attributes(attrs: &[Attribute]) -> Vec<Meta> {
.filter_map(|n| match n {
NestedMeta::Meta(meta) => Some(meta),
_ => None,
}).collect(),
})
.collect(),
Some(_) => panic!("`exonum` attribute should contain list of name value pairs"),
None => vec![],
}
Expand All @@ -138,7 +135,8 @@ fn get_exonum_name_value_attributes(attrs: &[Attribute]) -> Vec<MetaNameValue> {
.filter_map(|meta| match meta {
Meta::NameValue(name_value) => Some(name_value),
_ => None,
}).collect()
})
.collect()
}

fn find_exonum_word_attribute(attrs: &[Attribute], ident_name: &str) -> bool {
Expand Down
5 changes: 3 additions & 2 deletions components/derive/src/tx_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fn get_tx_variants(data: &DataEnum) -> Vec<Variant> {
ident: v.ident.clone(),
typ: field.ty.clone(),
}
}).collect()
})
.collect()
}

fn implement_conversions_for_transactions(
Expand All @@ -69,7 +70,7 @@ fn implement_conversions_for_transactions(
}
});

quote!{
quote! {
#(#conversions)*
}
}
Expand Down
3 changes: 2 additions & 1 deletion examples/cryptocurrency/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ fn test_unknown_wallet_request() {
.public(ApiKind::Service("cryptocurrency"))
.query(&WalletQuery {
pub_key: tx.author(),
}).get::<Wallet>("v1/wallet")
})
.get::<Wallet>("v1/wallet")
.unwrap_err();

assert_matches!(
Expand Down
3 changes: 2 additions & 1 deletion examples/cryptocurrency/tests/tx_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ fn test_fuzz_transfers() {
);
let amount = rng.gen_range(0, 250);
TxTransfer::sign(&receiver.0, amount, rng.gen::<u64>(), &sender.0, &sender.1)
}).collect();
})
.collect();

testkit.create_block_with_transactions(txs);

Expand Down
16 changes: 8 additions & 8 deletions exonum/benches/criterion/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ fn prepare_txs(
.map(|tx| {
schema.add_transaction_into_pool(tx.clone());
tx.hash()
}).collect()
})
.collect()
};

blockchain.merge(fork.into_patch()).unwrap();
Expand All @@ -452,12 +453,10 @@ fn assert_transactions_in_pool(blockchain: &Blockchain, tx_hashes: &[Hash]) {
let snapshot = blockchain.snapshot();
let schema = Schema::new(&snapshot);

assert!(
tx_hashes
.iter()
.all(|hash| schema.transactions_pool().contains(&hash)
&& !schema.transactions_locations().contains(&hash))
);
assert!(tx_hashes
.iter()
.all(|hash| schema.transactions_pool().contains(&hash)
&& !schema.transactions_locations().contains(&hash)));
assert_eq!(tx_hashes.len() as u64, schema.transactions_pool_len());
}

Expand Down Expand Up @@ -526,7 +525,8 @@ fn execute_block_rocksdb(
});
},
TXS_IN_BLOCK,
).sample_size(50)
)
.sample_size(50)
.throughput(|&&txs_in_block| Throughput::Elements(txs_in_block as u32)),
);
}
Expand Down
6 changes: 4 additions & 2 deletions exonum/benches/criterion/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ fn proof_list_append(b: &mut Bencher, db: &dyn Database, len: usize) {
let mut chunk = vec![0; CHUNK_SIZE];
rng.fill_bytes(&mut chunk);
chunk
}).collect::<Vec<_>>();
})
.collect::<Vec<_>>();

b.iter_with_setup(
|| db.fork(),
Expand Down Expand Up @@ -179,7 +180,8 @@ where
benchmark(b, &db, len)
},
item_counts,
).throughput(|s| Throughput::Elements(*s as u32))
)
.throughput(|s| Throughput::Elements(*s as u32))
.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic))
.sample_size(SAMPLE_SIZE),
);
Expand Down
6 changes: 4 additions & 2 deletions exonum/benches/criterion/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ fn gen_messages(count: usize, tx_size: usize) -> Vec<Vec<u8>> {
&s,
);
msg.into_bytes()
}).collect()
})
.collect()
}

#[derive(Clone)]
Expand Down Expand Up @@ -183,7 +184,8 @@ impl MessageVerifier {
messages
.into_iter()
.map(|message| InternalRequest::VerifyMessage(message)),
)).map(drop)
))
.map(drop)
.map_err(drop)
.and_then(|()| finish_signal.map_err(drop))
}
Expand Down
6 changes: 4 additions & 2 deletions exonum/src/api/backends/actix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ where
handler(&context, query)
.map(|value| HttpResponse::Ok().json(value))
.map_err(From::from)
}).responder()
})
.responder()
};

Self {
Expand Down Expand Up @@ -239,7 +240,8 @@ where
handler(&context, query)
.map(|value| HttpResponse::Ok().json(value))
.map_err(From::from)
}).responder()
})
.responder()
};

Self {
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/api/node/private/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ impl NodeInfo {
.map(|s| ServiceInfo {
name: s.service_name().to_owned(),
id: s.service_id(),
}).collect(),
})
.collect(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/api/node/public/explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ impl ExplorerApi {
if query.add_blocks_time {
times.push(median_precommits_time(&block.precommits()));
}
}).map(|block| block.into_header())
})
.map(|block| block.into_header())
.collect();

let height = if blocks.len() < query.count {
Expand Down
6 changes: 4 additions & 2 deletions exonum/src/api/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ impl Actor for Session {
self.server_address
.send(Subscribe {
address: address.clone().recipient(),
}).into_actor(self)
})
.into_actor(self)
.then(|response, actor, context| {
match response {
Ok(result) => {
Expand All @@ -130,7 +131,8 @@ impl Actor for Session {
_ => context.stop(),
}
fut::ok(())
}).wait(ctx);
})
.wait(ctx);
}

fn stopping(&mut self, _ctx: &mut <Self as Actor>::Context) -> Running {
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/blockchain/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ mod tests {
.map(|i| ValidatorKeys {
consensus_key: gen_keypair_from_seed(&Seed::new([i; SEED_LENGTH])).0,
service_key: gen_keypair_from_seed(&Seed::new([i * 10; SEED_LENGTH])).0,
}).collect();
})
.collect();

StoredConfiguration {
previous_cfg_hash: Hash::zero(),
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ impl Blockchain {
"Service not found. Service id: {}",
raw.service_id()
))
})?.service_name();
})?
.service_name();

let tx = self.tx_from_raw(raw.payload().clone()).map_err(|error| {
format_err!("Service <{}>: {}, tx: {:?}", service_name, error, tx_hash)
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/blockchain/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ impl SharedNodeState {
lock.validators
.iter()
.any(|v| v.consensus_key == ci.public_key)
}).count();
})
.count();

if lock.node_role.is_validator() {
// Peers list doesn't include current node address, so we have to increment its length.
Expand Down
6 changes: 3 additions & 3 deletions exonum/src/blockchain/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ mod tests {
Some("(Not) really long error description".to_owned()),
)),
]
.iter()
.map(|res| TransactionResult(res.to_owned()))
.collect::<Vec<_>>();
.iter()
.map(|res| TransactionResult(res.to_owned()))
.collect::<Vec<_>>();

for result in &results {
let bytes = result.clone().into_bytes();
Expand Down
3 changes: 2 additions & 1 deletion exonum/src/events/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ impl InternalPart {

let send_event = Self::send_event(event, internal_tx.clone());
handle.spawn(send_event);
}).for_each(Ok)
})
.for_each(Ok)
}
}

Expand Down
6 changes: 4 additions & 2 deletions exonum/src/events/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ impl ConnectionPool {
log_error(e);
write_pool.remove(&address);
Ok(())
}).map(drop),
})
.map(drop),
)
} else {
Either::B(future::ok(()))
Expand Down Expand Up @@ -540,7 +541,8 @@ impl NetworkHandler {
.ok_or_else(|| format_err!("shutdown twice"))
.into_future(),
),
}.map_err(log_error);
}
.map_err(log_error);

handle.spawn(fut);
Ok(())
Expand Down
Loading

0 comments on commit 0a5350f

Please sign in to comment.