Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
@@ -22,8 +22,8 @@ use super::{
BabeEpochConfiguration, Slot, BABE_ENGINE_ID,
};
use codec::{Codec, Decode, Encode};
use sp_std::vec::Vec;
use sp_runtime::{DigestItem, RuntimeDebug};
use sp_std::vec::Vec;
use sp_consensus_vrf::schnorrkel::{Randomness, VRFOutput, VRFProof};
@@ -143,14 +143,13 @@ pub enum NextConfigDescriptor {
c: (u64, u64),
/// Value of `allowed_slots` in `BabeEpochConfiguration`.
allowed_slots: AllowedSlots,
}
},
}
impl From<NextConfigDescriptor> for BabeEpochConfiguration {
fn from(desc: NextConfigDescriptor) -> Self {
match desc {
NextConfigDescriptor::V1 { c, allowed_slots } =>
Self { c, allowed_slots },
NextConfigDescriptor::V1 { c, allowed_slots } => Self { c, allowed_slots },
}
}
}
@@ -176,8 +175,9 @@ pub trait CompatibleDigestItem: Sized {
fn as_next_config_descriptor(&self) -> Option<NextConfigDescriptor>;
}
impl<Hash> CompatibleDigestItem for DigestItem<Hash> where
Hash: Send + Sync + Eq + Clone + Codec + 'static
impl<Hash> CompatibleDigestItem for DigestItem<Hash>
where
Hash: Send + Sync + Eq + Clone + Codec + 'static,
{
fn babe_pre_digest(digest: PreDigest) -> Self {
DigestItem::PreRuntime(BABE_ENGINE_ID, digest.encode())
@@ -17,7 +17,7 @@
//! Inherents for BABE
use sp_inherents::{InherentData, InherentIdentifier, Error};
use sp_inherents::{Error, InherentData, InherentIdentifier};
use sp_std::result::Result;
@@ -64,13 +64,10 @@ impl InherentDataProvider {
timestamp: sp_timestamp::Timestamp,
duration: std::time::Duration,
) -> Self {
let slot = InherentType::from(
(timestamp.as_duration().as_millis() / duration.as_millis()) as u64
);
let slot =
InherentType::from((timestamp.as_duration().as_millis() / duration.as_millis()) as u64);
Self {
slot,
}
Self { slot }
}
/// Returns the `slot` of this inherent data provider.
+10 -23
View File
@@ -30,7 +30,7 @@ pub use sp_consensus_vrf::schnorrkel::{
use codec::{Decode, Encode};
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use sp_keystore::vrf::{VRFTranscriptData, VRFTranscriptValue};
use sp_runtime::{traits::Header, ConsensusEngineId, RuntimeDebug};
@@ -96,11 +96,7 @@ pub type BabeAuthorityWeight = u64;
pub type BabeBlockWeight = u32;
/// Make a VRF transcript from given randomness, slot number and epoch.
pub fn make_transcript(
randomness: &Randomness,
slot: Slot,
epoch: u64,
) -> Transcript {
pub fn make_transcript(randomness: &Randomness, slot: Slot, epoch: u64) -> Transcript {
let mut transcript = Transcript::new(&BABE_ENGINE_ID);
transcript.append_u64(b"slot number", *slot);
transcript.append_u64(b"current epoch", epoch);
@@ -110,18 +106,14 @@ pub fn make_transcript(
/// Make a VRF transcript data container
#[cfg(feature = "std")]
pub fn make_transcript_data(
randomness: &Randomness,
slot: Slot,
epoch: u64,
) -> VRFTranscriptData {
pub fn make_transcript_data(randomness: &Randomness, slot: Slot, epoch: u64) -> VRFTranscriptData {
VRFTranscriptData {
label: &BABE_ENGINE_ID,
items: vec![
("slot number", VRFTranscriptValue::U64(*slot)),
("current epoch", VRFTranscriptValue::U64(epoch)),
("chain randomness", VRFTranscriptValue::Bytes(randomness.to_vec())),
]
],
}
}
@@ -280,20 +272,15 @@ where
use digests::*;
use sp_application_crypto::RuntimeAppPublic;
let find_pre_digest = |header: &H| {
header
.digest()
.logs()
.iter()
.find_map(|log| log.as_babe_pre_digest())
};
let find_pre_digest =
|header: &H| header.digest().logs().iter().find_map(|log| log.as_babe_pre_digest());
let verify_seal_signature = |mut header: H, offender: &AuthorityId| {
let seal = header.digest_mut().pop()?.as_babe_seal()?;
let pre_hash = header.hash();
if !offender.verify(&pre_hash.as_ref(), &seal) {
return None;
return None
}
Some(())
@@ -302,7 +289,7 @@ where
let verify_proof = || {
// we must have different headers for the equivocation to be valid
if proof.first_header.hash() == proof.second_header.hash() {
return None;
return None
}
let first_pre_digest = find_pre_digest(&proof.first_header)?;
@@ -313,12 +300,12 @@ where
if proof.slot != first_pre_digest.slot() ||
first_pre_digest.slot() != second_pre_digest.slot()
{
return None;
return None
}
// both headers must have been authored by the same authority
if first_pre_digest.authority_index() != second_pre_digest.authority_index() {
return None;
return None
}
// we finally verify that the expected authority has signed both headers and