-
Notifications
You must be signed in to change notification settings - Fork 745
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
[Snowbridge]: Ensure source always from AH for exported message #6838
Open
yrong
wants to merge
14
commits into
paritytech:master
Choose a base branch
from
yrong:check-souce-from-ah
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+278
−6
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8a88a8b
Ensure source always from AH
yrong 53ee95e
More tests for edge cases
yrong 525e6a6
Update bridges/snowbridge/primitives/router/src/outbound/mod.rs
yrong c3b8b88
Update bridges/snowbridge/primitives/router/src/outbound/mod.rs
yrong a7cb93d
Update bridges/snowbridge/primitives/router/src/outbound/mod.rs
yrong 277d51b
Load AssetHub's ParaId from runtime
yrong c2a8ba9
More tests
yrong 7192a5a
Add prdoc
yrong f7b6f3a
Merge branch 'master' into check-souce-from-ah
yrong 62f629b
Fix fmt
yrong eff2ef2
Merge branch 'check-souce-from-ah' of https://github.com/yrong/polkad…
yrong f84cc0a
Merge branch 'master' into check-souce-from-ah
yrong df1e673
Fix the comment
yrong 11f8d57
Merge branch 'master' into check-souce-from-ah
yrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...gration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge_edge_case.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
use crate::imports::*; | ||
use bridge_hub_westend_runtime::xcm_config::LocationToAccountId; | ||
use xcm_executor::traits::ConvertLocation; | ||
|
||
use crate::tests::snowbridge::{CHAIN_ID,WETH,ETHEREUM_DESTINATION_ADDRESS}; | ||
|
||
const INITIAL_FUND: u128 = 5_000_000_000_000; | ||
const TOKEN_AMOUNT: u128 = 100_000_000_000; | ||
|
||
pub fn bridge_hub() -> Location { | ||
Location::new(1, Parachain(BridgeHubWestend::para_id().into())) | ||
} | ||
|
||
pub fn beneficiary() -> Location { | ||
Location::new(0, [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }]) | ||
} | ||
|
||
#[test] | ||
fn user_export_message_from_ah_directly_will_fail() { | ||
let sov_account_for_assethub_sender = LocationToAccountId::convert_location(&Location::new( | ||
1, | ||
[ | ||
Parachain(AssetHubWestend::para_id().into()), | ||
AccountId32 { | ||
network: Some(ByGenesis(WESTEND_GENESIS_HASH)), | ||
id: AssetHubWestendSender::get().into(), | ||
}, | ||
], | ||
)) | ||
.unwrap(); | ||
BridgeHubWestend::fund_accounts(vec![(sov_account_for_assethub_sender, INITIAL_FUND)]); | ||
|
||
AssetHubWestend::execute_with(|| { | ||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent; | ||
type RuntimeOrigin = <AssetHubWestend as Chain>::RuntimeOrigin; | ||
|
||
let local_fee_asset = | ||
Asset { id: AssetId(Location::parent()), fun: Fungible(1_000_000_000_000) }; | ||
|
||
let weth_location_reanchored = | ||
Location::new(0, [AccountKey20 { network: None, key: WETH.into() }]); | ||
|
||
let weth_asset = Asset { | ||
id: AssetId(weth_location_reanchored.clone()), | ||
fun: Fungible(TOKEN_AMOUNT * 1_000_000_000), | ||
}; | ||
|
||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::send( | ||
RuntimeOrigin::signed(AssetHubWestendSender::get()), | ||
bx!(VersionedLocation::from(bridge_hub())), | ||
bx!(VersionedXcm::from(Xcm(vec![ | ||
WithdrawAsset(local_fee_asset.clone().into()), | ||
BuyExecution { fees: local_fee_asset.clone(), weight_limit: Unlimited }, | ||
ExportMessage { | ||
network: Ethereum { chain_id: CHAIN_ID }, | ||
destination: Here, | ||
xcm: Xcm(vec![ | ||
WithdrawAsset(weth_asset.clone().into()), | ||
DepositAsset { assets: Wild(All), beneficiary: beneficiary() }, | ||
SetTopic([0; 32]), | ||
]), | ||
}, | ||
]))), | ||
)); | ||
|
||
assert_expected_events!( | ||
AssetHubWestend, | ||
vec![RuntimeEvent::PolkadotXcm(pallet_xcm::Event::Sent{ .. }) => {},] | ||
); | ||
}); | ||
|
||
BridgeHubWestend::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubWestend as Chain>::RuntimeEvent; | ||
assert_expected_events!( | ||
BridgeHubWestend, | ||
vec![RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed{ success:false, .. }) => {},] | ||
); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an anti-pattern to hardcode para-id constants in these types of primitives that could be in theory reused in other scenarios.
In practice this is fine, but the used pattern is to make this a generic parameter so it can be customized by the runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Yeah, just a workaround before getting some feedback.
Fixed in 277d51b