Skip to content

Commit

Permalink
Merge branch 'xcm-v5' into impl-rfc-122
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored Oct 29, 2024
2 parents d431a1d + a1b8381 commit c0edd03
Show file tree
Hide file tree
Showing 50 changed files with 159 additions and 285 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod tests;

use codec::{Decode, Encode};
use core::marker::PhantomData;
use frame_support::{traits::tokens::Balance as BalanceT, weights::Weight, PalletError};
use frame_support::{traits::tokens::Balance as BalanceT, PalletError};
use scale_info::TypeInfo;
use snowbridge_core::TokenId;
use sp_core::{Get, RuntimeDebug, H160, H256};
Expand Down Expand Up @@ -279,7 +279,6 @@ where
// Call create_asset on foreign assets pallet.
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(400_000_000, 8_000),
call: (
create_call_index,
asset_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ macro_rules! test_xcm_fee_querying_apis_work_for_asset_hub {
));

type Runtime = <$asset_hub as Chain>::Runtime;
let acceptable_payment_assets = Runtime::query_acceptable_payment_assets(4).unwrap();
let acceptable_payment_assets = Runtime::query_acceptable_payment_assets(XCM_VERSION).unwrap();
assert_eq!(acceptable_payment_assets, vec![
VersionedAssetId::from(AssetId(wnd.clone())),
VersionedAssetId::from(AssetId(usdt.clone())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ pub fn xcm_transact_paid_execution(
beneficiary: AccountId,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);

VersionedXcm::from(Xcm(vec![
WithdrawAsset(fees.clone().into()),
BuyExecution { fees, weight_limit },
Transact { require_weight_at_most, origin_kind, call },
Transact { origin_kind, call },
RefundSurplus,
DepositAsset {
assets: All.into(),
Expand All @@ -50,12 +49,11 @@ pub fn xcm_transact_unpaid_execution(
origin_kind: OriginKind,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
let check_origin = None;

VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit, check_origin },
Transact { require_weight_at_most, origin_kind, call },
Transact { origin_kind, call },
]))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn send_transact_as_superuser_from_relay_to_asset_hub_works() {
ASSET_MIN_BALANCE,
true,
AssetHubWestendSender::get().into(),
Some(Weight::from_parts(1_019_445_000, 200_000)),
Some(Weight::from_parts(144_759_000, 3675)),
)
}

Expand Down Expand Up @@ -121,7 +121,7 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_sufficient_asset() {
ASSET_MIN_BALANCE,
true,
para_sovereign_account.clone(),
Some(Weight::from_parts(1_019_445_000, 200_000)),
Some(Weight::from_parts(144_759_000, 3675)),
ASSET_MIN_BALANCE * 1000000000,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ fn system_para_sets_relay_xcm_supported_version() {
AssetHubWestend::execute_with(|| {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;

AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(
1_019_210_000,
200_000,
)));
AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(115_688_000, 0)));

assert_expected_events!(
AssetHubWestend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ fn create_agent() {
let remote_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: create_agent_call.encode().into(),
},
Transact { origin_kind: OriginKind::Xcm, call: create_agent_call.encode().into() },
]));

// Rococo Global Consensus
Expand Down Expand Up @@ -142,11 +138,7 @@ fn create_channel() {
let create_agent_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: create_agent_call.encode().into(),
},
Transact { origin_kind: OriginKind::Xcm, call: create_agent_call.encode().into() },
]));

let create_channel_call =
Expand All @@ -155,11 +147,7 @@ fn create_channel() {
let create_channel_xcm = VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
DescendOrigin(Parachain(origin_para).into()),
Transact {
require_weight_at_most: 3000000000.into(),
origin_kind: OriginKind::Xcm,
call: create_channel_call.encode().into(),
},
Transact { origin_kind: OriginKind::Xcm, call: create_channel_call.encode().into() },
]));

// Rococo Global Consensus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fn fellows_whitelist_call() {
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(5_000_000_000, 500_000),
call: WestendCall::Whitelist(
pallet_whitelist::Call::<WestendRuntime>::whitelist_call { call_hash }
)
Expand Down
2 changes: 0 additions & 2 deletions cumulus/parachains/pallets/ping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ pub mod pallet {
(Parent, Junction::Parachain(para.into())).into(),
Xcm(vec![Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1_000, 1_000),
call: <T as Config>::RuntimeCall::from(Call::<T>::ping {
seq,
payload: payload.clone().to_vec(),
Expand Down Expand Up @@ -209,7 +208,6 @@ pub mod pallet {
(Parent, Junction::Parachain(para.into())).into(),
Xcm(vec![Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1_000, 1_000),
call: <T as Config>::RuntimeCall::from(Call::<T>::pong {
seq,
payload: payload.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
14 changes: 2 additions & 12 deletions cumulus/parachains/runtimes/assets/test-utils/src/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,19 +1202,13 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
let xcm = Xcm(vec![
WithdrawAsset(buy_execution_fee.clone().into()),
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(40_000_000_000, 8000),
call: foreign_asset_create.into(),
},
Transact { origin_kind: OriginKind::Xcm, call: foreign_asset_create.into() },
Transact {
origin_kind: OriginKind::SovereignAccount,
require_weight_at_most: Weight::from_parts(20_000_000_000, 8000),
call: foreign_asset_set_metadata.into(),
},
Transact {
origin_kind: OriginKind::SovereignAccount,
require_weight_at_most: Weight::from_parts(20_000_000_000, 8000),
call: foreign_asset_set_team.into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
Expand Down Expand Up @@ -1321,11 +1315,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
let xcm = Xcm(vec![
WithdrawAsset(buy_execution_fee.clone().into()),
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(20_000_000_000, 8000),
call: foreign_asset_create.into(),
},
Transact { origin_kind: OriginKind::Xcm, call: foreign_asset_create.into() },
ExpectTransactStatus(MaybeErrorCode::from(DispatchError::BadOrigin.encode())),
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ pub fn initialize_bridge_by_governance_works<Runtime, GrandpaPalletInstance>(
});

// execute XCM with Transacts to `initialize bridge` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
initialize_call.encode(),
initialize_call.get_dispatch_info().call_weight,
)
.ensure_complete());
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(initialize_call.encode(),)
.ensure_complete());

// check mode after
assert_eq!(
Expand Down Expand Up @@ -172,7 +169,6 @@ pub fn change_bridge_grandpa_pallet_mode_by_governance_works<Runtime, GrandpaPal
// execute XCM with Transacts to `initialize bridge` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
set_operating_mode_call.encode(),
set_operating_mode_call.get_dispatch_info().call_weight,
)
.ensure_complete());

Expand Down Expand Up @@ -225,7 +221,6 @@ pub fn change_bridge_parachains_pallet_mode_by_governance_works<Runtime, Paracha
// execute XCM with Transacts to `initialize bridge` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
set_operating_mode_call.encode(),
set_operating_mode_call.get_dispatch_info().call_weight,
)
.ensure_complete());

Expand Down Expand Up @@ -278,7 +273,6 @@ pub fn change_bridge_messages_pallet_mode_by_governance_works<Runtime, MessagesP
// execute XCM with Transacts to `initialize bridge` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
set_operating_mode_call.encode(),
set_operating_mode_call.get_dispatch_info().call_weight,
)
.ensure_complete());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
call: request_core_count_call.encode().into(),
},
]);
Expand Down Expand Up @@ -164,7 +163,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
call: request_revenue_info_at_call.encode().into(),
},
]);
Expand Down Expand Up @@ -193,7 +191,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
call: credit_account_call.encode().into(),
},
]);
Expand Down Expand Up @@ -258,7 +255,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1_000_000_000, 200000),
call: assign_core_call.encode().into(),
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ impl<Call> XcmWeightInfo<Call> for CoretimeRococoXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,13 @@ impl CoretimeInterface for CoretimeAllocator {
use crate::coretime::CoretimeProviderCalls::RequestCoreCount;
let request_core_count_call = RelayRuntimePallets::Coretime(RequestCoreCount(count));

// Weight for `request_core_count` from westend benchmarks:
// `ref_time` = 7889000 + (3 * 25000000) + (1 * 100000000) = 182889000
// `proof_size` = 1636
// Add 5% to each component and round to 2 significant figures.
let call_weight = Weight::from_parts(190_000_000, 1700);

let message = Xcm(vec![
Instruction::UnpaidExecution {
weight_limit: WeightLimit::Unlimited,
check_origin: None,
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: call_weight,
call: request_core_count_call.encode().into(),
},
]);
Expand Down Expand Up @@ -170,7 +163,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
call: request_revenue_info_at_call.encode().into(),
},
]);
Expand Down Expand Up @@ -199,7 +191,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
call: credit_account_call.encode().into(),
},
]);
Expand All @@ -225,12 +216,6 @@ impl CoretimeInterface for CoretimeAllocator {
) {
use crate::coretime::CoretimeProviderCalls::AssignCore;

// Weight for `assign_core` from westend benchmarks:
// `ref_time` = 10177115 + (1 * 25000000) + (2 * 100000000) + (57600 * 13932) = 937660315
// `proof_size` = 3612
// Add 5% to each component and round to 2 significant figures.
let call_weight = Weight::from_parts(980_000_000, 3800);

// The relay chain currently only allows `assign_core` to be called with a complete mask
// and only ever with increasing `begin`. The assignments must be truncated to avoid
// dropping that core's assignment completely.
Expand Down Expand Up @@ -270,7 +255,6 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: call_weight,
call: assign_core_call.encode().into(),
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ impl<Call> XcmWeightInfo<Call> for CoretimeWestendXcmWeight<Call> {
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
fn transact(_origin_type: &OriginKind, _call: &DoubleEncoded<Call>) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
Expand Down
Loading

0 comments on commit c0edd03

Please sign in to comment.