Skip to content

Commit ceda41a

Browse files
committed
XcmExecutorUtils pallet (#5)
* Assets filtering pallet on master * Changed structure to have a default and origins policies * Rename, tests, isTeleportFilter * Set teleport policies on genesis build * Test * Moved tests * Updated names * fmt * IKnit benchmarks * Removed Default for GenesisConfig. serde on std * Benchmarks and serde * fmt * Cleanup * Default policies mocks and tests * fmt
1 parent d737a3c commit ceda41a

File tree

9 files changed

+1275
-0
lines changed

9 files changed

+1275
-0
lines changed

Cargo.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ members = [
33
"client/orchestrator-chain-interface",
44
"container-chain-pallets/*",
55
"container-chain-primitives/*",
6+
"pallets/*",
67
"primitives/*",
78
"test-sproof-builder"
89
]

pallets/xcm-executor-utils/Cargo.toml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[package]
2+
name = "pallet-xcm-executor-utils"
3+
authors = { workspace = true }
4+
description = "XCM Executor configuration utility pallet"
5+
edition = "2021"
6+
license = "GPL-3.0-only"
7+
version = "0.1.0"
8+
9+
[package.metadata.docs.rs]
10+
targets = ["x86_64-unknown-linux-gnu"]
11+
12+
[dependencies]
13+
serde = { workspace = true, features = ["derive"] }
14+
15+
frame-benchmarking = { workspace = true, optional = true }
16+
frame-support = { workspace = true }
17+
frame-system = { workspace = true }
18+
parity-scale-codec = { workspace = true, features = [
19+
"derive",
20+
"max-encoded-len",
21+
] }
22+
scale-info = { workspace = true }
23+
sp-core = { workspace = true }
24+
sp-io = { workspace = true }
25+
sp-runtime = { workspace = true }
26+
sp-std = { workspace = true }
27+
staging-xcm = { workspace = true }
28+
29+
[features]
30+
default = ["std"]
31+
std = [
32+
"frame-benchmarking/std",
33+
"frame-support/std",
34+
"frame-system/std",
35+
"parity-scale-codec/std",
36+
"scale-info/std",
37+
"serde/std",
38+
"sp-runtime/std",
39+
"sp-std/std",
40+
"staging-xcm/std",
41+
]
42+
runtime-benchmarks = [
43+
"frame-benchmarking",
44+
"frame-benchmarking/runtime-benchmarks",
45+
"frame-support/runtime-benchmarks",
46+
"frame-system/runtime-benchmarks",
47+
"sp-runtime/runtime-benchmarks",
48+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Copyright (C) Moondance Labs Ltd.
2+
// This file is part of Tanssi.
3+
4+
// Tanssi is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Tanssi is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>
16+
17+
#![cfg(feature = "runtime-benchmarks")]
18+
19+
//! Benchmarking
20+
use {
21+
crate::{Call, Config, DefaultTrustPolicy, MultiLocation, Pallet, TrustPolicy},
22+
frame_benchmarking::{impl_benchmark_test_suite, v2::*},
23+
frame_system::RawOrigin,
24+
sp_std::vec,
25+
staging_xcm::v3::Junctions::Here,
26+
};
27+
28+
#[benchmarks]
29+
mod benchmarks {
30+
use super::*;
31+
32+
#[benchmark]
33+
fn set_reserve_policy() -> Result<(), BenchmarkError> {
34+
#[extrinsic_call]
35+
_(
36+
RawOrigin::Root,
37+
MultiLocation {
38+
parents: 1,
39+
interior: Here,
40+
},
41+
TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never),
42+
);
43+
44+
// assert!(
45+
Ok(())
46+
}
47+
48+
#[benchmark]
49+
fn remove_reserve_policy() -> Result<(), BenchmarkError> {
50+
let _ = Pallet::<T>::set_reserve_policy(
51+
RawOrigin::Root.into(),
52+
MultiLocation {
53+
parents: 1,
54+
interior: Here,
55+
},
56+
TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never),
57+
);
58+
59+
#[extrinsic_call]
60+
_(
61+
RawOrigin::Root,
62+
MultiLocation {
63+
parents: 1,
64+
interior: Here,
65+
},
66+
);
67+
assert!(Pallet::<T>::reserve_policy(MultiLocation {
68+
parents: 1,
69+
interior: Here,
70+
})
71+
.is_none());
72+
73+
Ok(())
74+
}
75+
76+
#[benchmark]
77+
fn set_teleport_policy() -> Result<(), BenchmarkError> {
78+
#[extrinsic_call]
79+
_(
80+
RawOrigin::Root,
81+
MultiLocation {
82+
parents: 1,
83+
interior: Here,
84+
},
85+
TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never),
86+
);
87+
88+
// assert!(
89+
Ok(())
90+
}
91+
92+
#[benchmark]
93+
fn remove_teleport_policy() -> Result<(), BenchmarkError> {
94+
let _ = Pallet::<T>::set_teleport_policy(
95+
RawOrigin::Root.into(),
96+
MultiLocation {
97+
parents: 1,
98+
interior: Here,
99+
},
100+
TrustPolicy::DefaultTrustPolicy(DefaultTrustPolicy::Never),
101+
);
102+
103+
#[extrinsic_call]
104+
_(
105+
RawOrigin::Root,
106+
MultiLocation {
107+
parents: 1,
108+
interior: Here,
109+
},
110+
);
111+
assert!(Pallet::<T>::teleport_policy(MultiLocation {
112+
parents: 1,
113+
interior: Here,
114+
})
115+
.is_none());
116+
117+
Ok(())
118+
}
119+
120+
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
121+
}

0 commit comments

Comments
 (0)