Fixed clippy warnings (#537)

* fixed clippy warnings

* Revert "Actually use pinned nightly version when building runtimes (#465)"

This reverts commit dedddb6b0f22260e00053c28873a0cb1fbea22e2.

* Revert "Pin Rust Nightly Version (#420)"

This reverts commit 8902ac2030cf7ef48ec512463424f134a3b38804.

* fix after revert

* another fix after revert

* more clippy fixes
This commit is contained in:
Svyatoslav Nikolsky
2020-11-30 16:14:07 +03:00
committed by Bastian Köcher
parent 4f661d2fe0
commit c20b4c868f
9 changed files with 57 additions and 47 deletions
+3 -3
View File
@@ -65,8 +65,8 @@ pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
impl Alternative {
/// Get an actual chain config from one of the alternatives.
pub(crate) fn load(self) -> Result<ChainSpec, String> {
Ok(match self {
pub(crate) fn load(self) -> ChainSpec {
match self {
Alternative::Development => ChainSpec::from_genesis(
"Development",
"dev",
@@ -131,7 +131,7 @@ impl Alternative {
None,
None,
),
})
}
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ impl SubstrateCli for Cli {
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
}
.load()?,
.load(),
))
}
}
+11 -11
View File
@@ -65,8 +65,8 @@ pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
impl Alternative {
/// Get an actual chain config from one of the alternatives.
pub(crate) fn load(self) -> Result<ChainSpec, String> {
Ok(match self {
pub(crate) fn load(self) -> ChainSpec {
match self {
Alternative::Development => ChainSpec::from_genesis(
"Development",
"dev",
@@ -131,7 +131,7 @@ impl Alternative {
None,
None,
),
})
}
}
}
@@ -156,8 +156,8 @@ fn testnet_genesis(
pallet_aura: Some(AuraConfig {
authorities: Vec::new(),
}),
pallet_bridge_eth_poa_Instance1: load_rialto_poa_bridge_config(),
pallet_bridge_eth_poa_Instance2: load_kovan_bridge_config(),
pallet_bridge_eth_poa_Instance1: Some(load_rialto_poa_bridge_config()),
pallet_bridge_eth_poa_Instance2: Some(load_kovan_bridge_config()),
pallet_grandpa: Some(GrandpaConfig {
authorities: Vec::new(),
}),
@@ -176,18 +176,18 @@ fn testnet_genesis(
}
}
fn load_rialto_poa_bridge_config() -> Option<BridgeRialtoPoAConfig> {
Some(BridgeRialtoPoAConfig {
fn load_rialto_poa_bridge_config() -> BridgeRialtoPoAConfig {
BridgeRialtoPoAConfig {
initial_header: rialto_runtime::rialto_poa::genesis_header(),
initial_difficulty: 0.into(),
initial_validators: rialto_runtime::rialto_poa::genesis_validators(),
})
}
}
fn load_kovan_bridge_config() -> Option<BridgeKovanConfig> {
Some(BridgeKovanConfig {
fn load_kovan_bridge_config() -> BridgeKovanConfig {
BridgeKovanConfig {
initial_header: rialto_runtime::kovan::genesis_header(),
initial_difficulty: 0.into(),
initial_validators: rialto_runtime::kovan::genesis_validators(),
})
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ impl SubstrateCli for Cli {
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
}
.load()?,
.load(),
))
}
}
+22 -19
View File
@@ -1028,7 +1028,7 @@ fn pool_configuration() -> PoolConfiguration {
}
/// Return iterator of given header ancestors.
fn ancestry<'a, S: Storage>(storage: &'a S, mut parent_hash: H256) -> impl Iterator<Item = (H256, AuraHeader)> + 'a {
fn ancestry<S: Storage>(storage: &'_ S, mut parent_hash: H256) -> impl Iterator<Item = (H256, AuraHeader)> + '_ {
sp_std::iter::from_fn(move || {
let (header, _) = storage.header(&parent_hash)?;
if header.number == 0 {
@@ -1069,30 +1069,33 @@ pub(crate) mod tests {
}
fn example_header_with_failed_receipt() -> AuraHeader {
let mut header = AuraHeader::default();
header.number = 3;
header.transactions_root = compute_merkle_root(vec![example_tx()].into_iter());
header.receipts_root = compute_merkle_root(vec![example_tx_receipt(false)].into_iter());
header.parent_hash = example_header().compute_hash();
header
AuraHeader {
number: 3,
transactions_root: compute_merkle_root(vec![example_tx()].into_iter()),
receipts_root: compute_merkle_root(vec![example_tx_receipt(false)].into_iter()),
parent_hash: example_header().compute_hash(),
..Default::default()
}
}
fn example_header() -> AuraHeader {
let mut header = AuraHeader::default();
header.number = 2;
header.transactions_root = compute_merkle_root(vec![example_tx()].into_iter());
header.receipts_root = compute_merkle_root(vec![example_tx_receipt(true)].into_iter());
header.parent_hash = example_header_parent().compute_hash();
header
AuraHeader {
number: 2,
transactions_root: compute_merkle_root(vec![example_tx()].into_iter()),
receipts_root: compute_merkle_root(vec![example_tx_receipt(true)].into_iter()),
parent_hash: example_header_parent().compute_hash(),
..Default::default()
}
}
fn example_header_parent() -> AuraHeader {
let mut header = AuraHeader::default();
header.number = 1;
header.transactions_root = compute_merkle_root(vec![example_tx()].into_iter());
header.receipts_root = compute_merkle_root(vec![example_tx_receipt(true)].into_iter());
header.parent_hash = genesis().compute_hash();
header
AuraHeader {
number: 1,
transactions_root: compute_merkle_root(vec![example_tx()].into_iter()),
receipts_root: compute_merkle_root(vec![example_tx_receipt(true)].into_iter()),
parent_hash: genesis().compute_hash(),
..Default::default()
}
}
fn with_headers_to_prune<T>(f: impl Fn(BridgeStorage<TestRuntime>) -> T) -> T {
+8 -4
View File
@@ -325,8 +325,10 @@ pub(crate) mod tests {
// when contract is active, but bloom has no required bits set
let config = ValidatorsConfiguration::Single(ValidatorsSource::Contract(Default::default(), Vec::new()));
let validators = Validators::new(&config);
let mut header = AuraHeader::default();
header.number = u64::max_value();
let mut header = AuraHeader {
number: u64::max_value(),
..Default::default()
};
assert!(!validators.maybe_signals_validators_change(&header));
// when contract is active and bloom has required bits set
@@ -347,10 +349,12 @@ pub(crate) mod tests {
(200, ValidatorsSource::Contract([3; 20].into(), vec![[3; 20].into()])),
]);
let validators = Validators::new(&config);
let mut header = AuraHeader::default();
let mut header = AuraHeader {
number: 100,
..Default::default()
};
// when we're at the block that switches to list source
header.number = 100;
assert_eq!(
validators.extract_validators_change(&header, None),
Ok((None, Some(vec![[2; 20].into()]))),
+1
View File
@@ -459,6 +459,7 @@ pub trait BridgeStorage {
/// Replace the current authority set with the next scheduled set.
///
/// Returns an error if there is no scheduled authority set to enact.
#[allow(clippy::result_unit_err)]
fn enact_authority_set(&mut self, signal_hash: <Self::Header as HeaderT>::Hash) -> Result<(), ()>;
/// Get the next scheduled Grandpa authority set change.
@@ -357,9 +357,10 @@ fn target_accept_all_headers(method: &TargetMethod, data: &mut TargetData, requi
if let TargetMethod::SubmitHeaders(ref submitted) = method {
assert_eq!(submitted.iter().all(|header| header.extra().is_some()), requires_extra,);
let mut submitted_headers = SubmittedHeaders::default();
submitted_headers.submitted = submitted.iter().map(|header| header.id()).collect();
data.submit_headers_result = Some(submitted_headers);
data.submit_headers_result = Some(SubmittedHeaders {
submitted: submitted.iter().map(|header| header.id()).collect(),
..Default::default()
});
}
}
+6 -5
View File
@@ -147,11 +147,12 @@ impl ToString for StringifiedMaybeConnectionError {
/// Exponential backoff for connection-unrelated errors retries.
pub fn retry_backoff() -> ExponentialBackoff {
let mut backoff = ExponentialBackoff::default();
// we do not want relayer to stop
backoff.max_elapsed_time = None;
backoff.max_interval = MAX_BACKOFF_INTERVAL;
backoff
ExponentialBackoff {
// we do not want relayer to stop
max_elapsed_time: None,
max_interval: MAX_BACKOFF_INTERVAL,
..Default::default()
}
}
/// Compact format of IDs vector.