From a503972cf32f03532ddac1c092e1e45b6d440be1 Mon Sep 17 00:00:00 2001 From: Cem Eliguzel Date: Thu, 14 Sep 2023 13:56:38 +0000 Subject: [PATCH] Fix formatting --- polkadot/xcm/xcm-builder/src/lib.rs | 4 +- .../xcm-builder/src/location_conversion.rs | 53 ++++++++++--------- .../basic-authorship/src/basic_authorship.rs | 5 +- substrate/client/block-builder/src/lib.rs | 12 +++-- 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/polkadot/xcm/xcm-builder/src/lib.rs b/polkadot/xcm/xcm-builder/src/lib.rs index 534f8819127f..ca8212a11f2f 100644 --- a/polkadot/xcm/xcm-builder/src/lib.rs +++ b/polkadot/xcm/xcm-builder/src/lib.rs @@ -34,8 +34,8 @@ pub use location_conversion::{ ChildParachainConvertsVia, DescribeAccountId32Terminal, DescribeAccountIdTerminal, DescribeAccountKey20Terminal, DescribeAllTerminal, DescribeFamily, DescribeLocation, DescribePalletTerminal, DescribeTerminus, GlobalConsensusConvertsFor, - GlobalConsensusParachainConvertsFor, HashedDescription, ParentIsPreset, - SiblingParachainConvertsVia, HashedDescriptionDescribeFamilyAllTerminal + GlobalConsensusParachainConvertsFor, HashedDescription, + HashedDescriptionDescribeFamilyAllTerminal, ParentIsPreset, SiblingParachainConvertsVia, }; mod origin_conversion; diff --git a/polkadot/xcm/xcm-builder/src/location_conversion.rs b/polkadot/xcm/xcm-builder/src/location_conversion.rs index 9f59c5bbfd12..2acbc4cce4c7 100644 --- a/polkadot/xcm/xcm-builder/src/location_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/location_conversion.rs @@ -173,7 +173,8 @@ impl + Clone> HashedDescriptionDescribeFamilyAllTermin fn describe_location_suffix(l: &MultiLocation) -> Option> { match (l.parents, &l.interior) { (0, Here) => Some(Vec::new()), - (0, X1(PalletInstance(i))) => Some((b"Pallet", Compact::::from(*i as u32)).encode()), + (0, X1(PalletInstance(i))) => + Some((b"Pallet", Compact::::from(*i as u32)).encode()), (0, X1(AccountId32 { id, .. })) => Some((b"AccountId32", id).encode()), (0, X1(AccountKey20 { key, .. })) => Some((b"AccountKey20", key).encode()), _ => return None, @@ -182,7 +183,8 @@ impl + Clone> HashedDescriptionDescribeFamilyAllTermin } impl + Clone> ConvertLocation - for HashedDescriptionDescribeFamilyAllTerminal { + for HashedDescriptionDescribeFamilyAllTerminal +{ fn convert_location(location: &MultiLocation) -> Option { let to_hash = match (location.parents, location.interior.first()) { (0, Some(Parachain(index))) => { @@ -969,66 +971,69 @@ mod tests { #[test] fn test_hashed_family_all_terminal_converter() { type Converter = HashedDescriptionDescribeFamilyAllTerminal; - + assert_eq!( [ - 129, 211, 14, 6, 146, 54, 225, 200, 135, 103, 248, 244, 125, 112, 53, 133, - 91, 42, 215, 236, 154, 199, 191, 208, 110, 148, 223, 55, 92, 216, 250, 34 + 129, 211, 14, 6, 146, 54, 225, 200, 135, 103, 248, 244, 125, 112, 53, 133, 91, 42, + 215, 236, 154, 199, 191, 208, 110, 148, 223, 55, 92, 216, 250, 34 ], Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 0, interior: X2(Parachain(1), AccountId32 { network: None, id: [0u8; 32] }), - }).unwrap() + }) + .unwrap() ); assert_eq!( [ - 17, 142, 105, 253, 199, 34, 43, 136, 155, 48, 12, 137, 155, 219, 155, 110, - 93, 181, 93, 252, 124, 60, 250, 195, 229, 86, 31, 220, 121, 111, 254, 252 + 17, 142, 105, 253, 199, 34, 43, 136, 155, 48, 12, 137, 155, 219, 155, 110, 93, 181, + 93, 252, 124, 60, 250, 195, 229, 86, 31, 220, 121, 111, 254, 252 ], Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 1, interior: X2(Parachain(1), AccountId32 { network: None, id: [0u8; 32] }), - }).unwrap() + }) + .unwrap() ); assert_eq!( [ - 237, 65, 190, 49, 53, 182, 196, 183, 151, 24, 214, 23, 72, 244, 235, 87, - 187, 67, 52, 122, 195, 192, 10, 58, 253, 49, 0, 112, 175, 224, 125, 66 + 237, 65, 190, 49, 53, 182, 196, 183, 151, 24, 214, 23, 72, 244, 235, 87, 187, 67, + 52, 122, 195, 192, 10, 58, 253, 49, 0, 112, 175, 224, 125, 66 ], Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 0, interior: X2(Parachain(1), AccountKey20 { network: None, key: [0u8; 20] }), - }).unwrap() + }) + .unwrap() ); assert_eq!( [ - 226, 225, 225, 162, 254, 156, 113, 95, 68, 155, 160, 118, 126, 18, 166, 132, - 144, 19, 8, 204, 228, 112, 164, 189, 179, 124, 249, 1, 168, 110, 151, 50 + 226, 225, 225, 162, 254, 156, 113, 95, 68, 155, 160, 118, 126, 18, 166, 132, 144, + 19, 8, 204, 228, 112, 164, 189, 179, 124, 249, 1, 168, 110, 151, 50 ], Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 1, interior: X2(Parachain(1), AccountKey20 { network: None, key: [0u8; 20] }), - }).unwrap() + }) + .unwrap() ); assert_eq!( [ - 254, 186, 179, 229, 13, 24, 84, 36, 84, 35, 64, 95, 114, 136, 62, 69, 247, - 74, 215, 104, 121, 114, 53, 6, 124, 46, 42, 245, 121, 197, 12, 208 + 254, 186, 179, 229, 13, 24, 84, 36, 84, 35, 64, 95, 114, 136, 62, 69, 247, 74, 215, + 104, 121, 114, 53, 6, 124, 46, 42, 245, 121, 197, 12, 208 ], Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 1, interior: X2(Parachain(2), PalletInstance(3)), - }).unwrap() + }) + .unwrap() ); assert_eq!( [ - 217, 56, 0, 36, 228, 154, 250, 26, 200, 156, 1, 39, 254, 162, 16, 187, 107, - 67, 27, 16, 218, 254, 250, 184, 6, 27, 216, 138, 194, 93, 23, 165 + 217, 56, 0, 36, 228, 154, 250, 26, 200, 156, 1, 39, 254, 162, 16, 187, 107, 67, 27, + 16, 218, 254, 250, 184, 6, 27, 216, 138, 194, 93, 23, 165 ], - Converter::<[u8; 32]>::convert_location(&MultiLocation { - parents: 1, - interior: Here, - }).unwrap() + Converter::<[u8; 32]>::convert_location(&MultiLocation { parents: 1, interior: Here }) + .unwrap() ); } } diff --git a/substrate/client/basic-authorship/src/basic_authorship.rs b/substrate/client/basic-authorship/src/basic_authorship.rs index 848b00d0310a..22b73047a9ae 100644 --- a/substrate/client/basic-authorship/src/basic_authorship.rs +++ b/substrate/client/basic-authorship/src/basic_authorship.rs @@ -501,7 +501,10 @@ where if pending_tx_encoded_size + proof_diff > block_size_limit { // The transaction and its storage proof are too big to be included // in a future block, we must ban the transaction right away - debug!("[{:?}] Invalid transaction: too big storage proof", pending_tx_hash); + debug!( + "[{:?}] Invalid transaction: too big storage proof", + pending_tx_hash + ); unqueue_invalid.push(pending_tx_hash); } else { // The transaction is suspicious, but it could be a false positive diff --git a/substrate/client/block-builder/src/lib.rs b/substrate/client/block-builder/src/lib.rs index bc8d2c12ac4b..c70c89a5af36 100644 --- a/substrate/client/block-builder/src/lib.rs +++ b/substrate/client/block-builder/src/lib.rs @@ -206,8 +206,8 @@ where let parent_hash = self.parent_hash; let extrinsics = &mut self.extrinsics; let version = self.version; - let estimate_proof_size_before = self - .api.proof_recorder().map(|pr| pr.estimate_encoded_size()).unwrap_or(0); + let estimate_proof_size_before = + self.api.proof_recorder().map(|pr| pr.estimate_encoded_size()).unwrap_or(0); self.api.execute_in_transaction(|api| { let res = if version < 6 { @@ -224,8 +224,8 @@ where if let Some(remaining_size_for_proof) = remaining_size_for_proof { let estimate_proof_size_after = api.proof_recorder().map(|pr| pr.estimate_encoded_size()).unwrap_or(0); - let estimate_proof_inflation = estimate_proof_size_after - .saturating_sub(estimate_proof_size_before); + let estimate_proof_inflation = + estimate_proof_size_after.saturating_sub(estimate_proof_size_before); if estimate_proof_inflation > remaining_size_for_proof { // The execution of the transaction results in exceeding the limits, @@ -376,7 +376,9 @@ mod tests { ) .unwrap(); - block_builder.push(ExtrinsicBuilder::new_read_and_panic(8).build(), None).unwrap_err(); + block_builder + .push(ExtrinsicBuilder::new_read_and_panic(8).build(), None) + .unwrap_err(); let block = block_builder.build().unwrap();