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

Transact without specifying weight #6228

Merged
merged 11 commits into from
Oct 29, 2024
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 @@ -1414,7 +1414,7 @@ impl_runtime_apis! {
// We also accept all assets in a pool with the native token.
let assets_in_pool_with_native = assets_common::get_assets_in_pool_with::<
Runtime,
xcm::v4::Location
xcm::v5::Location
>(&native_token).map_err(|()| XcmPaymentApiError::VersionedConversionFailed)?.into_iter();
acceptable_assets.extend(assets_in_pool_with_native);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
Expand All @@ -1431,7 +1431,7 @@ impl_runtime_apis! {
Ok(asset_id) => {
let assets_in_pool_with_this_asset: Vec<_> = assets_common::get_assets_in_pool_with::<
Runtime,
xcm::v4::Location
xcm::v5::Location
>(&asset_id.0).map_err(|()| XcmPaymentApiError::VersionedConversionFailed)?;
if assets_in_pool_with_this_asset
.into_iter()
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 @@ -1526,7 +1526,7 @@ impl_runtime_apis! {
// We also accept all assets in a pool with the native token.
let assets_in_pool_with_native = assets_common::get_assets_in_pool_with::<
Runtime,
xcm::v4::Location
xcm::v5::Location
>(&native_token).map_err(|()| XcmPaymentApiError::VersionedConversionFailed)?.into_iter();
acceptable_assets.extend(assets_in_pool_with_native);
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
Expand All @@ -1544,7 +1544,7 @@ impl_runtime_apis! {
// We recognize assets in a pool with the native one.
let assets_in_pool_with_this_asset: Vec<_> = assets_common::get_assets_in_pool_with::<
Runtime,
xcm::v4::Location
xcm::v5::Location
>(&asset_id.0).map_err(|()| XcmPaymentApiError::VersionedConversionFailed)?;
if assets_in_pool_with_this_asset
.into_iter()
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
Loading
Loading