diff --git a/parachain/pallets/control/Cargo.toml b/parachain/pallets/control/Cargo.toml index 7ff5ff7aaf..e1e61f6825 100644 --- a/parachain/pallets/control/Cargo.toml +++ b/parachain/pallets/control/Cargo.toml @@ -32,7 +32,7 @@ xcm = { git = "https://github.com/paritytech/polkadot.git", branch = "master", d ethabi = { git = "https://github.com/Snowfork/ethabi-decode.git", package = "ethabi-decode", branch = "master", default-features = false } [dev-dependencies] -xcm-builder = { git = "https://github.com/paritytech/polkadot.git", branch = "master" } +xcm-builder = { git = "https://github.com/paritytech/polkadot.git", branch = "master", default-features = false } [features] default = ["std"] @@ -47,6 +47,7 @@ std = [ "sp-io/std", "sp-runtime/std", "xcm/std", + "xcm-builder/std", "ethabi/std" ] runtime-benchmarks = [ diff --git a/parachain/pallets/control/src/lib.rs b/parachain/pallets/control/src/lib.rs index d058551e22..92e3c9a084 100644 --- a/parachain/pallets/control/src/lib.rs +++ b/parachain/pallets/control/src/lib.rs @@ -23,6 +23,7 @@ use snowbridge_core::{Command, OutboundMessage, OutboundQueue as OutboundQueueTr use sp_core::{H160, H256}; use sp_runtime::traits::Hash; use sp_std::prelude::*; +use xcm::prelude::*; pub use pallet::*; @@ -31,7 +32,6 @@ pub mod pallet { use super::*; use frame_support::{pallet_prelude::*, traits::EnsureOrigin}; use frame_system::pallet_prelude::*; - use xcm::v3::MultiLocation; #[pallet::pallet] pub struct Pallet(_); diff --git a/parachain/pallets/ethereum-beacon-client/src/impls.rs b/parachain/pallets/ethereum-beacon-client/src/impls.rs index 1639062f96..e5f93325fe 100644 --- a/parachain/pallets/ethereum-beacon-client/src/impls.rs +++ b/parachain/pallets/ethereum-beacon-client/src/impls.rs @@ -27,7 +27,7 @@ impl Verifier for Pallet { message.proof.block_hash, err ); - return Err(err) + return Err(err); }, }; @@ -46,7 +46,7 @@ impl Verifier for Pallet { message.proof.block_hash, err ); - return Err(Error::::DecodeFailed.into()) + return Err(Error::::DecodeFailed.into()); }, }; @@ -56,7 +56,7 @@ impl Verifier for Pallet { "💫 Event log not found in receipt for transaction at index {} in block {}", message.proof.tx_index, message.proof.block_hash, ); - return Err(Error::::InvalidProof.into()) + return Err(Error::::InvalidProof.into()); } log::info!( diff --git a/parachain/pallets/ethereum-beacon-client/src/lib.rs b/parachain/pallets/ethereum-beacon-client/src/lib.rs index b099838857..d667ee1a29 100644 --- a/parachain/pallets/ethereum-beacon-client/src/lib.rs +++ b/parachain/pallets/ethereum-beacon-client/src/lib.rs @@ -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::::ExecutionHeaderTooFarBehind ); Ok(()) @@ -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::::InvalidUpdateSlot ); // Retrieve latest finalized state. @@ -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 = !>::exists() && - (update.next_sync_committee_update.is_some() && - update_attested_period == store_period); + let update_has_next_sync_committee = !>::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::::IrrelevantUpdate ); @@ -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::::ExecutionHeaderSkippedSlot ); @@ -595,7 +595,7 @@ pub mod pallet { let state = >::get(block_root) .ok_or(Error::::ExpectedFinalizedHeaderNotStored)?; if update.header.slot != state.slot { - return Err(Error::::ExpectedFinalizedHeaderNotStored.into()) + return Err(Error::::ExpectedFinalizedHeaderNotStored.into()); } }, } @@ -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 diff --git a/parachain/pallets/outbound-queue/src/api.rs b/parachain/pallets/outbound-queue/src/api.rs index 312f7f1d88..5cbe7cebb8 100644 --- a/parachain/pallets/outbound-queue/src/api.rs +++ b/parachain/pallets/outbound-queue/src/api.rs @@ -12,7 +12,7 @@ where Runtime: Config, { if !MessageLeaves::::exists() { - return None + return None; } let proof = merkle_proof::<::Hashing, _>( MessageLeaves::::stream_iter(), diff --git a/parachain/pallets/outbound-queue/src/lib.rs b/parachain/pallets/outbound-queue/src/lib.rs index fd7957c733..e5dcc02c73 100644 --- a/parachain/pallets/outbound-queue/src/lib.rs +++ b/parachain/pallets/outbound-queue/src/lib.rs @@ -198,7 +198,7 @@ pub mod pallet { Messages::::kill(); MessageLeaves::::kill(); // Reserve some weight for the `on_finalize` handler - return T::WeightInfo::on_finalize() + return T::WeightInfo::on_finalize(); } fn on_finalize(_: BlockNumberFor) { @@ -240,7 +240,7 @@ pub mod pallet { pub(crate) fn commit_messages() { let count = MessageLeaves::::decode_len().unwrap_or_default() as u64; if count == 0 { - return + return; } // Create merkle root of messages @@ -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::::decode_len().unwrap_or(0) < - T::MaxMessagesPerBlock::get() as usize, + MessageLeaves::::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) diff --git a/parachain/primitives/router/src/outbound/mod.rs b/parachain/primitives/router/src/outbound/mod.rs index 402b0fd424..50064a05a3 100644 --- a/parachain/primitives/router/src/outbound/mod.rs +++ b/parachain/primitives/router/src/outbound/mod.rs @@ -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); }, }; @@ -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); }, }; @@ -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(); @@ -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)) @@ -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, @@ -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 @@ -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); } }; @@ -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); @@ -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); } };