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

Should we drop the transfer error FromBridgedChainMessageDispatch dispatch? #103

Closed
boundless-forest opened this issue Jun 1, 2022 · 3 comments

Comments

@boundless-forest
Copy link
Member

fn dispatch(
    relayer_account: &AccountIdOf<ThisChain<B>>,
    message: DispatchMessage<Self::DispatchPayload, BalanceOf<BridgedChain<B>>>,
) -> MessageDispatchResult {
    let message_id = (message.key.lane_id, message.key.nonce);
    pallet_bridge_dispatch::Pallet::<ThisRuntime, ThisDispatchInstance>::dispatch(
        B::BRIDGED_CHAIN_ID,
        B::THIS_CHAIN_ID,
        message_id,
        message.data.payload.map_err(drop),
        |dispatch_origin, dispatch_weight| {
            let unadjusted_weight_fee = ThisRuntime::WeightToFee::calc(&dispatch_weight);
            let fee_multiplier =
                pallet_transaction_payment::Pallet::<ThisRuntime>::next_fee_multiplier();
            let adjusted_weight_fee =
                fee_multiplier.saturating_mul_int(unadjusted_weight_fee);
            if !adjusted_weight_fee.is_zero() {
                ThisCurrency::transfer(
                    dispatch_origin,
                    relayer_account,
                    adjusted_weight_fee,
                    ExistenceRequirement::AllowDeath,
                )
                .map_err(drop) // here
            } else {
                Ok(())
            }
        },
    )
}
@boundless-forest boundless-forest changed the title Should we drop the transfer error FromBridgedChainMessageDispatch dispatch Should we drop the transfer error FromBridgedChainMessageDispatch dispatch? Jun 1, 2022
@wuminzhe
Copy link
Collaborator

wuminzhe commented Jun 2, 2022

the .map_err(drop) will return Err(()), so, if the dispatch_origin has no enough balance, the dispatch will fail.

@hackfisher
Copy link
Contributor

hackfisher commented Jun 8, 2022

As described in #107, non evm.transact do not need pay_dispatch_fee customization, and message.dispatch_fee_payment == DispatchFeePayment::AtSourceChain.

We should not use the default FromBridgedChainMessageDispatch from runtime common, and impl it in specific runtime.

@hackfisher
Copy link
Contributor

Will be fixed by darwinia-network/darwinia#905

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants