Skip to content

Commit

Permalink
Fixed clippy warnings (paritytech#537)
Browse files Browse the repository at this point in the history
* fixed clippy warnings

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

This reverts commit dedddb6.

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

This reverts commit 8902ac2.

* fix after revert

* another fix after revert

* more clippy fixes
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 67973a7 commit baf6288
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 47 deletions.
6 changes: 3 additions & 3 deletions bridges/bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Alternative {
None,
None,
),
})
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/millau/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl SubstrateCli for Cli {
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
}
.load()?,
.load(),
))
}
}
Expand Down
22 changes: 11 additions & 11 deletions bridges/bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Alternative {
None,
None,
),
})
}
}
}

Expand All @@ -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(),
}),
Expand All @@ -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(),
})
}
}
2 changes: 1 addition & 1 deletion bridges/bin/rialto/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl SubstrateCli for Cli {
"local" => crate::chain_spec::Alternative::LocalTestnet,
_ => return Err(format!("Unsupported chain specification: {}", id)),
}
.load()?,
.load(),
))
}
}
Expand Down
41 changes: 22 additions & 19 deletions bridges/modules/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions bridges/modules/ethereum/src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()]))),
Expand Down
1 change: 1 addition & 0 deletions bridges/modules/substrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions bridges/relays/headers-relay/src/sync_loop_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
}
}

Expand Down
11 changes: 6 additions & 5 deletions bridges/relays/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit baf6288

Please sign in to comment.