Skip to content

Commit cb2e929

Browse files
authored
Merge branch 'master' into oty-fix-bencher
2 parents d2152b5 + 00d8eea commit cb2e929

File tree

28 files changed

+614
-142
lines changed

28 files changed

+614
-142
lines changed

.github/workflows/command-backport.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131

3232
- name: Generate token
3333
id: generate_token
34-
uses: tibdex/github-app-token@v2.1.0
34+
uses: actions/create-github-app-token@v1
3535
with:
36-
app_id: ${{ secrets.CMD_BOT_APP_ID }}
37-
private_key: ${{ secrets.CMD_BOT_APP_KEY }}
36+
app_id: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_ID }}
37+
private_key: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_PRIVATE_KEY }}
3838

3939
- name: Create backport pull requests
4040
uses: korthout/backport-action@v3

Cargo.lock

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bridges/snowbridge/primitives/router/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sp-runtime = { workspace = true }
2323
sp-std = { workspace = true }
2424

2525
xcm = { workspace = true }
26+
xcm-builder = { workspace = true }
2627
xcm-executor = { workspace = true }
2728

2829
snowbridge-core = { workspace = true }
@@ -43,13 +44,15 @@ std = [
4344
"sp-io/std",
4445
"sp-runtime/std",
4546
"sp-std/std",
47+
"xcm-builder/std",
4648
"xcm-executor/std",
4749
"xcm/std",
4850
]
4951
runtime-benchmarks = [
5052
"frame-support/runtime-benchmarks",
5153
"snowbridge-core/runtime-benchmarks",
5254
"sp-runtime/runtime-benchmarks",
55+
"xcm-builder/runtime-benchmarks",
5356
"xcm-executor/runtime-benchmarks",
5457
"xcm/runtime-benchmarks",
5558
]

bridges/snowbridge/primitives/router/src/inbound/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ where
466466
}
467467
}
468468

469+
/// DEPRECATED in favor of [xcm_builder::ExternalConsensusLocationsConverterFor]
469470
pub struct EthereumLocationsConverterFor<AccountId>(PhantomData<AccountId>);
470471
impl<AccountId> ConvertLocation<AccountId> for EthereumLocationsConverterFor<AccountId>
471472
where

bridges/snowbridge/primitives/router/src/inbound/tests.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ use super::EthereumLocationsConverterFor;
22
use crate::inbound::{
33
mock::*, Command, ConvertMessage, Destination, MessageV1, VersionedMessage, H160,
44
};
5-
use frame_support::assert_ok;
5+
use frame_support::{assert_ok, parameter_types};
66
use hex_literal::hex;
77
use xcm::prelude::*;
8+
use xcm_builder::ExternalConsensusLocationsConverterFor;
89
use xcm_executor::traits::ConvertLocation;
910

11+
parameter_types! {
12+
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ByGenesis([9; 32])), Parachain(1234)].into();
13+
}
14+
1015
#[test]
1116
fn test_ethereum_network_converts_successfully() {
1217
let expected_account: [u8; 32] =
@@ -15,7 +20,12 @@ fn test_ethereum_network_converts_successfully() {
1520

1621
let account =
1722
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();
18-
23+
assert_eq!(account, expected_account);
24+
let account =
25+
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
26+
&contract_location,
27+
)
28+
.unwrap();
1929
assert_eq!(account, expected_account);
2030
}
2131

@@ -30,7 +40,12 @@ fn test_contract_location_with_network_converts_successfully() {
3040

3141
let account =
3242
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();
33-
43+
assert_eq!(account, expected_account);
44+
let account =
45+
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
46+
&contract_location,
47+
)
48+
.unwrap();
3449
assert_eq!(account, expected_account);
3550
}
3651

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ sp-runtime = { workspace = true }
2727
# Polkadot
2828
pallet-xcm = { workspace = true }
2929
xcm = { workspace = true }
30+
xcm-builder = { workspace = true }
3031
xcm-executor = { workspace = true }
3132
xcm-runtime-apis = { workspace = true }
3233

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mod imports {
2525
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
2626
prelude::{AccountId32 as AccountId32Junction, *},
2727
};
28+
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
2829
pub use xcm_executor::traits::TransferType;
2930

3031
// Cumulus

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
use crate::imports::*;
16+
use ahr_xcm_config::UniversalLocation as AssetHubRococoUniversalLocation;
1617
use codec::{Decode, Encode};
1718
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
1819
use frame_support::pallet_prelude::TypeInfo;
@@ -24,9 +25,7 @@ use snowbridge_pallet_inbound_queue_fixtures::{
2425
send_token::make_send_token_message, send_token_to_penpal::make_send_token_to_penpal_message,
2526
};
2627
use snowbridge_pallet_system;
27-
use snowbridge_router_primitives::inbound::{
28-
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
29-
};
28+
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
3029
use sp_core::H256;
3130
use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable};
3231
use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
@@ -319,8 +318,13 @@ fn send_weth_from_ethereum_to_penpal() {
319318
let origin_location = (Parent, Parent, ethereum_network_v5).into();
320319

321320
// Fund ethereum sovereign on AssetHub
322-
let ethereum_sovereign: AccountId =
323-
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
321+
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
322+
ExternalConsensusLocationsConverterFor::<
323+
AssetHubRococoUniversalLocation,
324+
AccountId,
325+
>::convert_location(&origin_location)
326+
.unwrap()
327+
});
324328
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
325329

326330
// Create asset on the Penpal parachain.
@@ -526,8 +530,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
526530
use ahr_xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
527531
let assethub_location = BridgeHubRococo::sibling_location_of(AssetHubRococo::para_id());
528532
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(assethub_location);
529-
let ethereum_sovereign: AccountId =
530-
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
533+
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
534+
ExternalConsensusLocationsConverterFor::<
535+
AssetHubRococoUniversalLocation,
536+
AccountId,
537+
>::convert_location(&origin_location)
538+
.unwrap()
539+
});
531540

532541
AssetHubRococo::force_default_xcm_version(Some(XCM_VERSION));
533542
BridgeHubRococo::force_default_xcm_version(Some(XCM_VERSION));

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ sp-runtime = { workspace = true }
2828
# Polkadot
2929
pallet-xcm = { workspace = true }
3030
xcm = { workspace = true }
31+
xcm-builder = { workspace = true }
3132
xcm-executor = { workspace = true }
3233
xcm-runtime-apis = { workspace = true }
3334

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod imports {
2626
prelude::{AccountId32 as AccountId32Junction, *},
2727
v5,
2828
};
29+
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
2930
pub use xcm_executor::traits::TransferType;
3031

3132
// Cumulus

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs

+41-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
use crate::{imports::*, tests::penpal_emulated_chain::penpal_runtime};
16-
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
16+
use asset_hub_westend_runtime::xcm_config::{
17+
bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee,
18+
UniversalLocation as AssetHubWestendUniversalLocation,
19+
};
1720
use bridge_hub_westend_runtime::{
1821
bridge_to_ethereum_config::EthereumGatewayAddress, EthereumBeaconClient, EthereumInboundQueue,
1922
};
@@ -24,9 +27,7 @@ use hex_literal::hex;
2427
use rococo_westend_system_emulated_network::asset_hub_westend_emulated_chain::genesis::AssetHubWestendAssetOwner;
2528
use snowbridge_core::{inbound::InboundQueueFixture, AssetMetadata, TokenIdOf};
2629
use snowbridge_pallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message;
27-
use snowbridge_router_primitives::inbound::{
28-
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
29-
};
30+
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
3031
use sp_core::H256;
3132
use testnet_parachains_constants::westend::snowbridge::EthereumNetwork;
3233
use xcm_executor::traits::ConvertLocation;
@@ -161,8 +162,13 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
161162
fn send_weth_token_from_ethereum_to_asset_hub() {
162163
let ethereum_network: NetworkId = EthereumNetwork::get().into();
163164
let origin_location = Location::new(2, ethereum_network);
164-
let ethereum_sovereign: AccountId =
165-
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
165+
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
166+
ExternalConsensusLocationsConverterFor::<
167+
AssetHubWestendUniversalLocation,
168+
AccountId,
169+
>::convert_location(&origin_location)
170+
.unwrap()
171+
});
166172

167173
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id().into(), INITIAL_FUND);
168174

@@ -280,8 +286,13 @@ fn send_weth_from_ethereum_to_penpal() {
280286
let origin_location = (Parent, Parent, ethereum_network_v5).into();
281287

282288
// Fund ethereum sovereign on AssetHub
283-
let ethereum_sovereign: AccountId =
284-
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
289+
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
290+
ExternalConsensusLocationsConverterFor::<
291+
AssetHubWestendUniversalLocation,
292+
AccountId,
293+
>::convert_location(&origin_location)
294+
.unwrap()
295+
});
285296
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
286297

287298
// Create asset on the Penpal parachain.
@@ -387,8 +398,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
387398
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
388399
let assethub_location = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());
389400
let assethub_sovereign = BridgeHubWestend::sovereign_account_id_of(assethub_location);
390-
let ethereum_sovereign: AccountId =
391-
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
401+
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
402+
ExternalConsensusLocationsConverterFor::<
403+
AssetHubWestendUniversalLocation,
404+
AccountId,
405+
>::convert_location(&origin_location)
406+
.unwrap()
407+
});
392408

393409
AssetHubWestend::force_default_xcm_version(Some(XCM_VERSION));
394410
BridgeHubWestend::force_default_xcm_version(Some(XCM_VERSION));
@@ -934,13 +950,17 @@ fn transfer_relay_token() {
934950

935951
let expected_token_id = TokenIdOf::convert_location(&expected_asset_id).unwrap();
936952

937-
let ethereum_sovereign: AccountId =
938-
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&Location::new(
953+
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
954+
ExternalConsensusLocationsConverterFor::<
955+
AssetHubWestendUniversalLocation,
956+
[u8; 32],
957+
>::convert_location(&Location::new(
939958
2,
940959
[GlobalConsensus(EthereumNetwork::get())],
941960
))
942961
.unwrap()
943-
.into();
962+
.into()
963+
});
944964

945965
// Register token
946966
BridgeHubWestend::execute_with(|| {
@@ -1082,10 +1102,14 @@ fn transfer_ah_token() {
10821102

10831103
let ethereum_destination = Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]);
10841104

1085-
let ethereum_sovereign: AccountId =
1086-
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&ethereum_destination)
1087-
.unwrap()
1088-
.into();
1105+
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
1106+
ExternalConsensusLocationsConverterFor::<
1107+
AssetHubWestendUniversalLocation,
1108+
[u8; 32],
1109+
>::convert_location(&ethereum_destination)
1110+
.unwrap()
1111+
.into()
1112+
});
10891113
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
10901114

10911115
let asset_id: Location =

cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ snowbridge-router-primitives = { workspace = true }
103103
[dev-dependencies]
104104
asset-test-utils = { workspace = true, default-features = true }
105105
parachains-runtimes-test-utils = { workspace = true, default-features = true }
106+
sp-io = { workspace = true, default-features = true }
106107

107108
[build-dependencies]
108109
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }

cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use parachains_common::{
4242
};
4343
use polkadot_parachain_primitives::primitives::Sibling;
4444
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
45-
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
4645
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
4746
use testnet_parachains_constants::rococo::snowbridge::{
4847
EthereumNetwork, INBOUND_QUEUE_PALLET_INDEX,
@@ -52,16 +51,15 @@ use xcm_builder::{
5251
AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom,
5352
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
5453
AllowTopLevelPaidExecutionFrom, DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry,
55-
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
56-
FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
57-
IsConcrete, LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking,
58-
NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
59-
SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
60-
SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter,
61-
SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith,
62-
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
63-
WeightInfoBounds, WithComputedOrigin, WithLatestLocationConverter, WithUniqueTopic,
64-
XcmFeeManagerFromComponents,
54+
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, ExternalConsensusLocationsConverterFor,
55+
FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, HashedDescription, IsConcrete,
56+
LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
57+
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
58+
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
59+
SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter,
60+
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
61+
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
62+
WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents,
6563
};
6664
use xcm_executor::XcmExecutor;
6765

@@ -105,12 +103,8 @@ pub type LocationToAccountId = (
105103
AccountId32Aliases<RelayNetwork, AccountId>,
106104
// Foreign locations alias into accounts according to a hash of their standard description.
107105
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
108-
// Different global consensus parachain sovereign account.
109-
// (Used for over-bridge transfers and reserve processing)
110-
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
111-
// Ethereum contract sovereign account.
112-
// (Used to get convert ethereum contract locations to sovereign account)
113-
EthereumLocationsConverterFor<AccountId>,
106+
// Different global consensus locations sovereign accounts.
107+
ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
114108
);
115109

116110
/// Means for transacting the native currency on this chain.

0 commit comments

Comments
 (0)