feat: hyperbridge token gateway - #1122
Conversation
w/ cargo update -p smoldot --precise 0.11.0
w/ cargo update -p anyhow --precise 1.0.98
|
Crate versions that have been updated:
Runtime version has been increased. |
Update Cargo.lock
Update Cargo.lock
# Conflicts: # Cargo.lock # Cargo.toml # runtime/hydradx/src/lib.rs
|
Quick benchmark at commit 993f2d1 has been executed successfully. |
| if let Some(name) = T::RegistryInspect::asset_name(asset) { | ||
| name | ||
| } else { | ||
| Vec::new() | ||
| } |
There was a problem hiding this comment.
| if let Some(name) = T::RegistryInspect::asset_name(asset) { | |
| name | |
| } else { | |
| Vec::new() | |
| } | |
| T::RegistryInspect::asset_name(asset).unwrap_or_default() |
| if let Some(sym) = T::RegistryInspect::asset_symbol(asset) { | ||
| sym | ||
| } else { | ||
| Vec::new() | ||
| } |
| 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" |
There was a problem hiding this comment.
4.0.0 - pallet's config changed, breaking api
| // #[benchmarks( | ||
| // where | ||
| // T: pallet_ismp::Config + pallet_token_gateway::Config, | ||
| // )] | ||
| // mod benchmarks { | ||
| // use super::*; | ||
| // |
There was a problem hiding this comment.
remove commented out code , if not used
|
|
||
| impl ismp_parachain::Config for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| // pallet-ismp implements the IsmpHost |
There was a problem hiding this comment.
i dont think this comment helps much. can be removed
| alloy-primitives = { workspace = true } | ||
| alloy-sol-types = { workspace = true } |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
used anywhere ? the anyhow crate
| alloy-primitives = { version = "0.7", default-features = false } | ||
| alloy-sol-types = { version = "0.7", default-features = false } | ||
| anyhow = { version = "1.0", default-features = false } |
There was a problem hiding this comment.
not sure if needed. could not find any usage. if not, remove.
enthusiastmartin
left a comment
There was a problem hiding this comment.
resolve last comments first
There was a problem hiding this comment.
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
FungibleCurrenciesto implementfungibles::metadatatrait 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.
| // #[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() | ||
| // } | ||
| // } | ||
| // } |
There was a problem hiding this comment.
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.
|
@enthusiastmartin @F3Joule merged, the nitpick stuff will have to be resolved separately ;) |
Description
This PR integrates Hyperbridge and ISMP into the Hydration runtime to enable cross-chain messaging and token gateway functionality.
Key changes:
ISMP Integration:
pallet_ismpwith IsmpParachain, TokenGateway, and Hyperbridge configs.Token Gateway:
pallet_token_gatewaywith hooks (on_accept, on_response, on_timeout).Miscellaneous:
fungibles::metadataforFungibleCurrencies.Related Issue
#1112