Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sibling location #1077

Merged
merged 9 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ contract Gateway is IGateway, IInitializable {
bytes4 internal immutable BRIDGE_HUB_PARA_ID_ENCODED;
bytes32 internal immutable BRIDGE_HUB_AGENT_ID;

// AssetHub
ParaID internal immutable ASSET_HUB_PARA_ID;
bytes32 internal immutable ASSET_HUB_AGENT_ID;

// ChannelIDs
ChannelID internal constant PRIMARY_GOVERNANCE_CHANNEL_ID = ChannelID.wrap(bytes32(uint256(1)));
ChannelID internal constant SECONDARY_GOVERNANCE_CHANNEL_ID = ChannelID.wrap(bytes32(uint256(2)));
Expand Down
7 changes: 3 additions & 4 deletions parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ where
SendError::Unroutable
})?;

// local_sub is relative to the relaychain. No conversion needed.
let local_sub_location: MultiLocation = local_sub.into();
let agent_id = match AgentHashedDescription::convert_location(&local_sub_location) {
let source_location: MultiLocation = MultiLocation { parents: 1, interior: local_sub };
let agent_id = match AgentHashedDescription::convert_location(&source_location) {
Some(id) => id,
None => {
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{local_sub_location:?}'");
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{source_location:?}'");
return Err(SendError::Unroutable)
},
};
Expand Down
34 changes: 32 additions & 2 deletions parachain/primitives/router/src/outbound/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use frame_support::parameter_types;
use hex_literal::hex;
use snowbridge_core::outbound::{Fee, SendError, SendMessageFeeProvider};
use snowbridge_core::{
outbound::{Fee, SendError, SendMessageFeeProvider},
DescribeHere,
};

use xcm::v3::prelude::SendError as XcmSendError;
use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription};

pub type AgentIdOf = HashedDescription<H256, DescribeFamily<DescribeAllTerminal>>;
pub type AgentIdOf = HashedDescription<H256, (DescribeHere, DescribeFamily<DescribeAllTerminal>)>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're also repeating this line in the BridgeHub xcm_config.rs configuration, can you check?

In which case we should factor out both definitions into our parachain/runtime/runtime-common crate.

Copy link
Contributor Author

@yrong yrong Dec 21, 2023

Choose a reason for hiding this comment

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

Yeah, several duplications and refactoring with 8c1d1d8

Btw, prefer to move to primitives as it's very low level and not only used in runtime.


use super::*;

Expand Down Expand Up @@ -1035,3 +1038,30 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_
let result = converter.convert();
assert_eq!(result.err(), Some(XcmConverterError::BeneficiaryResolutionFailed));
}

#[test]
fn test_describe_asset_hub() {
let legacy_location: MultiLocation =
MultiLocation { parents: 0, interior: X1(Parachain(1000)) };
let legacy_agent_id = AgentIdOf::convert_location(&legacy_location).unwrap();
assert_eq!(
legacy_agent_id,
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4").into()
);
let location: MultiLocation = MultiLocation { parents: 1, interior: X1(Parachain(1000)) };
let agent_id = AgentIdOf::convert_location(&location).unwrap();
assert_eq!(
agent_id,
hex!("81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79").into()
)
}

#[test]
fn test_describe_here() {
let location: MultiLocation = MultiLocation { parents: 0, interior: Here };
let agent_id = AgentIdOf::convert_location(&location).unwrap();
assert_eq!(
agent_id,
hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into()
)
}
2 changes: 1 addition & 1 deletion smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const BRIDGE_HUB_AGENT_ID: [u8; 32] =
hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314");
// Agent for asset hub parachain 1000
pub const ASSET_HUB_AGENT_ID: [u8; 32] =
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4");
hex!("81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79");
claravanstaden marked this conversation as resolved.
Show resolved Hide resolved
// Agent for penpal parachain 2000
pub const SIBLING_AGENT_ID: [u8; 32] =
hex!("5097ee1101e90c3aadb882858c59a22108668021ec81bce9f4930155e5c21e59");
Expand Down
2 changes: 1 addition & 1 deletion web/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export BRIDGE_HUB_AGENT_ID="${BRIDGE_HUB_AGENT_ID:-0x03170a2e7597b7b7e3d84c05391
assethub_ws_url="${ASSET_HUB_WS_URL:-ws://127.0.0.1:12144}"
assethub_seed="${ASSET_HUB_SEED:-//Alice}"
export ASSET_HUB_PARAID="${ASSET_HUB_PARAID:-1000}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79}"

export ASSET_HUB_CHANNEL_ID="0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539"
export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3"
Expand Down
Loading