Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Drop error in pre_dispatch (#152) (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest authored Jul 1, 2022
1 parent ff5c90e commit 3f8b687
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ use bp_runtime::{
};
use codec::Encode;
use frame_support::{
dispatch::Dispatchable,
dispatch::{DispatchInfo, DispatchResultWithPostInfo, Dispatchable, Weight},
ensure,
pallet_prelude::Pays,
traits::Get,
weights::GetDispatchInfo,
};
use frame_support::dispatch::{DispatchInfo, DispatchResultWithPostInfo, Weight};
use frame_support::pallet_prelude::Pays;
use frame_system::RawOrigin;
use sp_runtime::traits::{BadOrigin, Convert, IdentifyAccount, MaybeDisplay, Verify, Zero};
use sp_std::{fmt::Debug, prelude::*};
Expand Down Expand Up @@ -164,10 +163,20 @@ impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::BridgeMessageId>
relayer_account: &T::AccountId,
message: Result<&Self::Message, ()>,
) -> Result<(), &'static str> {
let raw_message = message.map_err(|_| "Invalid Message")?;
let call = raw_message.clone().call.into().map_err(|_| "Invalid Call")?;
match message {
Ok(raw_message) =>
if let Ok(call) = raw_message.clone().call.into() {
return T::CallValidator::check_receiving_before_dispatch(relayer_account, &call)
},
Err(_) => {
log::trace!(
target: "runtime::bridge-dispatch",
"Message will be rejected in dispatch, still Ok here",
);
},
}

T::CallValidator::check_receiving_before_dispatch(relayer_account, &call)
Ok(())
}

fn dispatch<P: FnOnce(&T::AccountId, bp_message_dispatch::Weight) -> Result<(), ()>>(
Expand Down Expand Up @@ -379,7 +388,7 @@ fn extract_actual_weight(result: &DispatchResultWithPostInfo, info: &DispatchInf
};
match post_info.pays_fee {
Pays::Yes => post_info.calc_actual_weight(info),
Pays::No => Weight::zero()
Pays::No => Weight::zero(),
}
}

Expand Down

0 comments on commit 3f8b687

Please sign in to comment.