polkadot-sdk
polkadot-sdk copied to clipboard
Bridges - Add improved congestion control mechanism
Closes: https://github.com/paritytech/polkadot-sdk/issues/5551 Closes: https://github.com/paritytech/polkadot-sdk/issues/5550
Context
Before permissionless lanes, bridges only supported hard-coded, static lanes. The congestion mechanism was based on sending Transact(report_bridge_status(is_congested)) from pallet-xcm-bridge-hub to pallet-xcm-bridge-hub-router. Depending on is_congested, we adjusted the fee factor to increase or decrease fees. This congestion mechanism relied on monitoring XCMP queues, which could cause issues like suspending the entire XCMP queue rather than just the affected bridge.
Additionally, we are progressing with deploying bridge message pallets/routing directly on AssetHub, where we don’t interact with XCMP to perform ExportXcm locally.
Description
This PR introduces two new pallets pallet-xcm-bridge and pallet-xcm-bridge-router. These pallets are designed to improve congestion handling for bridges. The main objective of this PR is to enhance the routing and management of messages between chains.
This PR re-introduces and improves congestion for bridges:
- Enhanced Bridge Congestion Mechanism: The bridge queue mechanism has been restructured to operate independently of XCMP, with a refined protocol for congestion detection and suspension management (
congested_thresholdandstop_threshold). - Bridge-Specific Channel Suspension:
pallet-xcm-bridgeandpallet-xcm-bridge-routernow useBridgeIdto identify specific bridges, enabling selective suspension and resumption of individual bridge channels. - Dynamic Congestion Detection:
pallet-xcm-bridgenow includes callbacks forfn suspend_bridgeandfn resume_bridgebased on congestion status:- For sibling chains, the
pallet-xcm-bridges exporter can sendxcm::Transact(update_bridge_status(bridge_id, is_congested))using the stored callback information. - For local chain deployments, the
pallet-xcm-bridge's exporter manages state directly.
- For sibling chains, the
- New Stop Threshold: A
stop_thresholdlimit inpallet-xcm-bridgeenables or disablesExportXcm::validate, providing a fallback mechanism when the router does not adhere to thesuspendsignal. - Flexible Message Routing:
pallet-xcm-bridge-routerhas support for message routing for both sibling chains (ExportMessage-ViaRemoteBridgeExporter) and local deployment (ExportXcm-ViaLocalBridgeExporter).
Open questions
- [ ] when the router receives
is_congested = falsewithfn do_update_bridge_status(, can we directly remove it (its fee factor) fromBridgesand the next message fee wont be affected by increased fee factor or slowly start decreasing fee factor on idle (this is how it is implemented now)? Original comment