Bridges - Add improved congestion control mechanism#6231
Bridges - Add improved congestion control mechanism#6231
Conversation
|
bot fmt |
659be89 to
b48b8a5
Compare
a663bc2 to
cbc6ae7
Compare
|
bot fmt |
c78f9bc to
501a5c0
Compare
|
bot fmt |
c78e707 to
152389a
Compare
|
bot fmt |
edd9c5c to
38f1bb3
Compare
|
/cmd bench --runtime asset-hub-westend asset-hub-rococo --pallet pallet_xcm_bridge_hub_router |
|
bot bench cumulus-assets --runtime=asset-hub-westend --pallet=pallet_xcm_bridge_hub_router |
f06433a to
d329dec
Compare
|
bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-assets --runtime=asset-hub-westend --pallet=pallet_xcm_bridge_hub_router bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-bridge-hubs --runtime=bridge-hub-rococo --pallet=pallet_bridge_messages |
|
bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-bridge-hubs --runtime=bridge-hub-rococo --pallet=pallet_bridge_messages |
21baa7f to
c00ff6b
Compare
|
bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-bridge-hubs --runtime=bridge-hub-rococo --pallet=pallet_bridge_messages bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-bridge-hubs --subcommand=xcm --runtime=bridge-hub-rococo --pallet=pallet_xcm_benchmarks::generic bot bench -v PIPELINE_SCRIPTS_REF=bko-fix cumulus-assets --runtime=asset-hub-westend --pallet=pallet_xcm_bridge_hub_router |
@serban300 I created separate issue for those comments and they are up to you :)
Let me try to split this big PR, but till that time, please you could help with review for other smaller ones:
Especially, the 8324/8325/8326/8368 could possibly go directly to the master (+backports) |
Fixing #8215 based on #8185: Improve try-state for pallet-xcm-bridge It removes try_as and uses try_into implementation instead. After adding test case where VersionedLocation* to have (XCM_VERSION - 1) is , the test case fails.  After adding the fix, by removing try_as and replacing with try_into, test case passed: 
Fixing #8215 based on #8185: Improve try-state for pallet-xcm-bridge It removes try_as and uses try_into implementation instead. --------- Co-authored-by: Branislav Kontur <[email protected]>
|
/cmd fmt |
| let message_size_factor = | ||
| FixedU128::from_u32(message_size.saturating_div(1024)) | ||
| .saturating_mul(MESSAGE_SIZE_FEE_BASE); | ||
| let total_factor = EXPONENTIAL_FEE_BASE.saturating_add(message_size_factor); | ||
|
|
||
| let previous_factor = bridge_state.delivery_fee_factor; | ||
| bridge_state.delivery_fee_factor = | ||
| bridge_state.delivery_fee_factor.saturating_mul(total_factor); |
There was a problem hiding this comment.
Will integrate the refactored FeeTracker here after we sort out all the other comments related to this pallet.
|
|
||
| // handle congestion and fee factor (if detected) | ||
| Bridges::<T, I>::mutate_exists(&bridge_id, |bridge_state| match bridge_state { | ||
| Some(ref mut bridge_state) if bridge_state.is_congested => { |
There was a problem hiding this comment.
Is is_congested actually needed ? Looks like we could just increase the fee factor here and set it to MINIMAL_DELIVERY_FEE_FACTOR on do_update_bridge_status(is_congested: false).
I'm just wondering if it would be good to have it for the future or for easier tracking of the bridge status.
There was a problem hiding this comment.
Is
is_congestedactually needed ? Looks like we could just increase the fee factor here and set it toMINIMAL_DELIVERY_FEE_FACTORondo_update_bridge_status(is_congested: false).I'm just wondering if it would be good to have it for the future or for easier tracking of the bridge status.
If you check description, there is an open question about changing that bool to BridgeState.
- Report congestion detection uses bool
update_bridge_status(bool), but shouldn't we better send theenum BridgeState {Opened, SoftSuspended, HardSuspended, Closed}? And onHardSuspendedstop thepallet-xcm-bridge-router?
So, if we want to stop the router (and prevent dropping), we need to change bool to BridgeState. But if we don't want to stop the router and only rely on increasing the fee factor, then yes — we don't even need to store is_congested.
@serban300 what do you think and/or suggest?
There was a problem hiding this comment.
Hmmm I don't know what would be best. Thinking.
cc: @serban300 --------- Co-authored-by: Serban Iorga <[email protected]>
The relevant change, which allows us to do dynamic pricing in `pallet-xcm-bridge` based on the router configuration and bridge status: ```rust - /// Price of single message export to the bridged consensus (`Self::BridgedNetwork`). - type MessageExportPrice: Get<Assets>; + /// Price of a single message export to the bridged consensus (`Self::BridgedNetwork`). + type MessageExportPrice: PriceForMessageDelivery<Id = BridgeId>; ``` Basically, with message bridging on AssetHub, the same dynamic price (based on the bridge congestion status) is calculated for exporting either via: - local routing using `ToRococoOverAssetHubRococoXcmRouter` / `ToWestendOverAssetHubWestendXcmRouter` (AH<>AH transfer) - executing `ExportMessage` from a sibling chain. It is just backport of xcm-bridge/xcm-bridge-router stuff from this commit: 8ada805 (where you can see also the real usage and setup) cc: @serban300
Fixing comments in PR #6231 - changed DeliveryFeeFactorUpdated #6231 (comment) - changed Bridges with ValueQuery with defaults #6231 (comment) - updated message_size to be u32 #6231 (comment) --------- Co-authored-by: Branislav Kontur <[email protected]>
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
Closes: #5551
Closes: #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))frompallet-xcm-bridge-hubtopallet-xcm-bridge-hub-router. Depending onis_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
ExportXcmlocally.Description
This PR introduces two new pallets
pallet-xcm-bridgeandpallet-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:
congested_thresholdandstop_threshold).pallet-xcm-bridgeandpallet-xcm-bridge-routernow useBridgeIdto identify specific bridges, enabling selective suspension and resumption of individual bridge channels.pallet-xcm-bridgenow includes callbacks forfn suspend_bridgeandfn resume_bridgebased on congestion status:pallet-xcm-bridges exporter can sendxcm::Transact(update_bridge_status(bridge_id, is_congested))using the stored callback information.pallet-xcm-bridge's exporter manages state directly.stop_thresholdlimit inpallet-xcm-bridgeenables or disablesExportXcm::validate, providing a fallback mechanism when the router does not adhere to thesuspendsignal.pallet-xcm-bridge-routerhas support for message routing for both sibling chains (ExportMessage-ViaRemoteBridgeExporter) and local deployment (ExportXcm-ViaLocalBridgeExporter).Open questions
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 commentupdate_bridge_status(bool), but shouldn't we better send theenum BridgeState {Opened, SoftSuspended, HardSuspended, Closed}? And onHardSuspendedstop thepallet-xcm-bridge-router?