Skip to content

Setup permissionless lanes for AssetHubs - heads/state-roots sync#8326

Open
bkontur wants to merge 18 commits intobko-permlanes-on-ahs-2-on-new-headfrom
bko-permlanes-on-ahs-3-heads-sync
Open

Setup permissionless lanes for AssetHubs - heads/state-roots sync#8326
bkontur wants to merge 18 commits intobko-permlanes-on-ahs-2-on-new-headfrom
bko-permlanes-on-ahs-3-heads-sync

Conversation

@bkontur
Copy link
Contributor

@bkontur bkontur commented Apr 24, 2025

Implements: #5827

Relates to: #8325
Relates to: #8324
Relates to: #6675
Relates to: #5827

This PR introduces pallet-bridge-proof-root-sync, which allows scheduling and sending arbitrary data (e.g., para_id/HeadData with state_root) using the on_idle hook.

The pallet implements the OnNewHead hook for new AssetHubRococo parachain heads and is used to send and sync these headers from BridgeHubWestend to AssetHubWestend, where we need to validate message proofs from AssetHubRococo. This header data is sent to the pallet-bridge-proof-root-store deployed on AssetHub see #8324.


Note: This is a phase1 with XCM, later as phase2, we can do this off-chain with proofs, but for that we need: #7445 or other #5827 - for example to add a new extrinsic to pallet-bridge-messages which will have two proofs:

  1. proof of bridged messages with bridged header hash (as we have today)
  2. proof of bridged header hash based on the local relay chain block which proofs local BridgeHub Paras block/state root, for which we can generate proof of local BridgeHub's pallet-bridge-parachains's ImportedParaHeads that it contains bridged header hash / state root

There are multiple alternatives for syncing parachain finality from BridgeHub to AssetHub, collected here: #5827. We chose the XCM approach because it is the simplest and doesn't require additional changes — such as custom RelayChainStateProof data or inherent providers for sibling para heads. Additionally, the pallet-bridge-proof-root-store, implemented as a simple ring buffer, is also useful for D-Day governance.


High-Level Context Diagram

image

@bkontur bkontur added the T15-bridges This PR/Issue is related to bridges. label Apr 24, 2025
@bkontur bkontur changed the title Setup permissionless lanes for AssetHubs - heads/roots sync Setup permissionless lanes for AssetHubs - heads/state-roots sync Apr 24, 2025
@bkontur bkontur moved this to In Progress in @bkontur's board Apr 24, 2025
@bkontur
Copy link
Contributor Author

bkontur commented Apr 24, 2025

/cmd fmt

@bkontur bkontur marked this pull request as ready for review April 29, 2025 11:02
@paritytech-review-bot paritytech-review-bot bot requested a review from a team April 29, 2025 11:03
bkontur added a commit that referenced this pull request May 1, 2025
#8326
#8325

Add proof root sync (`pallet-bridge-proof-root-sync`) as an ring buffer with on_idle callback
Add `OnNewHead` to `pallet-bridge-parachains`
@bkontur bkontur moved this to In-Review in Bridges + XCM May 5, 2025
bkontur added a commit that referenced this pull request May 7, 2025
#8326
#8325

Add proof root sync (`pallet-bridge-proof-root-sync`) as an ring buffer with on_idle callback
Add `OnNewHead` to `pallet-bridge-parachains`
bkontur added a commit that referenced this pull request May 9, 2025
#8326
#8325

Add proof root sync (`pallet-bridge-proof-root-sync`) as an ring buffer with on_idle callback
Add `OnNewHead` to `pallet-bridge-parachains`
github-merge-queue bot pushed a commit that referenced this pull request May 14, 2025
Relates to: #8326
Relates to: #6675

(Extracted from #8325)

This PR introduces a new `OnNewHead` hook for
`pallet-bridge-parachains`, which is triggered when a new parachain head
is relayed.

It will be used in conjunction with the [syncing
mechanism](#8326), which
sends relayed AssetHubRococo headers with `state_root`s to
AssetHubWestend for message proof verification.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left just a few comments.

Overall I think I understood the idea at least for the asset hubs. But it would still be good if we could have a call with the team and if you could give an overview of the entire architecture. I'm not sure if I understand exactly what a non-system parachain would need to do in order to open a bridge and what pallets it needs to deploy. Not sure if it would be exactly like the asset hubs or if it would be different and I would be interested in knowing this in detail.

Anyway, the general feeling is that the configuration is fairly complex.

Comment on lines +158 to +162
// Remove from the front up to the `T::RootsToKeep` limit.
let max = T::RootsToKeep::get();
while roots.len() > (max as usize) {
let _ = roots.pop_front();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw something similar done also in #8324 in do_note_new_roots. Maybe we can deduplicate this.

Comment on lines +87 to +131
impl pallet_bridge_proof_root_sync::OnSend<ParaId, ParaHead> for ToAssetHubRococoProofRootSender {
fn on_send(roots: &Vec<(ParaId, ParaHead)>) {
// For smaller messages, we just send minimal data.
let roots = roots
.iter()
.filter_map(|(id, head)| {
let header: HeaderOf<bp_asset_hub_westend::AssetHubWestend> =
match Decode::decode(&mut &head.0[..]) {
Ok(header) => header,
Err(error) => {
log::warn!(
target: "runtime::bridge-xcm::on-send",
"Failed to decode parachain header - skipping it! head: {:?}, para_id: {:?}, error: {:?}",
head,
id,
error,
);
return None;
},
};
// We just need block_hash and state_root.
Some((header.hash(), *header.state_root()))
})
.collect::<Vec<_>>();

// Send dedicated `Transact` to AHW.
let xcm = Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Xcm,
fallback_max_weight: None,
call: bp_asset_hub_rococo::Call::AssetHubWestendProofRootStore(
bp_asset_hub_rococo::ProofRootStoreCall::note_new_roots {
roots: roots.clone(),
},
)
.encode()
.into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
]);
if let Err(error) = PolkadotXcm::send_xcm(Here, AssetHubLocation::get(), xcm) {
log::warn!(target: "runtime::bridge-xcm::on-send", "Failed to send XCM: {:?}", error);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is duplicated for BHR and BHW. Even though there are some differences, I think some deduplication should be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is duplicated for BHR and BHW. Even though there are some differences, I think some deduplication should be possible.

Yes, thank you, you're right, I did some refactoring and now it is much more simpler now and easy to reuse the same stuff (polkadot-sdk, fellows, ...). Fixed by 8d6f747

@bkontur bkontur force-pushed the bko-permlanes-on-ahs-3-heads-sync branch from 3cf9819 to a246572 Compare May 28, 2025 21:49
@bkontur
Copy link
Contributor Author

bkontur commented Jun 24, 2025

if you could give an overview of the entire architecture.

@serban300 please, I updated description and also attached high-level diagram.

I'm not sure if I understand exactly what a non-system parachain would need to do in order to open a bridge and what pallets it needs to deploy. Not sure if it would be exactly like the asset hubs or if it would be different and I would be interested in knowing this in detail.

The current simplest expectation or assumption is that they could open a bridge/lane directly on the AssetHubs and use ExportMessage from their parachain. Alternatively, they could potentially use pallet-xcm-bridge-router as a SendXcm implementation and run the message relayer for the lane.
Additionally, the pallets (pallet-xcm-bridge, pallet-bridge-messages) could potentially be deployed directly on their parachain, but in that case, they would need to manage pallet-bridge-parachains finality sync themselves. In short, almost everything is possible :)

@bkontur
Copy link
Contributor Author

bkontur commented Jul 21, 2025

Anyway, the general feeling is that the configuration is fairly complex.

@serban300 Please, check now: Fixed by 8d6f747 :)

bkontur added a commit to bkontur/polkadot-sdk that referenced this pull request Jul 24, 2025
paritytech#8326
paritytech#8325

Add proof root sync (`pallet-bridge-proof-root-sync`) as an ring buffer with on_idle callback
Add `OnNewHead` to `pallet-bridge-parachains`
github-merge-queue bot pushed a commit that referenced this pull request Aug 20, 2025
This PR enables `TopicIdTracker` to support multiple flows.

Continues on  #9313
Closes #8676 to fix #8326

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andrii <ndk@parity.io>
@github-project-automation github-project-automation bot moved this from In-Review to Done in Bridges + XCM Aug 20, 2025
@acatangiu acatangiu reopened this Aug 20, 2025
@acatangiu acatangiu moved this from Done to In-Review in Bridges + XCM Aug 20, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/17096087193
Failed job name: fmt

pepoviola pushed a commit that referenced this pull request Aug 26, 2025
This PR enables `TopicIdTracker` to support multiple flows.

Continues on  #9313
Closes #8676 to fix #8326

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andrii <ndk@parity.io>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Relates to: #8326
Relates to: #6675

(Extracted from #8325)

This PR introduces a new `OnNewHead` hook for
`pallet-bridge-parachains`, which is triggered when a new parachain head
is relayed.

It will be used in conjunction with the [syncing
mechanism](#8326), which
sends relayed AssetHubRococo headers with `state_root`s to
AssetHubWestend for message proof verification.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
This PR enables `TopicIdTracker` to support multiple flows.

Continues on  #9313
Closes #8676 to fix #8326

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andrii <ndk@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T15-bridges This PR/Issue is related to bridges.

Projects

Status: In Progress
Status: In-Review
Status: Backlog

Development

Successfully merging this pull request may close these issues.

6 participants