Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Jul 20, 2023
1 parent bdb4f29 commit b83cec7
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 46 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 @@ -27,7 +27,7 @@ impl<T: Config> Verifier for Pallet<T> {
message.proof.block_hash,
err
);
return Err(err)
return Err(err);
},
};

Expand All @@ -46,7 +46,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 @@ -56,7 +56,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 @@ -346,9 +346,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 @@ -366,8 +366,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 @@ -387,12 +387,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 @@ -549,9 +549,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>::ExecutionHeaderSkippedSlot
);

Expand Down Expand Up @@ -595,7 +595,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 @@ -782,13 +782,13 @@ pub mod pallet {
let fork_versions = T::ForkVersions::get();

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/outbound-queue/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ where
Runtime: Config,
{
if !MessageLeaves::<Runtime>::exists() {
return None
return None;
}
let proof = merkle_proof::<<Runtime as Config>::Hashing, _>(
MessageLeaves::<Runtime>::stream_iter(),
Expand Down
10 changes: 5 additions & 5 deletions parachain/pallets/outbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub mod pallet {
Messages::<T>::kill();
MessageLeaves::<T>::kill();
// Reserve some weight for the `on_finalize` handler
return T::WeightInfo::on_finalize()
return T::WeightInfo::on_finalize();
}

fn on_finalize(_: BlockNumberFor<T>) {
Expand Down Expand Up @@ -240,7 +240,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 Down Expand Up @@ -337,14 +337,14 @@ pub mod pallet {
// Yield if we don't want to accept any more messages in the current block.
// There is hard limit to ensure the weight of `on_finalize` is bounded.
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
);

let weight = T::WeightInfo::do_process_message();
if !meter.check_accrue(weight) {
return Err(ProcessMessageError::Overweight(weight))
return Err(ProcessMessageError::Overweight(weight));
}

Self::do_process_message(message)
Expand Down
44 changes: 24 additions & 20 deletions parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,24 @@ where

if network != bridge_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 registry_contract = match registry_location {
X1(AccountKey20 { network, key })
if network.is_none() || network == Some(bridge_network) =>
key,
{
key
},
_ => {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched registry contract {registry_location:?}.");
return Err(SendError::NotApplicable)
return Err(SendError::NotApplicable);
},
};

Expand All @@ -80,14 +82,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 @@ -104,7 +106,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);
}

let params = converted_message.encode();
Expand Down Expand Up @@ -194,7 +196,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 @@ -206,7 +208,9 @@ 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 @@ -219,18 +223,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 benificiary is ethereum account key 20
Expand All @@ -239,11 +243,11 @@ impl<'a, Call> XcmConverter<'a, Call> {
beneficiary
{
if network.is_some() && network != &Some(*self.bridged_location) {
return Err(BeneficiaryResolutionFailed)
return Err(BeneficiaryResolutionFailed);
}
H160(*key)
} else {
return Err(BeneficiaryResolutionFailed)
return Err(BeneficiaryResolutionFailed);
}
};

Expand All @@ -257,7 +261,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 @@ -273,17 +277,17 @@ impl<'a, Call> XcmConverter<'a, Call> {
} = asset_location
{
if registry_network.is_some() && registry_network != &Some(*self.bridged_location) {
return Err(AssetResolutionFailed)
return Err(AssetResolutionFailed);
}
if registry_contract != self.registry_contract {
return Err(AssetResolutionFailed)
return Err(AssetResolutionFailed);
}
if erc20_network.is_some() && erc20_network != &Some(*self.bridged_location) {
return Err(AssetResolutionFailed)
return Err(AssetResolutionFailed);
}
(H160(*erc20_contract), *amount)
} else {
return Err(AssetResolutionFailed)
return Err(AssetResolutionFailed);
}
};

Expand Down

0 comments on commit b83cec7

Please sign in to comment.