Skip to content

Commit

Permalink
Merge branch 'master' into oty-fix-bencher
Browse files Browse the repository at this point in the history
  • Loading branch information
ggwpez authored Mar 6, 2025
2 parents d2152b5 + 00d8eea commit cb2e929
Show file tree
Hide file tree
Showing 28 changed files with 614 additions and 142 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/command-backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:

- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2.1.0
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.CMD_BOT_APP_ID }}
private_key: ${{ secrets.CMD_BOT_APP_KEY }}
app_id: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_ID }}
private_key: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_PRIVATE_KEY }}

- name: Create backport pull requests
uses: korthout/backport-action@v3
Expand Down
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bridges/snowbridge/primitives/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sp-runtime = { workspace = true }
sp-std = { workspace = true }

xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }

snowbridge-core = { workspace = true }
Expand All @@ -43,13 +44,15 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"snowbridge-core/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ where
}
}

/// DEPRECATED in favor of [xcm_builder::ExternalConsensusLocationsConverterFor]
pub struct EthereumLocationsConverterFor<AccountId>(PhantomData<AccountId>);
impl<AccountId> ConvertLocation<AccountId> for EthereumLocationsConverterFor<AccountId>
where
Expand Down
21 changes: 18 additions & 3 deletions bridges/snowbridge/primitives/router/src/inbound/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ use super::EthereumLocationsConverterFor;
use crate::inbound::{
mock::*, Command, ConvertMessage, Destination, MessageV1, VersionedMessage, H160,
};
use frame_support::assert_ok;
use frame_support::{assert_ok, parameter_types};
use hex_literal::hex;
use xcm::prelude::*;
use xcm_builder::ExternalConsensusLocationsConverterFor;
use xcm_executor::traits::ConvertLocation;

parameter_types! {
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ByGenesis([9; 32])), Parachain(1234)].into();
}

#[test]
fn test_ethereum_network_converts_successfully() {
let expected_account: [u8; 32] =
Expand All @@ -15,7 +20,12 @@ fn test_ethereum_network_converts_successfully() {

let account =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();

assert_eq!(account, expected_account);
let account =
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
&contract_location,
)
.unwrap();
assert_eq!(account, expected_account);
}

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

let account =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();

assert_eq!(account, expected_account);
let account =
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
&contract_location,
)
.unwrap();
assert_eq!(account, expected_account);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ sp-runtime = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod imports {
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
};
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::imports::*;
use ahr_xcm_config::UniversalLocation as AssetHubRococoUniversalLocation;
use codec::{Decode, Encode};
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
use frame_support::pallet_prelude::TypeInfo;
Expand All @@ -24,9 +25,7 @@ use snowbridge_pallet_inbound_queue_fixtures::{
send_token::make_send_token_message, send_token_to_penpal::make_send_token_to_penpal_message,
};
use snowbridge_pallet_system;
use snowbridge_router_primitives::inbound::{
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
};
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use sp_core::H256;
use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable};
use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
Expand Down Expand Up @@ -319,8 +318,13 @@ fn send_weth_from_ethereum_to_penpal() {
let origin_location = (Parent, Parent, ethereum_network_v5).into();

// Fund ethereum sovereign on AssetHub
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubRococoUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on the Penpal parachain.
Expand Down Expand Up @@ -526,8 +530,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
use ahr_xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
let assethub_location = BridgeHubRococo::sibling_location_of(AssetHubRococo::para_id());
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(assethub_location);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubRococoUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

AssetHubRococo::force_default_xcm_version(Some(XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(XCM_VERSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-runtime = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod imports {
prelude::{AccountId32 as AccountId32Junction, *},
v5,
};
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{imports::*, tests::penpal_emulated_chain::penpal_runtime};
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
use asset_hub_westend_runtime::xcm_config::{
bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee,
UniversalLocation as AssetHubWestendUniversalLocation,
};
use bridge_hub_westend_runtime::{
bridge_to_ethereum_config::EthereumGatewayAddress, EthereumBeaconClient, EthereumInboundQueue,
};
Expand All @@ -24,9 +27,7 @@ use hex_literal::hex;
use rococo_westend_system_emulated_network::asset_hub_westend_emulated_chain::genesis::AssetHubWestendAssetOwner;
use snowbridge_core::{inbound::InboundQueueFixture, AssetMetadata, TokenIdOf};
use snowbridge_pallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message;
use snowbridge_router_primitives::inbound::{
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
};
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use sp_core::H256;
use testnet_parachains_constants::westend::snowbridge::EthereumNetwork;
use xcm_executor::traits::ConvertLocation;
Expand Down Expand Up @@ -161,8 +162,13 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
fn send_weth_token_from_ethereum_to_asset_hub() {
let ethereum_network: NetworkId = EthereumNetwork::get().into();
let origin_location = Location::new(2, ethereum_network);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

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

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

// Fund ethereum sovereign on AssetHub
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on the Penpal parachain.
Expand Down Expand Up @@ -387,8 +398,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
let assethub_location = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());
let assethub_sovereign = BridgeHubWestend::sovereign_account_id_of(assethub_location);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

AssetHubWestend::force_default_xcm_version(Some(XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(XCM_VERSION));
Expand Down Expand Up @@ -934,13 +950,17 @@ fn transfer_relay_token() {

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

let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&Location::new(
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
[u8; 32],
>::convert_location(&Location::new(
2,
[GlobalConsensus(EthereumNetwork::get())],
))
.unwrap()
.into();
.into()
});

// Register token
BridgeHubWestend::execute_with(|| {
Expand Down Expand Up @@ -1082,10 +1102,14 @@ fn transfer_ah_token() {

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

let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&ethereum_destination)
.unwrap()
.into();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
[u8; 32],
>::convert_location(&ethereum_destination)
.unwrap()
.into()
});
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

let asset_id: Location =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ snowbridge-router-primitives = { workspace = true }
[dev-dependencies]
asset-test-utils = { workspace = true, default-features = true }
parachains-runtimes-test-utils = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }

[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use testnet_parachains_constants::rococo::snowbridge::{
EthereumNetwork, INBOUND_QUEUE_PALLET_INDEX,
Expand All @@ -52,16 +51,15 @@ use xcm_builder::{
AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom,
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry,
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
IsConcrete, LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking,
NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter,
SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith,
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithLatestLocationConverter, WithUniqueTopic,
XcmFeeManagerFromComponents,
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, ExternalConsensusLocationsConverterFor,
FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, HashedDescription, IsConcrete,
LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter,
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -105,12 +103,8 @@ pub type LocationToAccountId = (
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
// Different global consensus parachain sovereign account.
// (Used for over-bridge transfers and reserve processing)
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
EthereumLocationsConverterFor<AccountId>,
// Different global consensus locations sovereign accounts.
ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
);

/// Means for transacting the native currency on this chain.
Expand Down
Loading

0 comments on commit cb2e929

Please sign in to comment.