Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofdeepanshu committed Oct 20, 2023
1 parent 7f929d1 commit bbcff0b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 40 deletions.
17 changes: 12 additions & 5 deletions pallets/astar-xcm-benchmarks/src/fungible/assets/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ benchmarks_instance_pallet! {
as
TryInto<u128>
>::Error: sp_std::fmt::Debug,

< T::TransactAsset
as
Inspect<T::AccountId>
>::Balance : Into<u128>

}

withdraw_asset {
Expand Down Expand Up @@ -86,14 +92,12 @@ benchmarks_instance_pallet! {
},
).unwrap();
assert!(T::TransactAsset::balance(&dest_account).is_zero());

// reducing some assets for Existential deposit
if let Fungible(x) = asset.fun {
asset.fun = Fungible(x/10)
};

log::trace!(
target: "xcm::process",
"asset is {:?}",asset.clone());
let assets: MultiAssets = vec![ asset.clone() ].into();
log::trace!(
target: "xcm::process",
Expand All @@ -116,13 +120,14 @@ benchmarks_instance_pallet! {
target: "xcm::process",
"destination balance is {:?}, sender balance is {:?}",T::TransactAsset::balance(&dest_account),T::TransactAsset::balance(&sender_account));
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
let previous_balance: u128 = T::TransactAsset::balance(&dest_account).into();
}: {
executor.bench_process(xcm)?;
} verify {
log::trace!(
target: "xcm::process",
"destination balance is {:?}, sender balance is {:?}",T::TransactAsset::balance(&dest_account),T::TransactAsset::balance(&sender_account));
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
assert!(T::TransactAsset::balance(&dest_account).into() == 2 * previous_balance);
}

transfer_reserve_asset {
Expand Down Expand Up @@ -165,10 +170,12 @@ benchmarks_instance_pallet! {
xcm: Xcm::new()
};
let xcm = Xcm(vec![instruction]);
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
let previous_balance: u128 = T::TransactAsset::balance(&dest_account).into();
}: {
executor.bench_process(xcm)?;
} verify {
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
assert!(T::TransactAsset::balance(&dest_account).into() == 2 * previous_balance);
}

receive_teleported_asset {
Expand Down
13 changes: 0 additions & 13 deletions pallets/astar-xcm-benchmarks/src/fungible/assets/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ impl pallet_assets::Config for Test {
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
// pub struct MatchAnyFungible;
// impl xcm_executor::traits::MatchesFungible<u64> for MatchAnyFungible {
// fn matches_fungible(m: &MultiAsset) -> Option<u64> {
// use sp_runtime::traits::SaturatedConversion;
// match m {
// MultiAsset {
// fun: Fungible(amount),
// ..
// } => Some((*amount).saturated_into::<u64>()),
// _ => None,
// }
// }
// }

// Use fungible transactor as the asset transactor.
pub type AssetTransactor = xcm_builder::FungiblesAdapter<
Expand Down
2 changes: 0 additions & 2 deletions pallets/astar-xcm-benchmarks/src/fungible/balances/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ pub type AssetTransactor = xcm_builder::CurrencyAdapter<
>;

parameter_types! {
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
/// calculations getting too crazy.
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/astar/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ pub type XcmOriginToTransactDispatchOrigin = (

parameter_types! {
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
// For the PoV size, we estimate 64 kB per instruction - which will is once again very conservative.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, astar_primitives::xcm::DEFAULT_PROOF_SIZE);
// For the PoV size, we estimate 4 kB per instruction. This will be changed when we benchmark the instructions.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 4 * 1024);
pub const MaxInstructions: u32 = 100;
}

Expand Down
14 changes: 5 additions & 9 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1982,15 +1982,11 @@ impl_runtime_apis! {
type RuntimeCall = RuntimeCall;

fn worst_case_response() -> (u64, Response) {
// not sure what will be the worst case for Response
// either `Assets(MultiAssets)` or `PalletsInfo(BoundedVec<PalletInfo, MaxPalletsInfo>)`
// in either case, what will be the worst case?
// let assets: Vec<MultiAsset> = vec![MultiAsset {
// id: Concrete(MultiLocation::parent()),
// fun: Fungible(u128::MAX),
// }];
// (0u64, Response::Assets(assets.into()))
(0u64, Response::Version(Default::default()))
let assets: Vec<MultiAsset> = vec![MultiAsset {
id: Concrete(MultiLocation::parent()),
fun: Fungible(u128::MAX),
}];
(0u64, Response::Assets(assets.into()))

}

Expand Down
3 changes: 0 additions & 3 deletions runtime/shibuya/src/weights/xcm_instruction_benchmarks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,9 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for ShibuyaXcmWeight<RuntimeCall> {
XcmGeneric::<Runtime>::unsubscribe_version()
}
fn burn_asset(assets: &MultiAssets) -> Weight {
//TODO: This should not be multiploed by assets, we are already burning worse case
// assets
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
}
fn expect_asset(assets: &MultiAssets) -> Weight {
// TODO same here
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
}
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
Expand Down
4 changes: 0 additions & 4 deletions runtime/shibuya/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ pub type XcmOriginToTransactDispatchOrigin = (
);

parameter_types! {
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
// For the PoV size, we estimate 64 kB per instruction - which will is once again very conservative.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, astar_primitives::xcm::DEFAULT_PROOF_SIZE);
pub const MaxInstructions: u32 = 100;
}

Expand Down Expand Up @@ -171,7 +168,6 @@ pub type ShibuyaXcmFungibleFeeHandler = XcmFungibleFeeHandler<
TreasuryAccountId,
>;

// pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
pub type Weigher = WeightInfoBounds<
crate::weights::xcm_instruction_benchmarks::ShibuyaXcmWeight<RuntimeCall>,
RuntimeCall,
Expand Down
4 changes: 2 additions & 2 deletions runtime/shiden/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ pub type XcmOriginToTransactDispatchOrigin = (

parameter_types! {
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
// For the PoV size, we estimate 64 kB per instruction - which will is once again very conservative.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, astar_primitives::xcm::DEFAULT_PROOF_SIZE);
// For the PoV size, we estimate 4 kB per instruction. This will be changed when we benchmark the instructions.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 4 * 1024);
pub const MaxInstructions: u32 = 100;
}

Expand Down

0 comments on commit bbcff0b

Please sign in to comment.