ci: add quick-check with rustfmt (#615)

* ci: add quick-check with clippy and rustfmt

* chore: rustfmt round

* chore: set the same rustfmt config than substrate

* chore: fix formatting

* cI: remove clippy

* ci: switch to nightly for the checks

* ci: fix toolchains and naming

* ci: Limit the check to formatting

* chore: fix formatting

* Update .rustfmt.toml

* Update .rustfmt.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Chevdor
2021-09-16 16:57:52 +02:00
committed by GitHub
parent 035a576008
commit 1dd000a011
98 changed files with 1244 additions and 1872 deletions
+2 -12
View File
@@ -165,11 +165,7 @@ impl<B: BlockT> ParachainBlockData<B> {
extrinsics: sp_std::vec::Vec<<B as BlockT>::Extrinsic>,
storage_proof: sp_trie::CompactProof,
) -> Self {
Self {
header,
extrinsics,
storage_proof,
}
Self { header, extrinsics, storage_proof }
}
/// Convert `self` into the stored block.
@@ -198,13 +194,7 @@ impl<B: BlockT> ParachainBlockData<B> {
}
/// Deconstruct into the inner parts.
pub fn deconstruct(
self,
) -> (
B::Header,
sp_std::vec::Vec<B::Extrinsic>,
sp_trie::CompactProof,
) {
pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec<B::Extrinsic>, sp_trie::CompactProof) {
(self.header, self.extrinsics, self.storage_proof)
}
}
@@ -173,16 +173,10 @@ fn collect_relay_storage_proof(
relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id));
relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id));
relevant_keys.extend(ingress_channels.into_iter().map(|sender| {
relay_well_known_keys::hrmp_channels(HrmpChannelId {
sender,
recipient: para_id,
})
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id })
}));
relevant_keys.extend(egress_channels.into_iter().map(|recipient| {
relay_well_known_keys::hrmp_channels(HrmpChannelId {
sender: para_id,
recipient,
})
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender: para_id, recipient })
}));
sp_state_machine::prove_read(relay_parent_state_backend, relevant_keys)
+1 -1
View File
@@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives_core::PersistedValidationData;
use crate::{ParachainInherentData, INHERENT_IDENTIFIER};
use cumulus_primitives_core::PersistedValidationData;
use sp_inherents::{InherentData, InherentDataProvider};
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
+11 -26
View File
@@ -48,25 +48,21 @@ impl InherentDataProvider {
relay_chain_slot: Slot,
relay_chain_slot_duration: Duration,
) -> Self {
Self {
relay_chain_slot,
relay_chain_slot_duration,
}
Self { relay_chain_slot, relay_chain_slot_duration }
}
/// Create the inherent data.
pub fn create_inherent_data(&self) -> Result<InherentData, Error> {
let mut inherent_data = InherentData::new();
self.provide_inherent_data(&mut inherent_data)
.map(|_| inherent_data)
self.provide_inherent_data(&mut inherent_data).map(|_| inherent_data)
}
/// Provide the inherent data into the given `inherent_data`.
pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> {
// As the parachain starts building at around `relay_chain_slot + 1` we use that slot to
// calculate the timestamp.
let data: InherentType = ((*self.relay_chain_slot + 1)
* self.relay_chain_slot_duration.as_millis() as u64)
let data: InherentType = ((*self.relay_chain_slot + 1) *
self.relay_chain_slot_duration.as_millis() as u64)
.into();
inherent_data.put_data(INHERENT_IDENTIFIER, &data)
@@ -114,16 +110,10 @@ mod tests {
timestamp: u64,
relay_chain_slot: Slot,
) -> (ParachainBlockData, PHash) {
let sproof_builder = RelayStateSproofBuilder {
current_slot: relay_chain_slot,
..Default::default()
};
let sproof_builder =
RelayStateSproofBuilder { current_slot: relay_chain_slot, ..Default::default() };
let parent_header = client
.header(&at)
.ok()
.flatten()
.expect("Genesis header exists");
let parent_header = client.header(&at).ok().flatten().expect("Genesis header exists");
let relay_parent_storage_root = sproof_builder.clone().into_state_root_and_proof().0;
@@ -155,18 +145,13 @@ mod tests {
let timestamp = u64::from_str(&env::var("TIMESTAMP").expect("TIMESTAMP is set"))
.expect("TIMESTAMP is a valid `u64`");
let block = build_block(&client, BlockId::number(0), SLOT_DURATION, 1.into())
.0
.into_block();
let block =
build_block(&client, BlockId::number(0), SLOT_DURATION, 1.into()).0.into_block();
futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block))
.unwrap();
let (block, relay_chain_root) = build_block(
&client,
BlockId::number(1),
timestamp,
relay_chain_slot.into(),
);
let (block, relay_chain_root) =
build_block(&client, BlockId::number(1), timestamp, relay_chain_slot.into());
let header = call_validate_block(
client
+5 -7
View File
@@ -19,10 +19,10 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::marker::PhantomData;
use codec::Encode;
use cumulus_primitives_core::UpwardMessageSender;
use xcm::{WrapVersion, latest::prelude::*};
use sp_std::marker::PhantomData;
use xcm::{latest::prelude::*, WrapVersion};
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
@@ -36,12 +36,11 @@ impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
if dest.contains_parents_only(1) {
// An upward message for the relay chain.
let versioned_xcm = W::wrap_version(&dest, msg)
.map_err(|()| SendError::DestinationUnsupported)?;
let versioned_xcm =
W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
let data = versioned_xcm.encode();
T::send_upward_message(data)
.map_err(|e| SendError::Transport(e.into()))?;
T::send_upward_message(data).map_err(|e| SendError::Transport(e.into()))?;
Ok(())
} else {
@@ -50,4 +49,3 @@ impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
}
}
}