cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
@@ -17,10 +17,12 @@
//! Basic parachain that adds a number as part of its state.
#![no_std]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)
)]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler))]
use parity_scale_codec::{Encode, Decode};
use parity_scale_codec::{Decode, Encode};
use tiny_keccak::{Hasher as _, Keccak};
#[cfg(not(feature = "std"))]
@@ -45,8 +47,10 @@ fn keccak256(input: &[u8]) -> [u8; 32] {
/// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics.
#[cfg(feature = "std")]
pub fn wasm_binary_unwrap() -> &'static [u8] {
WASM_BINARY.expect("Development wasm binary is not available. Testing is only \
supported with the flag disabled.")
WASM_BINARY.expect(
"Development wasm binary is not available. Testing is only \
supported with the flag disabled.",
)
}
/// Head data for this parachain.
@@ -93,14 +97,10 @@ pub fn execute(
assert_eq!(parent_hash, parent_head.hash());
if hash_state(block_data.state) != parent_head.post_state {
return Err(StateMismatch);
return Err(StateMismatch)
}
let new_state = block_data.state.wrapping_add(block_data.add);
Ok(HeadData {
number: parent_head.number + 1,
parent_hash,
post_state: hash_state(new_state),
})
Ok(HeadData { number: parent_head.number + 1, parent_hash, post_state: hash_state(new_state) })
}
@@ -16,32 +16,30 @@
//! WASM validation for adder parachain.
use crate::{HeadData, BlockData};
use crate::{BlockData, HeadData};
use core::panic;
use parachain::primitives::{HeadData as GenericHeadData, ValidationResult};
use parity_scale_codec::{Decode, Encode};
use sp_std::vec::Vec;
use parachain::primitives::{ValidationResult, HeadData as GenericHeadData};
use parity_scale_codec::{Encode, Decode};
#[no_mangle]
pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 {
let params = unsafe { parachain::load_params(params, len) };
let parent_head = HeadData::decode(&mut &params.parent_head.0[..])
.expect("invalid parent head format.");
let parent_head =
HeadData::decode(&mut &params.parent_head.0[..]).expect("invalid parent head format.");
let block_data = BlockData::decode(&mut &params.block_data.0[..])
.expect("invalid block data format.");
let block_data =
BlockData::decode(&mut &params.block_data.0[..]).expect("invalid block data format.");
let parent_hash = crate::keccak256(&params.parent_head.0[..]);
let new_head = crate::execute(parent_hash, parent_head, &block_data).expect("Executes block");
parachain::write_result(
&ValidationResult {
head_data: GenericHeadData(new_head.encode()),
new_validation_code: None,
upward_messages: sp_std::vec::Vec::new(),
horizontal_messages: sp_std::vec::Vec::new(),
processed_downward_messages: 0,
hrmp_watermark: params.relay_parent_number,
}
)
parachain::write_result(&ValidationResult {
head_data: GenericHeadData(new_head.encode()),
new_validation_code: None,
upward_messages: sp_std::vec::Vec::new(),
horizontal_messages: sp_std::vec::Vec::new(),
processed_downward_messages: 0,
hrmp_watermark: params.relay_parent_number,
})
}