Skip to content

feat: hyperbridge token gateway - #1122

Merged
mrq1911 merged 63 commits into
masterfrom
feat/hyperbridge
Oct 16, 2025
Merged

feat: hyperbridge token gateway#1122
mrq1911 merged 63 commits into
masterfrom
feat/hyperbridge

Conversation

@F3Joule

@F3Joule F3Joule commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

Description

This PR integrates Hyperbridge and ISMP into the Hydration runtime to enable cross-chain messaging and token gateway functionality.

Key changes:

ISMP Integration:

  • Added pallet_ismp with IsmpParachain, TokenGateway, and Hyperbridge configs.
  • Implemented IsmpRouter and new runtime APIs (IsmpRuntimeApi, IsmpParachainApi).

Token Gateway:

  • Introduced pallet_token_gateway with hooks (on_accept, on_response, on_timeout).
  • Added benchmarks for token gateway ISMP Module implementation.

Miscellaneous:

  • Added benchmarking modules and weights for new pallets.
  • Implemented fungibles::metadata for FungibleCurrencies.

Related Issue

#1112

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown

Crate versions that have been updated:

  • hydradx: v14.4.2 -> v14.5.0
  • pallet-circuit-breaker: v1.2.2 -> v1.2.3
  • pallet-currencies: v3.2.0 -> v3.3.0
  • pallet-dca: v1.9.4 -> v1.9.5
  • pallet-duster: v3.3.1 -> v3.3.2
  • pallet-dynamic-evm-fee: v1.1.0 -> v1.1.1
  • pallet-liquidation: v1.4.1 -> v1.4.2
  • pallet-otc: v2.1.7 -> v2.1.8
  • pallet-otc-settlements: v1.1.9 -> v1.1.10
  • pallet-route-executor: v2.10.1 -> v2.10.2
  • pallet-transaction-multi-payment: v10.1.6 -> v10.1.7
  • primitives: v6.1.2 -> v6.1.3
  • runtime-mock: v1.0.8 -> v1.0.9
  • hydradx-adapters: v1.9.1 -> v1.9.2
  • hydradx-runtime: v350.0.0 -> v351.0.0

Runtime version has been increased.

@F3Joule F3Joule self-assigned this Jul 4, 2025
Comment thread pallets/token-gateway/src/lib.rs Outdated
@mrq1911 mrq1911 mentioned this pull request Oct 10, 2025
@github-actions

Copy link
Copy Markdown

Quick benchmark at commit 993f2d1 has been executed successfully.
View results

Comment on lines +145 to +149
if let Some(name) = T::RegistryInspect::asset_name(asset) {
name
} else {
Vec::new()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if let Some(name) = T::RegistryInspect::asset_name(asset) {
name
} else {
Vec::new()
}
T::RegistryInspect::asset_name(asset).unwrap_or_default()

Comment on lines +153 to +157
if let Some(sym) = T::RegistryInspect::asset_symbol(asset) {
sym
} else {
Vec::new()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/currencies"
license = "Apache-2.0"
version = "3.2.0"
version = "3.3.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

4.0.0 - pallet's config changed, breaking api

Comment on lines +47 to +53
// #[benchmarks(
// where
// T: pallet_ismp::Config + pallet_token_gateway::Config,
// )]
// mod benchmarks {
// use super::*;
//

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove commented out code , if not used


impl ismp_parachain::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// pallet-ismp implements the IsmpHost

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i dont think this comment helps much. can be removed

Comment on lines +24 to +25
alloy-primitives = { workspace = true }
alloy-sol-types = { workspace = true }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this used at all? i cant find any usage

pallet-token-gateway = { workspace = true }
ismp-parachain = { workspace = true }
ismp = { workspace = true }
anyhow = { workspace = true }

@enthusiastmartin enthusiastmartin Oct 15, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

used anywhere ? the anyhow crate

Comment thread Cargo.toml
Comment on lines +63 to +65
alloy-primitives = { version = "0.7", default-features = false }
alloy-sol-types = { version = "0.7", default-features = false }
anyhow = { version = "1.0", default-features = false }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure if needed. could not find any usage. if not, remove.

@enthusiastmartin enthusiastmartin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

resolve last comments first

@mrq1911 mrq1911 changed the title feat: add ismp and hyperbridge feat: hyperbridge & ismp Oct 16, 2025
@mrq1911 mrq1911 changed the title feat: hyperbridge & ismp feat: hyperbridge token gateway Oct 16, 2025
@mrq1911
mrq1911 requested a review from Copilot October 16, 2025 11:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates Hyperbridge and ISMP into the Hydration runtime to enable cross-chain messaging and token gateway functionality. The integration adds new pallets for ISMP message routing, token gateway operations, and parachain consensus handling.

Key Changes:

  • Added ISMP core pallets (pallet_ismp, pallet_hyperbridge, pallet_token_gateway, ismp_parachain) with runtime APIs and configuration
  • Implemented benchmarking infrastructure for ISMP module handlers with custom weight template
  • Extended FungibleCurrencies to implement fungibles::metadata trait for asset metadata inspection

Reviewed Changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
runtime/hydradx/src/lib.rs Added Hyperbridge pallets to runtime, incremented spec_version, and implemented ISMP runtime APIs
runtime/hydradx/src/hyperbridge.rs Configured ISMP, token gateway, and hyperbridge pallets with routing and weight providers
runtime/hydradx/src/benchmarking/token_gateway_ismp.rs Implemented benchmarks for token gateway ISMP module handlers (on_accept, on_response, on_timeout)
pallets/currencies/src/fungibles.rs Added fungibles::metadata::Inspect implementation for FungibleCurrencies
pallets/currencies/src/lib.rs Added RegistryInspect associated type to Config trait
scripts/benchmarking.sh Updated to handle ISMP module benchmarks with custom template
scripts/ismp-module-weight-template.hbs Added custom Handlebars template for ISMP module weight generation
runtime/hydradx/src/weights/*.rs Auto-generated weight files for new pallets
node/src/service.rs Integrated ISMP consensus inherent data provider into block production
node/src/rpc.rs Added ISMP RPC handler to runtime API
node/src/command.rs Enabled offchain indexing for non-authority nodes to store ISMP data
Cargo.toml Added Hyperbridge dependencies from polytope-labs repository

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +47 to +97
// #[benchmarks(
// where
// T: pallet_ismp::Config + pallet_token_gateway::Config,
// )]
// mod benchmarks {
// use super::*;
//
// #[benchmark]
// fn tg_on_accept() {
// // Environment
// let source = StateMachine::Evm(100);
// let dest = host_state_machine();
// let nonce: u64 = 1;
//
// // Configure TokenGateway address for the source chain to pass origin check
// let module_addr: Vec<u8> = b"tg-address".to_vec();
// tg::TokenGatewayAddresses::<T>::insert(source, module_addr.clone());
//
// // Use the native asset id in runtime
// let local_asset_id = <T as tg::Config>::NativeAssetId::get();
// let remote_asset_id = H256::repeat_byte(7u8);
// setup_mappings(local_asset_id.clone(), remote_asset_id, source);
//
// // Beneficiary is derived from Body.to
// let beneficiary_bytes = [2u8; 32];
// let amount_u256 = AlloyU256::from(1_000u64);
// let body = Body {
// amount: amount_u256,
// asset_id: FixedBytes::<32>::from_slice(remote_asset_id.as_fixed_bytes()),
// redeem: false,
// from: FixedBytes::<32>::from([1u8; 32]),
// to: FixedBytes::<32>::from(beneficiary_bytes),
// };
// let encoded_body = encode_body(body);
//
// let post = PostRequest {
// source,
// dest,
// nonce,
// from: module_addr,
// to: Vec::new(),
// timeout_timestamp: 0,
// body: encoded_body,
// };
//
// #[block]
// {
// tg::Pallet::<T>::default().on_accept(post).unwrap()
// }
// }
// }

Copilot AI Oct 16, 2025

Copy link

Choose a reason for hiding this comment

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

Large block of commented-out code (lines 47-97) should be removed. If this alternate implementation is needed for future reference, it should be preserved in version control history rather than as commented code.

Copilot uses AI. Check for mistakes.

@cl0w5 cl0w5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@mrq1911
mrq1911 merged commit 7ef2be2 into master Oct 16, 2025
11 checks passed
@mrq1911

mrq1911 commented Oct 16, 2025

Copy link
Copy Markdown
Member

@enthusiastmartin @F3Joule merged, the nitpick stuff will have to be resolved separately ;)

@cl0w5
cl0w5 deleted the feat/hyperbridge branch October 18, 2025 09:22
@enthusiastmartin enthusiastmartin added this to the 42 milestone Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants