Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

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

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

This reverts commit 03ef763.

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

This reverts commit 8902ac2.

* fix after revert

* another fix after revert

* more clippy fixes
  • Loading branch information
svyatonik authored Nov 30, 2020
1 parent 18a4e98 commit 1eedbb1
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 61 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ jobs:
toolchain:
- stable
#- beta
- nightly-2020-10-04
- nightly
runs-on: self-hosted
container:
image: paritytech/ci-linux:production
volumes:
- /cache:/cache
env:
WASM_BUILD_TOOLCHAIN: nightly-2020-10-04
RUST_BACKTRACE: full
SCCACHE_REDIS: redis://172.17.0.1/0
SCCACHE_IDLE_TIMEOUT: 0
Expand All @@ -46,10 +45,6 @@ jobs:
with:
fetch-depth: 5
submodules: recursive
- name: Install Toolchain
run: rustup toolchain add nightly-2020-10-04
- name: Add WASM Utilities
run: rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-04
- name: Configure CARGO_TARGET_DIR
shell: bash
run: ./scripts/ci-cache.sh
Expand Down Expand Up @@ -82,11 +77,11 @@ jobs:

## Linting Stage
- name: Add clippy
if: matrix.toolchain == 'nightly-2020-10-04'
if: matrix.toolchain == 'nightly'
run: rustup component add clippy --toolchain ${{ matrix.toolchain }}
- name: Clippy
uses: actions-rs/cargo@master
if: matrix.toolchain == 'nightly-2020-10-04'
if: matrix.toolchain == 'nightly'
with:
command: clippy
toolchain: ${{ matrix.toolchain }}
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ RUN update-ca-certificates && \
curl https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH="/root/.cargo/bin:${PATH}"
ENV LAST_RUST_UPDATE 2020-10-15
ENV LAST_RUST_UPDATE 2020-11-30

RUN rustup update stable && \
rustup install nightly-2020-10-04 && \
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-04
rustup install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly

RUN rustc -vV && \
cargo -V && \
Expand Down
6 changes: 3 additions & 3 deletions 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 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 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 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
6 changes: 3 additions & 3 deletions deployments/Bridge.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ RUN update-ca-certificates && \
curl https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH="/root/.cargo/bin:${PATH}"
ENV LAST_RUST_UPDATE 2020-10-15
ENV LAST_RUST_UPDATE 2020-11-30

RUN rustup update stable && \
rustup install nightly-2020-10-04 && \
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-04
rustup install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly

RUN rustc -vV && \
cargo -V && \
Expand Down
41 changes: 22 additions & 19 deletions 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 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 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 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 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 1eedbb1

Please sign in to comment.