Skip to content

Commit ae891f1

Browse files
committed
Merge remote-tracking branch 'origin/master' into add-vesting-benchmarks
2 parents a6ebb47 + 29ee65a commit ae891f1

File tree

24 files changed

+223
-34
lines changed

24 files changed

+223
-34
lines changed

Cargo.dev.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ resolver = "2"
3131
split-debuginfo = "unpacked"
3232

3333
[workspace.dependencies]
34+
hex-literal = { version = "1.0.0" }
3435
log = { version = "0.4.25", default-features = false }
3536
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
3637
serde = { version = "1.0.214" }
3738
parity-scale-codec = { version = "3.6.12", default-features = false, features = ["max-encoded-len"] }
39+
num-traits = { version = "0.2.14", default-features = false }
40+
impl-trait-for-tuples = "0.2.2"
41+
paste = "1.0"
3842

3943
cumulus-pallet-xcm = { version = "0.22.0", default-features = false }
4044
cumulus-primitives-core = { version = "0.21.0", default-features = false }

asset-registry/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ std = [
7878
runtime-benchmarks = [
7979
"frame-support/runtime-benchmarks",
8080
"frame-system/runtime-benchmarks",
81+
"orml-tokens/runtime-benchmarks",
8182
"pallet-xcm/runtime-benchmarks",
8283
"polkadot-runtime-common/runtime-benchmarks",
8384
"sp-runtime/runtime-benchmarks",

asset-registry/src/mock/para.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl orml_tokens::Config for Runtime {
7777
type MaxReserves = ();
7878
type MaxLocks = ConstU32<50>;
7979
type DustRemovalWhitelist = Nothing;
80+
#[cfg(feature = "runtime-benchmarks")]
81+
type BenchmarkHelper = ();
8082
}
8183

8284
#[derive(scale_info::TypeInfo, Encode, Decode, Clone, Eq, PartialEq, Debug, MaxEncodedLen, DecodeWithMemTracking)]

authority/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010
[dependencies]
1111
parity-scale-codec = { workspace = true }
1212
scale-info = { workspace = true }
13-
serde = { version = "1.0.145", optional = true }
13+
serde = { workspace = true, optional = true }
1414

1515
frame-support = { workspace = true }
1616
frame-system = { workspace = true }

benchmarking/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sp-std = { workspace = true }
2525
sp-storage = { workspace = true }
2626

2727
[dev-dependencies]
28-
hex-literal = "1.0.0"
28+
hex-literal = { workspace = true }
2929

3030
frame-system = { workspace = true, features = ["std"] }
3131

currencies/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ orml-utilities = { path = "../utilities", version = "1.5.0", default-features =
2525
pallet-balances = { workspace = true, features = ["std"] }
2626
sp-core = { workspace = true, features = ["std"] }
2727

28-
orml_tokens = { package = "orml-tokens", path = "../tokens" }
28+
orml-tokens = { path = "../tokens", features = ["std"] }
2929

3030
[features]
3131
default = [ "std" ]
@@ -41,6 +41,12 @@ std = [
4141
"sp-runtime/std",
4242
"sp-std/std",
4343
]
44+
runtime-benchmarks = [
45+
"frame-support/runtime-benchmarks",
46+
"frame-system/runtime-benchmarks",
47+
"orml-tokens/runtime-benchmarks",
48+
"sp-runtime/runtime-benchmarks",
49+
]
4450
try-runtime = [
4551
"frame-support/try-runtime",
4652
"frame-system/try-runtime",

currencies/src/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ impl orml_tokens::Config for Runtime {
8585
type MaxReserves = ConstU32<100_000>;
8686
type ReserveIdentifier = ReserveIdentifier;
8787
type DustRemovalWhitelist = Nothing;
88+
#[cfg(feature = "runtime-benchmarks")]
89+
type BenchmarkHelper = ();
8890
}
8991

9092
pub const NATIVE_CURRENCY_ID: CurrencyId = 1;

nft/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = ["Acala Developers"]
88
edition = "2021"
99

1010
[dependencies]
11-
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
11+
parity-scale-codec = { workspace = true }
1212
scale-info = { workspace = true }
1313
serde = { workspace = true, optional = true }
1414

oracle/src/benchmarking.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
pub use crate::*;
22

3-
use frame_benchmarking::v2::{impl_test_function, instance_benchmarks, whitelisted_caller};
4-
3+
use frame_benchmarking::v2::*;
54
use frame_support::assert_ok;
65
use frame_system::{Pallet as System, RawOrigin};
76

7+
/// Helper trait for benchmarking.
8+
pub trait BenchmarkHelper<OracleKey, OracleValue, L: Get<u32>> {
9+
/// Returns a list of `(oracle_key, oracle_value)` pairs to be used for
10+
/// benchmarking.
11+
///
12+
/// NOTE: User should ensure to at least submit two values, otherwise the
13+
/// benchmark linear analysis might fail.
14+
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>;
15+
}
16+
17+
impl<OracleKey, OracleValue, L: Get<u32>> BenchmarkHelper<OracleKey, OracleValue, L> for () {
18+
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> {
19+
BoundedVec::default()
20+
}
21+
}
22+
823
#[instance_benchmarks]
924
mod benchmarks {
1025
use super::*;

oracle/src/lib.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,18 @@ use sp_std::{prelude::*, vec};
4343
pub use crate::default_combine_data::DefaultCombineData;
4444

4545
#[cfg(feature = "runtime-benchmarks")]
46-
pub mod benchmarking;
46+
mod benchmarking;
4747

4848
mod default_combine_data;
4949
mod mock;
5050
mod tests;
5151
mod weights;
5252

53+
#[cfg(feature = "runtime-benchmarks")]
54+
pub use benchmarking::BenchmarkHelper;
5355
pub use module::*;
5456
pub use weights::WeightInfo;
5557

56-
#[cfg(feature = "runtime-benchmarks")]
57-
/// Helper trait for benchmarking.
58-
pub trait BenchmarkHelper<OracleKey, OracleValue, L: Get<u32>> {
59-
/// Returns a list of `(oracle_key, oracle_value)` pairs to be used for
60-
/// benchmarking.
61-
///
62-
/// NOTE: User should ensure to at least submit two values, otherwise the
63-
/// benchmark linear analysis might fail.
64-
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L>;
65-
}
66-
67-
#[cfg(feature = "runtime-benchmarks")]
68-
impl<OracleKey, OracleValue, L: Get<u32>> BenchmarkHelper<OracleKey, OracleValue, L> for () {
69-
fn get_currency_id_value_pairs() -> BoundedVec<(OracleKey, OracleValue), L> {
70-
BoundedVec::default()
71-
}
72-
}
73-
7458
#[frame_support::pallet]
7559
pub mod module {
7660
use super::*;

0 commit comments

Comments
 (0)