-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better bridge asset transfer user fees #2434
Comments
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/bridge-hub-questions/2693/2 |
Sorry for the late response. Yeah this is a tricky one. I agree dynamic fees will ultimately be necessary. Looking at the three queues, I think we could handle it for DOT/KSM being transferred over the bridge, but it will be more difficult with other messages. In the case Statemine to mint:
|
Background
The current general idea of how assets are transferred over the bridge is described below. Let's say it is for the bridge between Statemint (Polkadot parachain) and Statemine (Kusama parachain):
transfer_asset_via_bridge()
function of the pallet. Part of this call is taking fees - so user pays fees on the source parachain (not at bridge hubs). Right now the plan is that it'll be the constant, which eventually may be updated by governance or something like that. We need to figure out how to calculate this constant fee;pallet-bridge-relayers
on both sides bridge hubs, so they can claim it anytime.So we assume that Statemint will have a sovereign account at the Kusama Bridge Hub and Statemine will have a sovereign account at the Polkadot Bridge Hub. These accounts are used to pay registered rewards to relayers. Accounts eventually need be topped up by Statemint/Statemine bridge maintainers.
Issue/Task
This issue focuses on the fee in point 2) above.
A concern was raised that a constant fee is likely not enough, as it would allow an attacker to enqueue thousands of messages and thus create a considerable delay in message delivery. This could be abused for intentional DoS by temporarily stalling a bridge lane/delaying messages in order to slow down automatic arbitration systems and gain an unfair advantage.
Dynamic fees
One idea is to implement some form of dynamic fees similar to what is implemented in paritytech/polkadot#6843 for DMP. That way sending messages gets (exponentially) more expensive if the queue size (number of messages and/or cumulative size of all messages in queue) exceeds a threshold. This will effectively limit the queue length and therefore the delay an attacker can cause by spamming the system. When having a dynamic fee system, it is also possible to adjust fees so that the sovereign account used for relayer rewards gets sufficiently funded (may require using the dex pallet to exchange between DOT and KSM so that the rewards on the other side can be paid).
From technical point of view, we have our own challenges regarding this exponential approach. We have 3 queueus in the bridge (Statemine
<XCMP queue>
BHK<bridge queue>
BHP<XCMP queue>
Statemint). So we don't have access to "number of queued messages" at the source parachain.We may say that the whole bridge throughput is, say 10 messages per block and then we can exponentially increase cost if we see that the number of outbound messages overflows this limit.
Constant fees
We may also decide that a constant fee is enough for the first iteration of the bridge where being able to transfer assets between Statemint and Statemine is all we target.
In this case we would have to document and warn users that the bridge should not be used for low-latency arbitrage purposes.
How to calculate fee
In either case, we need to find the base value of this fee paid by users at Statemint/Statemine when doing asset transfers between them.
@joepetrowski ^
The text was updated successfully, but these errors were encountered: