Skip to content

Commit 51341d9

Browse files
authored
Configurable BaseXcmWeight. (#545)
* Configurable BaseXcmWeight. * fmt * Saturating add. * Fix tests.
1 parent 5de8935 commit 51341d9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

xtokens/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ pub mod module {
8989

9090
/// Means of measuring the weight consumed by an XCM message locally.
9191
type Weigher: WeightBounds<Self::Call>;
92+
93+
/// Base XCM weight.
94+
///
95+
/// The actually weight for an XCM message is `T::BaseXcmWeight +
96+
/// T::Weigher::weight(&msg)`.
97+
#[pallet::constant]
98+
type BaseXcmWeight: Get<Weight>;
9299
}
93100

94101
#[pallet::event]
@@ -376,7 +383,7 @@ pub mod module {
376383
}
377384
}
378385
};
379-
T::Weigher::weight(&mut msg).map_or(Weight::max_value(), |w| 100_000_000 + w)
386+
T::Weigher::weight(&mut msg).map_or(Weight::max_value(), |w| T::BaseXcmWeight::get().saturating_add(w))
380387
} else {
381388
0
382389
}

xtokens/src/mock/para.rs

+2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ impl Convert<AccountId, MultiLocation> for AccountIdToMultiLocation {
216216

217217
parameter_types! {
218218
pub SelfLocation: MultiLocation = X2(Parent, Parachain(ParachainInfo::get().into()));
219+
pub const BaseXcmWeight: Weight = 100_000_000;
219220
}
220221

221222
impl orml_xtokens::Config for Runtime {
@@ -227,6 +228,7 @@ impl orml_xtokens::Config for Runtime {
227228
type SelfLocation = SelfLocation;
228229
type XcmExecutor = XcmExecutor<XcmConfig>;
229230
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
231+
type BaseXcmWeight = BaseXcmWeight;
230232
}
231233

232234
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;

0 commit comments

Comments
 (0)