Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable foreign asset teleport #249

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions polkadot-parachains/integritee-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ frame-try-runtime = { git = "https://github.com/paritytech/substrate.git", defau

# pallets
pallet-aura = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-asset-registry = { default-features = false, git = "https://github.com/paritytech/trappist", branch = "polkadot-v1.0.0" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-bounties = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-child-bounties = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
Expand All @@ -52,6 +54,7 @@ pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "
pallet-treasury = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-utility = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
pallet-vesting = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-withdraw-teleport = { default-features = false, git = "https://github.com/paritytech/trappist", branch = "polkadot-v1.0.0" }

# integritee pallets
pallet-claims = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v1.0.0" }
Expand Down Expand Up @@ -127,6 +130,8 @@ std = [
"orml-xcm/std",
"orml-xtokens/std",
"pallet-aura/std",
"pallet-assets/std",
"pallet-asset-registry/std",
"pallet-balances/std",
"pallet-bounties/std",
"pallet-child-bounties/std",
Expand All @@ -147,6 +152,7 @@ std = [
"pallet-treasury/std",
"pallet-utility/std",
"pallet-vesting/std",
"pallet-withdraw-teleport/std",
"pallet-xcm-transactor/std",
"pallet-xcm/std",
"parachain-info/std",
Expand Down Expand Up @@ -182,6 +188,8 @@ runtime-benchmarks = [
"xcm-builder/runtime-benchmarks",
# actual pallets to be benchmarked
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-registry/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-bounties/runtime-benchmarks",
"pallet-child-bounties/runtime-benchmarks",
Expand All @@ -200,6 +208,7 @@ runtime-benchmarks = [
"pallet-treasury/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-withdraw-teleport/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
]

Expand All @@ -216,6 +225,8 @@ try-runtime = [
"orml-xcm/try-runtime",
"parachain-info/try-runtime",
"pallet-aura/try-runtime",
"pallet-assets/try-runtime",
"pallet-asset-registry/try-runtime",
"pallet-balances/try-runtime",
"pallet-bounties/try-runtime",
"pallet-child-bounties/try-runtime",
Expand All @@ -235,6 +246,7 @@ try-runtime = [
"pallet-treasury/try-runtime",
"pallet-vesting/try-runtime",
"pallet-utility/try-runtime",
"pallet-withdraw-teleport/try-runtime",
"pallet-xcm/try-runtime",
"pallet-xcm-transactor/try-runtime",
]
Expand Down
69 changes: 67 additions & 2 deletions polkadot-parachains/integritee-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ pub use parachains_common::{
AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, MILLISECS_PER_BLOCK,
};
use parachains_common::{
AuraId, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
AssetIdForTrustBackedAssets, AuraId, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS,
MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};

pub use pallet_balances::Call as BalancesCall;
Expand All @@ -89,6 +89,7 @@ pub use pallet_enclave_bridge;
pub use pallet_sidechain;
pub use pallet_teeracle;
pub use pallet_teerex::Call as TeerexCall;
use sp_runtime::traits::ConstU128;

mod helpers;
mod weights;
Expand Down Expand Up @@ -744,6 +745,64 @@ impl orml_xcm::Config for Runtime {
type SovereignOrigin = EnsureRoot<AccountId>;
}

pub type AssetBalance = Balance;

impl pallet_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = AssetBalance;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
type AssetId = AssetIdForTrustBackedAssets;
type AssetIdParameter = codec::Compact<AssetIdForTrustBackedAssets>;
type Currency = Balances;
type CreateOrigin = EnsureRootOrMoreThanHalfCouncil;
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDeposit = ConstU128<{ TEER }>;
type AssetAccountDeposit = ConstU128<{ TEER }>;
type MetadataDepositBase = ConstU128<{ TEER }>;
type MetadataDepositPerByte = ConstU128<{ 10 * MILLITEER }>;
type ApprovalDeposit = ConstU128<{ 10 * MILLITEER }>;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
type CallbackHandle = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

#[cfg(feature = "runtime-benchmarks")]
pub struct AssetRegistryBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pallet_asset_registry::BenchmarkHelper<AssetIdForTrustBackedAssets>
for AssetRegistryBenchmarkHelper
{
fn get_registered_asset() -> AssetIdForTrustBackedAssets {
use sp_runtime::traits::StaticLookup;

let root = frame_system::RawOrigin::Root.into();
let asset_id = 1;
let caller = frame_benchmarking::whitelisted_caller();
let caller_lookup = <Runtime as frame_system::Config>::Lookup::unlookup(caller);
Assets::force_create(root, asset_id.into(), caller_lookup, true, 1)
.expect("Should have been able to force create asset");
asset_id
}
}

impl pallet_asset_registry::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ReserveAssetModifierOrigin = EnsureRoot<Self::AccountId>;
type Assets = Assets;
type WeightInfo = weights::pallet_asset_registry::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = AssetRegistryBenchmarkHelper;
}

impl pallet_withdraw_teleport::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_withdraw_teleport::WeightInfo<Runtime>;
}

construct_runtime!(
pub enum Runtime
{
Expand Down Expand Up @@ -787,6 +846,9 @@ construct_runtime!(
XTokens: orml_xtokens::{Pallet, Call, Storage, Event<T>} = 34,
OrmlXcm: orml_xcm = 35,
XcmTransactor: pallet_xcm_transactor = 36,
Assets: pallet_assets = 41,
AssetRegistry: pallet_asset_registry::{Pallet, Call, Storage, Event<T>} = 42,
WithdrawTeleport: pallet_withdraw_teleport = 43,

// Integritee pallets.
Teerex: pallet_teerex::{Pallet, Call, Config<T>, Storage, Event<T>} = 50,
Expand Down Expand Up @@ -854,6 +916,8 @@ extern crate frame_benchmarking;
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_asset_registry, AssetRegistry]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_bounties, Bounties]
[pallet_child_bounties, ChildBounties]
Expand All @@ -877,6 +941,7 @@ mod benches {
[pallet_vesting, Vesting]
[pallet_xcm, PolkadotXcm]
[pallet_utility, Utility]
[pallet_withdraw_teleport, WithdrawTeleport]
);
}

Expand Down
3 changes: 3 additions & 0 deletions polkadot-parachains/integritee-runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#![allow(clippy::all)]

pub mod frame_system;
pub mod pallet_asset_registry;
pub mod pallet_assets;
pub mod pallet_balances;
pub mod pallet_bounties;
pub mod pallet_child_bounties;
Expand All @@ -22,4 +24,5 @@ pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_withdraw_teleport;
pub mod pallet_xcm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// This file is part of Trappist.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Autogenerated weights for `pallet_asset_registry`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-10-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-nbnwcyh-project-647-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("trappist-dev")`, DB CACHE: 1024

// Executed Command:
// ./target/production/trappist-node
// benchmark
// pallet
// --chain=trappist-dev
// --steps=50
// --repeat=20
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_asset_registry
// --extrinsic=*
// --wasm-execution=compiled
// --header=./templates/file_header.txt
// --output=./runtime/trappist/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]

use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;

/// Weight functions for `pallet_asset_registry`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_asset_registry::WeightInfo for WeightInfo<T> {
/// Storage: `Assets::Asset` (r:1 w:0)
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::AssetIdMultiLocation` (r:1 w:1)
/// Proof: `AssetRegistry::AssetIdMultiLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::AssetMultiLocationId` (r:0 w:1)
/// Proof: `AssetRegistry::AssetMultiLocationId` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
fn register_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `123`
// Estimated: `4087`
// Minimum execution time: 19_271_000 picoseconds.
Weight::from_parts(19_590_000, 0)
.saturating_add(Weight::from_parts(0, 4087))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `AssetRegistry::AssetIdMultiLocation` (r:1 w:1)
/// Proof: `AssetRegistry::AssetIdMultiLocation` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `AssetRegistry::AssetMultiLocationId` (r:0 w:1)
/// Proof: `AssetRegistry::AssetMultiLocationId` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
fn unregister_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `107`
// Estimated: `4087`
// Minimum execution time: 15_981_000 picoseconds.
Weight::from_parts(16_448_000, 0)
.saturating_add(Weight::from_parts(0, 4087))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
}
Loading
Loading