From 389a2ee62ee5c37b4274a22dbd94b38baec0ec1e Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Thu, 19 Oct 2023 14:16:06 +0200 Subject: [PATCH] fixes --- parachain/pallets/control/src/mock.rs | 18 +++---- .../ethereum-beacon-client/src/impls.rs | 8 +-- .../pallets/ethereum-beacon-client/src/lib.rs | 37 +++++++------- .../ethereum-beacon-client/src/mock.rs | 39 +++++---------- parachain/pallets/inbound-queue/src/test.rs | 21 +++----- parachain/pallets/outbound-queue/src/lib.rs | 10 ++-- parachain/pallets/outbound-queue/src/test.rs | 21 +++----- .../primitives/router/src/outbound/mod.rs | 49 ++++++++++--------- 8 files changed, 89 insertions(+), 114 deletions(-) diff --git a/parachain/pallets/control/src/mock.rs b/parachain/pallets/control/src/mock.rs index 916012368c..8dee0c7926 100644 --- a/parachain/pallets/control/src/mock.rs +++ b/parachain/pallets/control/src/mock.rs @@ -14,9 +14,8 @@ use snowbridge_core::{ AgentId, }; use sp_runtime::{ - testing::Header, traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, - AccountId32, + AccountId32, BuildStorage, }; use xcm::prelude::*; use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription}; @@ -24,7 +23,6 @@ use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription}; #[cfg(feature = "runtime-benchmarks")] use crate::BenchmarkHelper; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u128; @@ -86,10 +84,7 @@ mod pallet_xcm_origin { // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -105,24 +100,23 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; + type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; + type Nonce = u64; + type Block = Block; } impl pallet_balances::Config for Test { @@ -209,7 +203,7 @@ impl crate::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext: sp_io::TestExternalities = storage.into(); ext.execute_with(|| { System::set_block_number(1); diff --git a/parachain/pallets/ethereum-beacon-client/src/impls.rs b/parachain/pallets/ethereum-beacon-client/src/impls.rs index fc98a5b2a3..e8ef5bb411 100644 --- a/parachain/pallets/ethereum-beacon-client/src/impls.rs +++ b/parachain/pallets/ethereum-beacon-client/src/impls.rs @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: 2023 Snowfork use super::*; -use frame_support::dispatch::DispatchError; use snowbridge_ethereum::{Log, Receipt}; +use sp_runtime::DispatchError; impl Verifier for Pallet { /// Verify a message by verifying the existence of the corresponding @@ -29,7 +29,7 @@ impl Verifier for Pallet { message.proof.block_hash, err ); - return Err(err) + return Err(err); }, }; @@ -48,7 +48,7 @@ impl Verifier for Pallet { message.proof.block_hash, err ); - return Err(Error::::DecodeFailed.into()) + return Err(Error::::DecodeFailed.into()); }, }; @@ -58,7 +58,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 12f4bb1526..342d64ed47 100644 --- a/parachain/pallets/ethereum-beacon-client/src/lib.rs +++ b/parachain/pallets/ethereum-beacon-client/src/lib.rs @@ -19,9 +19,10 @@ mod tests; mod benchmarking; use frame_support::{ - dispatch::DispatchResult, log, pallet_prelude::OptionQuery, traits::Get, transactional, + dispatch::DispatchResult, pallet_prelude::OptionQuery, traits::Get, transactional, }; use frame_system::ensure_signed; +use log; use primitives::{ fast_aggregate_verify, verify_merkle_branch, verify_receipt_proof, BeaconHeader, BlsError, CompactBeaconState, CompactExecutionHeader, ExecutionHeaderState, ForkData, ForkVersion, @@ -351,9 +352,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(()) @@ -371,8 +372,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. @@ -392,12 +393,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 ); @@ -554,9 +555,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::::ExecutionHeaderSkippedBlock ); @@ -600,7 +601,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()); } }, } @@ -790,13 +791,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 diff --git a/parachain/pallets/ethereum-beacon-client/src/mock.rs b/parachain/pallets/ethereum-beacon-client/src/mock.rs index fd7f9f741b..78e71833be 100644 --- a/parachain/pallets/ethereum-beacon-client/src/mock.rs +++ b/parachain/pallets/ethereum-beacon-client/src/mock.rs @@ -5,10 +5,7 @@ use frame_support::parameter_types; use pallet_timestamp; use primitives::{Fork, ForkVersions}; use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; #[cfg(not(feature = "beacon-spec-mainnet"))] pub mod minimal { @@ -18,17 +15,13 @@ pub mod minimal { use hex_literal::hex; use primitives::CompactExecutionHeader; use snowbridge_core::inbound::{Message, Proof}; + use sp_runtime::BuildStorage; use std::{fs::File, path::PathBuf}; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub enum Test { System: frame_system::{Pallet, Call, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, EthereumBeaconClient: ethereum_beacon_client::{Pallet, Call, Storage, Event}, @@ -48,13 +41,10 @@ pub mod minimal { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); @@ -65,6 +55,8 @@ pub mod minimal { type SystemWeightInfo = (); type SS58Prefix = SS58Prefix; type MaxConsumers = frame_support::traits::ConstU32<16>; + type Nonce = u64; + type Block = Block; } impl pallet_timestamp::Config for Test { @@ -105,9 +97,9 @@ pub mod minimal { // Build genesis storage according to the mock runtime. pub fn new_tester() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| Timestamp::set_timestamp(30_000)); + let _ = ext.execute_with(|| Timestamp::set(RuntimeOrigin::signed(1), 30_000)); ext } @@ -185,15 +177,11 @@ pub mod minimal { pub mod mainnet { use super::*; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; + use sp_runtime::BuildStorage; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub enum Test { System: frame_system::{Pallet, Call, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, EthereumBeaconClient: ethereum_beacon_client::{Pallet, Call, Storage, Event}, @@ -213,13 +201,10 @@ pub mod mainnet { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); @@ -230,6 +215,8 @@ pub mod mainnet { type SystemWeightInfo = (); type SS58Prefix = SS58Prefix; type MaxConsumers = frame_support::traits::ConstU32<16>; + type Nonce = u64; + type Block = Block; } impl pallet_timestamp::Config for Test { @@ -270,9 +257,9 @@ pub mod mainnet { // Build genesis storage according to the mock runtime. pub fn new_tester() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| Timestamp::set_timestamp(30_000)); + let _ = ext.execute_with(|| Timestamp::set(RuntimeOrigin::signed(1), 30_000)); ext } } diff --git a/parachain/pallets/inbound-queue/src/test.rs b/parachain/pallets/inbound-queue/src/test.rs index b667a112a1..202acf1ef9 100644 --- a/parachain/pallets/inbound-queue/src/test.rs +++ b/parachain/pallets/inbound-queue/src/test.rs @@ -3,15 +3,12 @@ use super::*; use frame_support::{ - assert_noop, assert_ok, - dispatch::DispatchError, - parameter_types, + assert_noop, assert_ok, parameter_types, traits::{ConstU64, Everything}, }; use sp_core::{H160, H256}; use sp_keyring::AccountKeyring as Keyring; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, ArithmeticError, MultiSignature, }; @@ -24,20 +21,17 @@ use snowbridge_core::{ }; use snowbridge_ethereum::Log; use snowbridge_router_primitives::inbound::MessageToXcm; +use sp_runtime::{BuildStorage, DispatchError}; use hex_literal::hex; use xcm::v3::{prelude::*, MultiAssets, SendXcm}; use crate::{self as inbound_queue, envelope::Envelope, Error, Event as InboundQueueEvent}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -59,13 +53,10 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -78,6 +69,8 @@ impl frame_system::Config for Test { type SS58Prefix = (); type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; + type Nonce = u64; + type Block = Block; } impl pallet_balances::Config for Test { @@ -164,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())) }, @@ -207,7 +200,7 @@ fn expect_events(e: Vec) { } pub fn new_tester() -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext: sp_io::TestExternalities = storage.into(); ext.execute_with(|| System::set_block_number(1)); ext diff --git a/parachain/pallets/outbound-queue/src/lib.rs b/parachain/pallets/outbound-queue/src/lib.rs index 4295205d19..e63b2d4c1f 100644 --- a/parachain/pallets/outbound-queue/src/lib.rs +++ b/parachain/pallets/outbound-queue/src/lib.rs @@ -221,7 +221,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 @@ -348,14 +348,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)) + if meter.try_consume(weight).is_err() { + return Err(ProcessMessageError::Overweight(weight)); } Self::do_process_message(message) diff --git a/parachain/pallets/outbound-queue/src/test.rs b/parachain/pallets/outbound-queue/src/test.rs index 4a3f7a3fe2..7fc6c4539e 100644 --- a/parachain/pallets/outbound-queue/src/test.rs +++ b/parachain/pallets/outbound-queue/src/test.rs @@ -11,21 +11,16 @@ use frame_support::{ use snowbridge_core::outbound::{Command, Initializer}; use sp_core::{ConstU128, H160, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup, Keccak256}, - AccountId32, BoundedVec, + AccountId32, BoundedVec, BuildStorage, }; use sp_std::convert::From; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type AccountId = AccountId32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, @@ -43,13 +38,10 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -62,6 +54,8 @@ impl frame_system::Config for Test { type SS58Prefix = (); type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; + type Nonce = u64; + type Block = Block; } parameter_types! { @@ -79,6 +73,7 @@ impl pallet_message_queue::Config for Test { type HeapSize = HeapSize; type MaxStale = MaxStale; type ServiceWeight = ServiceWeight; + type QueuePausedQuery = (); } parameter_types! { @@ -105,7 +100,7 @@ fn setup() { } pub fn new_tester() -> sp_io::TestExternalities { - let storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let mut ext: sp_io::TestExternalities = storage.into(); ext.execute_with(|| setup()); ext @@ -227,7 +222,7 @@ fn process_message_yields_on_max_messages_per_block() { let message = (0..100).map(|_| 1u8).collect::>(); let message: BoundedVec> = message.try_into().unwrap(); - let mut meter = WeightMeter::max_limit(); + let mut meter = WeightMeter::new(); assert_noop!( OutboundQueue::process_message( @@ -248,7 +243,7 @@ fn process_message_fails_on_overweight_message() { let message = (0..100).map(|_| 1u8).collect::>(); let message: BoundedVec> = message.try_into().unwrap(); - let mut meter = WeightMeter::from_limit(Weight::from_parts(1, 1)); + let mut meter = WeightMeter::with_limit(Weight::from_parts(1, 1)); assert_noop!( OutboundQueue::process_message( diff --git a/parachain/primitives/router/src/outbound/mod.rs b/parachain/primitives/router/src/outbound/mod.rs index 081037af52..8cb7ed78a5 100644 --- a/parachain/primitives/router/src/outbound/mod.rs +++ b/parachain/primitives/router/src/outbound/mod.rs @@ -5,7 +5,8 @@ use core::slice::Iter; use codec::{Decode, Encode}; -use frame_support::{ensure, log, traits::Get}; +use frame_support::{ensure, traits::Get}; +use log; use snowbridge_core::outbound::{ AgentExecuteCommand, Command, Message, OutboundQueue as OutboundQueueTrait, }; @@ -50,22 +51,24 @@ 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); }, }; @@ -83,14 +86,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); }, }; @@ -107,7 +110,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. @@ -116,7 +119,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); }, }; @@ -204,7 +207,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)) @@ -216,7 +219,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, @@ -229,18 +234,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 @@ -249,11 +254,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); } }; @@ -267,7 +272,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); @@ -283,17 +288,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); } };