Skip to content

Commit

Permalink
[no ci] runtime benchmarks now compiles
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Ferrell <[email protected]>
  • Loading branch information
ferrell-code committed Feb 16, 2024
1 parent 49cee80 commit e0dd42d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
23 changes: 17 additions & 6 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ impl pallet_treasury::Config for Runtime {
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = PayoutSpendPeriod;
type AssetKind = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

impl pallet_aura_style_filter::Config for Runtime {
Expand Down Expand Up @@ -1098,10 +1100,6 @@ pub type Executive = frame_executive::Executive<
OnRuntimeUpgradeHooks,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1137,8 +1135,6 @@ mod benches {
// we disable zenlink in this release, and will fix it in next release
// [zenlink_protocol, ZenlinkProtocol]
[pallet_farming, Farming]
// XCM
[pallet_xcm, PolkadotXcm]
[cumulus_pallet_xcmp_queue, XcmpQueue]
// always get this error(Unimplemented) while benchmarking pallet_xcm_benchmarks::fungible::initiate_teleport
// so this time we will use statemint's fungible weights
Expand Down Expand Up @@ -1500,11 +1496,20 @@ impl_runtime_apis! {
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
pub const KsmLocation: MultiLocation = MultiLocation::parent();
pub KmaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::parachain_id().into())));
pub ExistentialDepositAsset: Option<MultiAsset> = Some(MultiAsset {
id: Concrete(MultiLocation::parent()),
fun: Fungible(NativeTokenExistentialDeposit::get())
}).into();
}

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = XcmExecutorConfig;
type AccountIdConverter = LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
XcmExecutorConfig,
ExistentialDepositAsset,
(),
>;

fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
Ok(KsmLocation::get())
Expand Down Expand Up @@ -1542,6 +1547,7 @@ impl_runtime_apis! {

type CheckedAccount = CheckedAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;

fn get_multi_asset() -> MultiAsset {
MultiAsset {
Expand All @@ -1553,6 +1559,7 @@ impl_runtime_apis! {

impl pallet_xcm_benchmarks::generic::Config for Runtime {
type RuntimeCall = RuntimeCall;
type TransactAsset = Balances;

fn worst_case_response() -> (u64, Response) {
(0u64, Response::Version(Default::default()))
Expand Down Expand Up @@ -1589,6 +1596,10 @@ impl_runtime_apis! {
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
Err(BenchmarkError::Skip)
}

fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
Err(BenchmarkError::Skip)
}
}

let whitelist: Vec<TrackedStorageKey> = vec![
Expand Down
2 changes: 0 additions & 2 deletions runtime/integration-tests/src/xcm_mock/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ impl pallet_xcm::Config for Runtime {
type MaxLockers = ConstU32<8>;
type RemoteLockConsumerIdentifier = ();
type WeightInfo = PalletXcmWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
}

parameter_types! {
Expand Down
2 changes: 0 additions & 2 deletions runtime/integration-tests/src/xcm_mock/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ impl pallet_xcm::Config for Runtime {
type MaxLockers = ConstU32<8>;
type RemoteLockConsumerIdentifier = ();
type WeightInfo = PalletXcmWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
}

parameter_types! {
Expand Down
24 changes: 18 additions & 6 deletions runtime/manta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ impl pallet_treasury::Config for Runtime {
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = PayoutSpendPeriod;
type AssetKind = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

parameter_types! {
Expand Down Expand Up @@ -1048,10 +1050,6 @@ pub type Executive = frame_executive::Executive<
OnRuntimeUpgradeHooks,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand All @@ -1074,7 +1072,6 @@ mod benches {
[pallet_sudo, Sudo]
// XCM
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm, PolkadotXcm]
// always get this error(Unimplemented) while benchmarking pallet_xcm_benchmarks::fungible::initiate_teleport
// so this time we will use statemint's fungible weights
// [pallet_xcm_benchmarks::fungible, XcmBalances]
Expand Down Expand Up @@ -1444,11 +1441,21 @@ impl_runtime_apis! {
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
pub const DotLocation: MultiLocation = MultiLocation::parent();
pub MantaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::parachain_id().into())));
pub ExistentialDepositAsset: Option<MultiAsset> = Some(MultiAsset {
id: Concrete(MultiLocation::parent()),
fun: Fungible(NativeTokenExistentialDeposit::get())
}).into();

}

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = XcmExecutorConfig;
type AccountIdConverter = LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
XcmExecutorConfig,
ExistentialDepositAsset,
(),
>;

fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
Ok(DotLocation::get())
Expand Down Expand Up @@ -1483,9 +1490,9 @@ impl_runtime_apis! {

impl pallet_xcm_benchmarks::fungible::Config for Runtime {
type TransactAsset = Balances;

type CheckedAccount = CheckedAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;

fn get_multi_asset() -> MultiAsset {
MultiAsset {
Expand All @@ -1497,6 +1504,7 @@ impl_runtime_apis! {

impl pallet_xcm_benchmarks::generic::Config for Runtime {
type RuntimeCall = RuntimeCall;
type TransactAsset = Balances;

fn worst_case_response() -> (u64, Response) {
(0u64, Response::Version(Default::default()))
Expand Down Expand Up @@ -1533,6 +1541,10 @@ impl_runtime_apis! {
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
Err(BenchmarkError::Skip)
}

fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
Err(BenchmarkError::Skip)
}
}

// type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
Expand Down

0 comments on commit e0dd42d

Please sign in to comment.