Skip to content

Commit

Permalink
fix benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Feb 16, 2024
1 parent 5b29c0e commit 824e3ed
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 49 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions polkadot-parachains/integritee-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down
66 changes: 25 additions & 41 deletions polkadot-parachains/integritee-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
Expand All @@ -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;
Expand Down Expand Up @@ -902,23 +888,21 @@ impl pallet_asset_conversion::Config for Runtime {
type PoolSetupFeeAsset = Native;
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
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<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
Native,
parachain_info::Pallet<Runtime>,
xcm_config::AssetsPalletIndex,
>;
type BenchmarkHelper = ();
}

parameter_types! {
pub AssetsPalletIndex: u32 = <Assets as PalletInfoAccess>::index() as u32;
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub const Native: NativeOrWithId<u32> = 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! {
Expand Down
15 changes: 9 additions & 6 deletions scripts/dump-essential-balances.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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"
Expand All @@ -54,7 +56,8 @@ echo "*** Sibling 2015"
print_balances 5Eg2fntM2SfbNedAZi2Bbbwtmj9fxANGtkoCAr2y3g3JqoH4
echo "*** Sibling 1000"
print_balances 5Eg2fntNprdN3FgH4sfEaaZhYtddZQSQUqvYJ1f2mLtinVhV

echo "*** PoolReserve"
print_balances 2PUnzrp5fQnwWJgoNexyUaysy4i7KN9MNDesMa1BdyyrAKar



Expand Down

0 comments on commit 824e3ed

Please sign in to comment.