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

Introduce a check for replayer's can withdraw balance in MessageDispatch trait #134

Closed
hackfisher opened this issue Jun 16, 2022 · 2 comments
Assignees
Labels

Comments

@hackfisher
Copy link
Contributor

Another problem here is that, if the relayer have no enough funds for paying to the dispatch origin, and we ignore it here, this message will probably be fail as a result.

But it does not make sense, because the message sender paid enough fees in source chain, the message is unluckily failed just because some relayer's fault.

Solution:

We might need to introduce another check before dispatch, to make sure this relayer have enough funds for this pre_dispatch, otherwise, an invalid ReceivalResult should be returned before dispatch.

https://github.com/darwinia-network/darwinia-messages-substrate/blob/main/modules/messages/src/lib.rs#L461-L471

https://github.com/darwinia-network/darwinia-messages-substrate/blob/main/modules/messages/src/inbound_lane.rs#L134-L142

I'll create an issue in repo darwinia-messages-substrate for fixing before continue.

And here, we should remove if condition, and return Err if transfer failed.

Originally posted by @hackfisher in darwinia-network/darwinia-common#1267 (comment)

@hackfisher
Copy link
Contributor Author

But one more thing need to note here is that, one single message should not block latter messages.

minimum_required_balance(relayer_on_target_chain) -> Balances { min(MAX_REQUIRED_RELAYER_BALNCE, gas_price * gas_limit / 10 ** 9) }

So the check here for relayer's balance should be

relayer's balance > minimum_required_balance(relayer)

If the gas_price * gas_limit are set too large by message sender, larger than MAX_REQUIRED_RELAYER_BALANCE, then it is not the relayer's fault if this message is failed in validation/pre-dispatch.

@boundless-forest
Copy link
Member

#137 Close this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Status: No status
Status: Done/No Companion
Development

No branches or pull requests

3 participants
@hackfisher @boundless-forest and others