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 @@ -68,8 +68,8 @@ fn system_para_sets_relay_xcm_supported_version() {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;

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

assert_expected_events!(
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 @@ -86,7 +86,6 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
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 @@ -85,7 +85,6 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,17 +1204,14 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
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::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 @@ -1323,7 +1320,6 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
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(),
},
ExpectTransactStatus(MaybeErrorCode::from(DispatchError::BadOrigin.encode())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ 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());

Expand Down Expand Up @@ -172,7 +171,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 +223,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 +275,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 @@ -86,7 +86,6 @@ impl<Call> XcmWeightInfo<Call> for CoretimeRococoXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
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 @@ -85,7 +85,6 @@ impl<Call> XcmWeightInfo<Call> for CoretimeWestendXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl<Call> XcmWeightInfo<Call> for PeopleRococoXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl<Call> XcmWeightInfo<Call> for PeopleWestendXcmWeight<Call> {
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
4 changes: 1 addition & 3 deletions cumulus/parachains/runtimes/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,12 @@ impl<
AllPalletsWithoutSystem,
> RuntimeHelper<Runtime, AllPalletsWithoutSystem>
{
pub fn execute_as_governance(call: Vec<u8>, require_weight_at_most: Weight) -> Outcome {
pub fn execute_as_governance(call: Vec<u8>) -> Outcome {
// prepare xcm as governance will do
let xcm = Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Superuser,
require_weight_at_most,
call: call.into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
Expand Down Expand Up @@ -475,7 +474,6 @@ impl<
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: call.get_dispatch_info().call_weight,
call: call.encode().into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
Expand Down
14 changes: 0 additions & 14 deletions cumulus/parachains/runtimes/test-utils/src/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,9 @@ pub fn change_storage_constant_by_governance_works<Runtime, StorageConstant, Sto
)],
});

// estimate - storing just 1 value
use frame_system::WeightInfo;
let require_weight_at_most =
<Runtime as frame_system::Config>::SystemWeightInfo::set_storage(1);

// execute XCM with Transact to `set_storage` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
set_storage_call,
require_weight_at_most
)
.ensure_complete());

Expand Down Expand Up @@ -127,17 +121,9 @@ pub fn set_storage_keys_by_governance_works<Runtime>(
items: storage_items.clone(),
});

// estimate - storing just 1 value
use frame_system::WeightInfo;
let require_weight_at_most =
<Runtime as frame_system::Config>::SystemWeightInfo::set_storage(
storage_items.len().try_into().unwrap(),
);

// execute XCM with Transact to `set_storage` as governance does
assert_ok!(RuntimeHelper::<Runtime>::execute_as_governance(
kill_storage_call,
require_weight_at_most
)
.ensure_complete());
});
Expand Down
6 changes: 0 additions & 6 deletions polkadot/runtime/parachains/src/coretime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ pub mod pallet {
type AssetTransactor: TransactAsset;
/// AccountId to Location converter
type AccountToLocation: for<'a> TryConvert<&'a Self::AccountId, Location>;

/// Maximum weight for any XCM transact call that should be executed on the coretime chain.
///
/// Basically should be `max_weight(set_leases, reserve, notify_core_count)`.
type MaxXcmTransactWeight: Get<Weight>;
}

#[pallet::event]
Expand Down Expand Up @@ -338,7 +333,6 @@ impl<T: Config> OnNewSession<BlockNumberFor<T>> for Pallet<T> {
fn mk_coretime_call<T: Config>(call: crate::coretime::CoretimeCalls) -> Instruction<()> {
Instruction::Transact {
origin_kind: OriginKind::Superuser,
require_weight_at_most: T::MaxXcmTransactWeight::get(),
call: BrokerRuntimePallets::Broker(call).encode().into(),
}
}
Expand Down
1 change: 0 additions & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,6 @@ impl coretime::Config for Runtime {
xcm_config::ThisNetwork,
<Runtime as frame_system::Config>::AccountId,
>;
type MaxXcmTransactWeight = MaxXcmTransactWeight;
}

parameter_types! {
Expand Down
1 change: 0 additions & 1 deletion polkadot/runtime/rococo/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
}
fn transact(
_origin_kind: &OriginKind,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<RuntimeCall>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
Expand Down
Loading
Loading