Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Oct 27, 2023
1 parent 7ff1e19 commit cc9b1fc
Show file tree
Hide file tree
Showing 18 changed files with 944 additions and 1,094 deletions.
6 changes: 3 additions & 3 deletions parachain/pallets/ethereum-beacon-client/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<T: Config> Verifier for Pallet<T> {
message.proof.block_hash,
err
);
return Err(err);
return Err(err)
},
};

Expand All @@ -48,7 +48,7 @@ impl<T: Config> Verifier for Pallet<T> {
message.proof.block_hash,
err
);
return Err(Error::<T>::DecodeFailed.into());
return Err(Error::<T>::DecodeFailed.into())
},
};

Expand All @@ -58,7 +58,7 @@ impl<T: Config> Verifier for Pallet<T> {
"💫 Event log not found in receipt for transaction at index {} in block {}",
message.proof.tx_index, message.proof.block_hash,
);
return Err(Error::<T>::InvalidProof.into());
return Err(Error::<T>::InvalidProof.into())
}

log::info!(
Expand Down
34 changes: 17 additions & 17 deletions parachain/pallets/ethereum-beacon-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ pub mod pallet {
// committee period.
let max_latency = config::EPOCHS_PER_SYNC_COMMITTEE_PERIOD * config::SLOTS_PER_EPOCH;
ensure!(
latest_execution_state.beacon_slot == 0
|| latest_finalized_state.slot
< latest_execution_state.beacon_slot + max_latency as u64,
latest_execution_state.beacon_slot == 0 ||
latest_finalized_state.slot <
latest_execution_state.beacon_slot + max_latency as u64,
Error::<T>::ExecutionHeaderTooFarBehind
);
Ok(())
Expand All @@ -371,8 +371,8 @@ pub mod pallet {

// Verify update does not skip a sync committee period.
ensure!(
update.signature_slot > update.attested_header.slot
&& update.attested_header.slot >= update.finalized_header.slot,
update.signature_slot > update.attested_header.slot &&
update.attested_header.slot >= update.finalized_header.slot,
Error::<T>::InvalidUpdateSlot
);
// Retrieve latest finalized state.
Expand All @@ -392,12 +392,12 @@ pub mod pallet {

// Verify update is relevant.
let update_attested_period = compute_period(update.attested_header.slot);
let update_has_next_sync_committee = !<NextSyncCommittee<T>>::exists()
&& (update.next_sync_committee_update.is_some()
&& update_attested_period == store_period);
let update_has_next_sync_committee = !<NextSyncCommittee<T>>::exists() &&
(update.next_sync_committee_update.is_some() &&
update_attested_period == store_period);
ensure!(
update.attested_header.slot > latest_finalized_state.slot
|| update_has_next_sync_committee,
update.attested_header.slot > latest_finalized_state.slot ||
update_has_next_sync_committee,
Error::<T>::IrrelevantUpdate
);

Expand Down Expand Up @@ -554,9 +554,9 @@ pub mod pallet {
// Checks that we don't skip execution headers, they need to be imported sequentially.
let latest_execution_state: ExecutionHeaderState = Self::latest_execution_state();
ensure!(
latest_execution_state.block_number == 0
|| update.execution_header.block_number
== latest_execution_state.block_number + 1,
latest_execution_state.block_number == 0 ||
update.execution_header.block_number ==
latest_execution_state.block_number + 1,
Error::<T>::ExecutionHeaderSkippedBlock
);

Expand Down Expand Up @@ -600,7 +600,7 @@ pub mod pallet {
let state = <FinalizedBeaconState<T>>::get(block_root)
.ok_or(Error::<T>::ExpectedFinalizedHeaderNotStored)?;
if update.header.slot != state.slot {
return Err(Error::<T>::ExpectedFinalizedHeaderNotStored.into());
return Err(Error::<T>::ExpectedFinalizedHeaderNotStored.into())
}
},
}
Expand Down Expand Up @@ -790,13 +790,13 @@ pub mod pallet {
/// Returns the fork version based on the current epoch.
pub(super) fn select_fork_version(fork_versions: &ForkVersions, epoch: u64) -> ForkVersion {
if epoch >= fork_versions.capella.epoch {
return fork_versions.capella.version;
return fork_versions.capella.version
}
if epoch >= fork_versions.bellatrix.epoch {
return fork_versions.bellatrix.version;
return fork_versions.bellatrix.version
}
if epoch >= fork_versions.altair.epoch {
return fork_versions.altair.version;
return fork_versions.altair.version
}

fork_versions.genesis.version
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl SendXcm for MockXcmSender {
match dest {
Some(MultiLocation { interior, .. }) => {
if let X1(Parachain(1001)) = interior {
return Err(XcmpSendError::NotApplicable);
return Err(XcmpSendError::NotApplicable)
}
Ok((xcm.clone().unwrap(), MultiAssets::default()))
},
Expand Down
8 changes: 4 additions & 4 deletions parachain/pallets/outbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub mod pallet {
pub(crate) fn commit_messages() {
let count = MessageLeaves::<T>::decode_len().unwrap_or_default() as u64;
if count == 0 {
return;
return
}

// Create merkle root of messages
Expand All @@ -264,8 +264,8 @@ pub mod pallet {
// Yield if the maximum number of messages has been processed this block.
// This ensures that the weight of `on_finalize` has a known maximum bound.
ensure!(
MessageLeaves::<T>::decode_len().unwrap_or(0)
< T::MaxMessagesPerBlock::get() as usize,
MessageLeaves::<T>::decode_len().unwrap_or(0) <
T::MaxMessagesPerBlock::get() as usize,
ProcessMessageError::Yield
);

Expand Down Expand Up @@ -403,7 +403,7 @@ pub mod pallet {
) -> Result<bool, ProcessMessageError> {
let weight = T::WeightInfo::do_process_message();
if meter.try_consume(weight).is_err() {
return Err(ProcessMessageError::Overweight(weight));
return Err(ProcessMessageError::Overweight(weight))
}
Self::do_process_message(origin, message)
}
Expand Down
2 changes: 1 addition & 1 deletion parachain/primitives/core/src/outbound.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::ParaId;
use codec::{Decode, Encode, MaxEncodedLen};
use derivative::Derivative;
use ethabi::Token;
use frame_support::{
traits::{tokens::Balance, Get},
BoundedVec, CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
};
use crate::ParaId;
use scale_info::TypeInfo;
use sp_core::{RuntimeDebug, H160, H256, U256};
use sp_std::{borrow::ToOwned, vec, vec::Vec};
Expand Down
46 changes: 21 additions & 25 deletions parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,22 @@ where

if network != gateway_network {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched bridge network {network:?}.");
return Err(SendError::NotApplicable);
return Err(SendError::NotApplicable)
}

let dest = destination.take().ok_or(SendError::MissingArgument)?;
if dest != Here {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched remote destination {dest:?}.");
return Err(SendError::NotApplicable);
return Err(SendError::NotApplicable)
}

let gateway_address = match gateway_junctions {
X1(AccountKey20 { network, key })
if network.is_none() || network == Some(gateway_network) =>
{
key
},
key,
_ => {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched registry contract {gateway_junctions:?}.");
return Err(SendError::NotApplicable);
return Err(SendError::NotApplicable)
},
};

Expand All @@ -86,14 +84,14 @@ where

if Ok(local_net) != universal_location.global_consensus() {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched relay network {local_net:?}.");
return Err(SendError::NotApplicable);
return Err(SendError::NotApplicable)
}

let para_id = match local_sub {
X1(Parachain(para_id)) => para_id,
_ => {
log::error!(target: "xcm::ethereum_blob_exporter", "could not get parachain id from universal source '{local_sub:?}'.");
return Err(SendError::MissingArgument);
return Err(SendError::MissingArgument)
},
};

Expand All @@ -110,7 +108,7 @@ where

if max_target_fee.is_some() {
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due not supporting max target fee.");
return Err(SendError::Unroutable);
return Err(SendError::Unroutable)
}

// local_sub is relative to the relaychain. No conversion needed.
Expand All @@ -119,7 +117,7 @@ where
Some(id) => id,
None => {
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{local_sub_location:?}'");
return Err(SendError::Unroutable);
return Err(SendError::Unroutable)
},
};

Expand Down Expand Up @@ -207,7 +205,7 @@ impl<'a, Call> XcmConverter<'a, Call> {

// All xcm instructions must be consumed before exit.
if self.next().is_ok() {
return Err(XcmConverterError::EndOfXcmMessageExpected);
return Err(XcmConverterError::EndOfXcmMessageExpected)
}

Ok((result, max_target_fee))
Expand All @@ -219,9 +217,7 @@ impl<'a, Call> XcmConverter<'a, Call> {
WithdrawAsset(fee_asset) => match self.next()? {
BuyExecution { fees: execution_fee, weight_limit: Unlimited }
if fee_asset.len() == 1 && fee_asset.contains(execution_fee) =>
{
Some(execution_fee)
},
Some(execution_fee),
_ => return Err(BuyExecutionExpected),
},
UnpaidExecution { check_origin: None, weight_limit: Unlimited } => None,
Expand All @@ -234,18 +230,18 @@ impl<'a, Call> XcmConverter<'a, Call> {
use XcmConverterError::*;
let (assets, beneficiary) = if let WithdrawAsset(reserved_assets) = self.next()? {
if reserved_assets.len() == 0 {
return Err(NoReserveAssets);
return Err(NoReserveAssets)
}
if let DepositAsset { assets, beneficiary } = self.next()? {
if reserved_assets.inner().iter().any(|asset| !assets.matches(asset)) {
return Err(FilterDoesNotConsumeAllAssets);
return Err(FilterDoesNotConsumeAllAssets)
}
(reserved_assets, beneficiary)
} else {
return Err(DepositExpected);
return Err(DepositExpected)
}
} else {
return Err(WithdrawExpected);
return Err(WithdrawExpected)
};

// assert that the beneficiary is AccountKey20
Expand All @@ -254,11 +250,11 @@ impl<'a, Call> XcmConverter<'a, Call> {
beneficiary
{
if network.is_some() && network != &Some(*self.ethereum_network) {
return Err(BeneficiaryResolutionFailed);
return Err(BeneficiaryResolutionFailed)
}
key.into()
} else {
return Err(BeneficiaryResolutionFailed);
return Err(BeneficiaryResolutionFailed)
}
};

Expand All @@ -272,7 +268,7 @@ impl<'a, Call> XcmConverter<'a, Call> {
if let MultiAsset { id: Concrete(location), fun: Fungible(amount) } = asset {
(location, amount)
} else {
return Err(AssetNotConcreteFungible);
return Err(AssetNotConcreteFungible)
};

ensure!(*amount > 0, ZeroAssetTransfer);
Expand All @@ -288,17 +284,17 @@ impl<'a, Call> XcmConverter<'a, Call> {
} = asset_location
{
if gateway_network.is_some() && gateway_network != &Some(*self.ethereum_network) {
return Err(AssetResolutionFailed);
return Err(AssetResolutionFailed)
}
if gateway_address != self.gateway_address {
return Err(AssetResolutionFailed);
return Err(AssetResolutionFailed)
}
if token_network.is_some() && token_network != &Some(*self.ethereum_network) {
return Err(AssetResolutionFailed);
return Err(AssetResolutionFailed)
}
(token_address.into(), *amount)
} else {
return Err(AssetResolutionFailed);
return Err(AssetResolutionFailed)
}
};

Expand Down
2 changes: 1 addition & 1 deletion polkadot-sdk
Submodule polkadot-sdk updated 245 files
42 changes: 0 additions & 42 deletions smoketest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cc9b1fc

Please sign in to comment.