From 824e3ed94c5594603fdeeb4b1dc20fcce4b3346a Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Fri, 16 Feb 2024 17:35:33 +0100 Subject: [PATCH] fix benchmarking --- Cargo.lock | 13 ++++ Cargo.toml | 2 + .../integritee-runtime/Cargo.toml | 4 +- .../integritee-runtime/src/lib.rs | 66 +++++++------------ scripts/dump-essential-balances.sh | 15 +++-- 5 files changed, 51 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27462965..f325cfe2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4109,6 +4109,17 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-num-traits" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951641f13f873bff03d4bf19ae8bec531935ac0ac2cc775f84d7edfdcfed3f17" +dependencies = [ + "integer-sqrt", + "num-traits", + "uint", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -4390,6 +4401,7 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-common", "polkadot-runtime-parachains", + "primitive-types", "scale-info", "sp-api", "sp-block-builder", @@ -9172,6 +9184,7 @@ checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", + "impl-num-traits", "impl-serde", "scale-info", "uint", diff --git a/Cargo.toml b/Cargo.toml index 4aa63da4..02ab7316 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,8 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive serde = { version = "1.0.195", features = ["derive"] } serde_json = "1.0" smallvec = "1.11.0" +# num-traits feature needed for dex integer sq root: +primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "num-traits", "scale-info"] } # integritee pallets pallet-asset-registry = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.6.0" } diff --git a/polkadot-parachains/integritee-runtime/Cargo.toml b/polkadot-parachains/integritee-runtime/Cargo.toml index 0657d55e..54d2fcd7 100644 --- a/polkadot-parachains/integritee-runtime/Cargo.toml +++ b/polkadot-parachains/integritee-runtime/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" log = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } - +primitive-types = { workspace = true } integritee-parachains-common = { path = "../common", default-features = false } # Substrate dependencies @@ -67,7 +67,6 @@ parachains-common = { workspace = true } polkadot-parachain-primitives = { workspace = true } polkadot-runtime-common = { workspace = true } sp-api = { workspace = true } -#sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } @@ -159,6 +158,7 @@ std = [ "parity-scale-codec/std", "polkadot-parachain-primitives/std", "polkadot-runtime-common/std", + "primitive-types/std", "scale-info/std", "sp-api/std", # "sp-arithmetic/std", diff --git a/polkadot-parachains/integritee-runtime/src/lib.rs b/polkadot-parachains/integritee-runtime/src/lib.rs index ef00305e..db2d57b2 100644 --- a/polkadot-parachains/integritee-runtime/src/lib.rs +++ b/polkadot-parachains/integritee-runtime/src/lib.rs @@ -24,34 +24,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use frame_support::{ - ord_parameter_types, - traits::{ - fungible::HoldConsideration, - tokens::{imbalance::ResolveAssetTo, PayFromAccount}, - AsEnsureOriginWithArg, ConstBool, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, - InstanceFilter, LinearStoragePrice, OnUnbalanced, - }, -}; -use pallet_collective; -use parachains_common::AssetIdForTrustBackedAssets; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, ConstU32, OpaqueMetadata}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{ - AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup, - IntegerSquareRoot, - }, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, -}; -use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; -// A few exports that help ease life for downstream crates. use cumulus_primitives_core::AggregateMessageOrigin; pub use frame_support::{ construct_runtime, @@ -71,9 +43,12 @@ pub use frame_support::{ use frame_support::{ derive_impl, genesis_builder_helper::{build_config, create_default_config}, + ord_parameter_types, traits::{ - fungible::{NativeFromLeft, NativeOrWithId, UnionOf}, - tokens::ConversionFromAssetBalance, + fungible::{HoldConsideration, NativeFromLeft, NativeOrWithId, UnionOf}, + tokens::{imbalance::ResolveAssetTo, ConversionFromAssetBalance, PayFromAccount}, + AsEnsureOriginWithArg, ConstBool, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, + InstanceFilter, LinearStoragePrice, OnUnbalanced, }, weights::ConstantMultiplier, }; @@ -93,19 +68,30 @@ pub use integritee_parachains_common::{ use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset}; pub use pallet_balances::Call as BalancesCall; pub use pallet_claims; +use pallet_collective; pub use pallet_enclave_bridge; pub use pallet_sidechain; pub use pallet_teeracle; pub use pallet_teerex::Call as TeerexCall; pub use pallet_timestamp::Call as TimestampCall; -use parachains_common::message_queue::NarrowOriginToSibling; +use parachains_common::{message_queue::NarrowOriginToSibling, AssetIdForTrustBackedAssets}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -//use sp_arithmetic::traits::{BaseArithmetic, Unsigned}; -use sp_core::ConstU128; +use sp_api::impl_runtime_apis; +use sp_core::{crypto::KeyTypeId, ConstU128, ConstU32, OpaqueMetadata}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -use sp_runtime::RuntimeDebug; +use sp_runtime::{ + create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, RuntimeDebug, +}; pub use sp_runtime::{Perbill, Permill}; +use sp_std::prelude::*; +#[cfg(feature = "std")] +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; mod helpers; mod weights; @@ -902,23 +888,21 @@ impl pallet_asset_conversion::Config for Runtime { type PoolSetupFeeAsset = Native; type PoolSetupFeeTarget = ResolveAssetTo; type LiquidityWithdrawalFee = LiquidityWithdrawalFee; - type LPFee = ConstU32<3>; + type LPFee = ConstU32<3>; // 0.3% swap fee type PalletId = AssetConversionPalletId; type MaxSwapPathLength = ConstU32<3>; type MintMinLiquidity = ConstU128<100>; type WeightInfo = weights::pallet_asset_conversion::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory< - Native, - parachain_info::Pallet, - xcm_config::AssetsPalletIndex, - >; + type BenchmarkHelper = (); } parameter_types! { + pub AssetsPalletIndex: u32 = ::index() as u32; pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon"); pub const Native: NativeOrWithId = NativeOrWithId::Native; - pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0); + // we charge no fee for liquidity withdrawal + pub const LiquidityWithdrawalFee: Permill = Permill::from_perthousand(0); } ord_parameter_types! { diff --git a/scripts/dump-essential-balances.sh b/scripts/dump-essential-balances.sh index c76368da..bf2139ae 100755 --- a/scripts/dump-essential-balances.sh +++ b/scripts/dump-essential-balances.sh @@ -11,7 +11,7 @@ # compare balances pre/post YOUR THING # diff -y -W 80 fee1.txt fee2.txt -ASSET_HUB="ws://127.0.0.1:9954" +#ASSET_HUB="ws://127.0.0.1:9954" INTEGRITEE="ws://127.0.0.1:9944" ROCOCO="ws://127.0.0.1:9999" @@ -20,10 +20,10 @@ TREASURY=5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z function print_balances() { echo "*** print balances for $1" - echo "Asset Hub ROC" - polkadot-js-api --ws $ASSET_HUB query.system.account $1 | jq .account.data.free - echo "Asset Hub TEER" - polkadot-js-api --ws $ASSET_HUB query.foreignAssets.account '{ "parents": "1", "interior": { "X1": { "Parachain": "2015" }}}' $1 | jq .account.balance + #echo "Asset Hub ROC" + #polkadot-js-api --ws $ASSET_HUB query.system.account $1 | jq .account.data.free + #echo "Asset Hub TEER" + #polkadot-js-api --ws $ASSET_HUB query.foreignAssets.account '{ "parents": "1", "interior": { "X1": { "Parachain": "2015" }}}' $1 | jq .account.balance #integritee-cli -p $ASSET_HUB balance $1 echo "Rococo ROC" polkadot-js-api --ws $ROCOCO query.system.account $1 | jq .account.data.free @@ -46,6 +46,8 @@ polkadot-js-api --ws $INTEGRITEE query.assets.account 0 $TREASURY | jq .account. echo "*** Alice" print_balances 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +echo "*** Bob" +print_balances 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty echo "*** Parachain 2015" print_balances 5Ec4AhPXwiUhF3u21i56Uxc5XFUNEkKAq79kutWUAx1jyz47 echo "*** Parachain 1000" @@ -54,7 +56,8 @@ echo "*** Sibling 2015" print_balances 5Eg2fntM2SfbNedAZi2Bbbwtmj9fxANGtkoCAr2y3g3JqoH4 echo "*** Sibling 1000" print_balances 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV - +echo "*** PoolReserve" +print_balances 2PUnzrp5fQnwWJgoNexyUaysy4i7KN9MNDesMa1BdyyrAKar