From 39fb1d0a12730931b211702948a6095855576129 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Sat, 11 Jun 2022 17:53:29 +0200
Subject: [PATCH] fix(gdev): fix runtime benchmarks compilation

---
 Cargo.lock                                    |  11 ++
 Cargo.toml                                    |   8 +-
 file_header.txt                               |  15 +++
 .../universal-dividend/src/benchmarking.rs    |  52 --------
 pallets/universal-dividend/src/lib.rs         |   4 +-
 runtime/common/Cargo.toml                     | 107 +++++------------
 runtime/common/src/apis.rs                    | 113 +++++++++++-------
 runtime/gdev/Cargo.toml                       |  41 +++++--
 runtime/gdev/src/lib.rs                       |   4 +
 9 files changed, 167 insertions(+), 188 deletions(-)
 create mode 100644 file_header.txt
 delete mode 100644 pallets/universal-dividend/src/benchmarking.rs

diff --git a/Cargo.lock b/Cargo.lock
index f7fbb6a6a..2c04c3ab6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -855,8 +855,10 @@ name = "common-runtime"
 version = "0.8.0-dev"
 dependencies = [
  "duniter-primitives",
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
+ "frame-system-benchmarking",
  "log",
  "pallet-authority-members",
  "pallet-babe",
@@ -873,6 +875,7 @@ dependencies = [
  "parity-scale-codec",
  "scale-info",
  "serde",
+ "serde_derive",
  "smallvec",
  "sp-arithmetic",
  "sp-consensus-babe",
@@ -2313,6 +2316,7 @@ dependencies = [
  "parity-scale-codec",
  "scale-info",
  "serde",
+ "serde_derive",
  "sp-api",
  "sp-arithmetic",
  "sp-authority-discovery",
@@ -5036,6 +5040,7 @@ name = "pallet-im-online"
 version = "4.0.0-dev"
 source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc"
 dependencies = [
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "log",
@@ -5073,6 +5078,7 @@ name = "pallet-multisig"
 version = "4.0.0-dev"
 source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc"
 dependencies = [
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "parity-scale-codec",
@@ -5093,6 +5099,7 @@ dependencies = [
  "pallet-balances",
  "parity-scale-codec",
  "scale-info",
+ "serde",
  "sp-runtime",
  "sp-staking",
  "sp-std",
@@ -5134,6 +5141,7 @@ name = "pallet-proxy"
 version = "4.0.0-dev"
 source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc"
 dependencies = [
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "parity-scale-codec",
@@ -5148,6 +5156,7 @@ name = "pallet-scheduler"
 version = "4.0.0-dev"
 source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc"
 dependencies = [
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "log",
@@ -5205,6 +5214,7 @@ dependencies = [
  "parity-scale-codec",
  "scale-info",
  "sp-inherents",
+ "sp-io",
  "sp-runtime",
  "sp-std",
  "sp-timestamp",
@@ -5326,6 +5336,7 @@ name = "pallet-utility"
 version = "4.0.0-dev"
 source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-02#80f060dfad0363af03dbecbe39c6fa9b99042acc"
 dependencies = [
+ "frame-benchmarking",
  "frame-support",
  "frame-system",
  "parity-scale-codec",
diff --git a/Cargo.toml b/Cargo.toml
index e826d2d80..9a42061a0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,12 +23,12 @@ g1 = ["g1-runtime"]
 gdev = ["gdev-runtime"]
 gtest = ["gtest-runtime"]
 runtime-benchmarks = [
-    'g1-runtime',
-    'g1-runtime/runtime-benchmarks',
+    #'g1-runtime',
+    #'g1-runtime/runtime-benchmarks',
     'gdev-runtime',
     'gdev-runtime/runtime-benchmarks',
-    'gtest-runtime',
-    'gtest-runtime/runtime-benchmarks',
+    #'gtest-runtime',
+    #'gtest-runtime/runtime-benchmarks',
 ]
 try-runtime = [
 	"g1-runtime/try-runtime",
diff --git a/file_header.txt b/file_header.txt
new file mode 100644
index 000000000..33e702036
--- /dev/null
+++ b/file_header.txt
@@ -0,0 +1,15 @@
+// Copyright 2021-2022 Axiom-Team
+//
+// This file is part of Duniter-v2S.
+//
+// Duniter-v2S is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, version 3 of the License.
+//
+// Duniter-v2S is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
diff --git a/pallets/universal-dividend/src/benchmarking.rs b/pallets/universal-dividend/src/benchmarking.rs
deleted file mode 100644
index 76a3c5905..000000000
--- a/pallets/universal-dividend/src/benchmarking.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2021 Axiom-Team
-//
-// This file is part of Substrate-Libre-Currency.
-//
-// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published by
-// the Free Software Foundation, version 3 of the License.
-//
-// Substrate-Libre-Currency is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
-
-//! Benchmarking setup for pallet-universal-dividend
-
-use super::*;
-
-#[allow(unused)]
-use crate::Pallet as UniversalDividend;
-use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
-use frame_system::RawOrigin;
-
-// Create state for use in `on_initialize`.
-fn create_state<T: Config>(n: u32) -> Result<(), &'static str> {
-    <LastReevalStorage<T>>::put(LastReeval {
-        members_count: T::MembersCount::get(),
-        monetary_mass: T::Currency::total_issuance(),
-        ud_amount: new_ud_amount,
-    });
-    Ok(())
-}
-
-benchmarks! {
-    create_ud {
-        run_to_block(2);
-    }: UniversalDividend::on_initialize()
-    verify {
-        assert_eq!(System::events().len(), 7);
-    }
-}
-
-impl_benchmark_test_suite!(
-    UniversalDividend,
-    crate::mock::new_test_ext(UniversalDividendConfig {
-        first_ud: 1_000,
-        initial_monetary_mass: 0,
-    }),
-    crate::mock::Test,
-);
diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs
index 9b57563bb..a34c7a0ce 100644
--- a/pallets/universal-dividend/src/lib.rs
+++ b/pallets/universal-dividend/src/lib.rs
@@ -24,8 +24,8 @@ mod mock;
 #[cfg(test)]
 mod tests;
 
-#[cfg(feature = "runtime-benchmarks")]
-mod benchmarking;
+/*#[cfg(feature = "runtime-benchmarks")]
+mod benchmarking;*/
 
 use frame_support::traits::{tokens::ExistenceRequirement, Currency};
 use sp_arithmetic::{
diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml
index e26cc3c97..85964c294 100644
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -8,13 +8,16 @@ edition = '2018'
 
 [features]
 runtime-benchmarks = [
+	"frame-benchmarking/runtime-benchmarks",
     'frame-support/runtime-benchmarks',
+    'frame-system-benchmarking',
     'frame-system/runtime-benchmarks',
+	"pallet-babe/runtime-benchmarks",
     'pallet-certification/runtime-benchmarks',
     'pallet-duniter-wot/runtime-benchmarks',
     'pallet-identity/runtime-benchmarks',
     'pallet-membership/runtime-benchmarks',
-    'pallet-treasury/std',
+    'pallet-treasury/runtime-benchmarks',
     'pallet-ud-accounts-storage/runtime-benchmarks',
     'sp-runtime/runtime-benchmarks',
 ]
@@ -35,12 +38,13 @@ std = [
     'pallet-provide-randomness/std',
     'pallet-treasury/std',
     'pallet-ud-accounts-storage/std',
-    'serde',
+	"serde/std",
+	"serde_derive",
     'sp-arithmetic/std',
     'sp-core/std',
     'sp-membership/std',
     'sp-runtime/std',
-    'sp-std/std'
+    'sp-std/std',
 ]
 try-runtime = [
 	"frame-support/try-runtime",
@@ -49,7 +53,6 @@ try-runtime = [
 	"pallet-grandpa/try-runtime",
 ]
 
-
 [dependencies]
 duniter-primitives = { path = '../../primitives/duniter', default-features = false }
 pallet-authority-members = { path = '../../pallets/authority-members', default-features = false }
@@ -63,80 +66,30 @@ pallet-ud-accounts-storage = { path = '../../pallets/ud-accounts-storage', defau
 sp-membership = { path = '../../primitives/membership', default-features = false }
 
 # Crates.io
+codec = { package = "parity-scale-codec", version = "2.3.1", features = ["derive"], default-features = false }
 log = { version = "0.4.14", default-features = false }
+scale-info = { version = "1.0", default-features = false, features = ["derive"] }
+serde = { version = "1.0.101", default-features = false }
+serde_derive = { version = "1.0.101", optional = true }
 smallvec = "1.6.1"
 
 # Substrate
-scale-info = { version = "1.0", default-features = false, features = ["derive"] }
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '2.3.1'
-
-[dependencies.frame-support]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.frame-system]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.pallet-babe]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.pallet-grandpa]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.pallet-session]
-default-features = false
-features = ["historical"]
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.pallet-treasury]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.serde]
-version = "1.0.101"
-optional = true
-features = ["derive"]
-
-[dependencies.sp-arithmetic]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.sp-consensus-babe]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.sp-core]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.sp-runtime]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.sp-staking]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
-
-[dependencies.sp-std]
-default-features = false
-git = 'https://github.com/librelois/substrate.git'
-branch = 'duniter-monthly-2022-02'
+frame-support = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+frame-system = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+pallet-babe = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+pallet-grandpa = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+pallet-session = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+pallet-treasury = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+sp-arithmetic = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+sp-consensus-babe = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+sp-core = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+sp-runtime = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+sp-std = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+
+
+# substrate benchmarks
+frame-benchmarking = { git = "https://github.com/librelois/substrate", branch = 'duniter-monthly-2022-02', default-features = false, optional = true }
+frame-system-benchmarking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false, optional = true }
+
+# TODO: there is a bad coupling in substrate that force to add this dependency
+sp-staking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs
index cb1321f87..7558a6556 100644
--- a/runtime/common/src/apis.rs
+++ b/runtime/common/src/apis.rs
@@ -223,51 +223,74 @@ macro_rules! runtime_apis {
             }
 
             #[cfg(feature = "runtime-benchmarks")]
-            impl frame_benchmarking::Benchmark<Block> for Runtime {
-                fn dispatch_benchmark(
-                    config: frame_benchmarking::BenchmarkConfig,
-                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
-                    use frame_benchmarking::{
-                        add_benchmark, BenchmarkBatch, Benchmarking, TrackedStorageKey,
-                    };
-
-                    use frame_system_benchmarking::Pallet as SystemBench;
-                    impl frame_system_benchmarking::Config for Runtime {}
-
-                    use pallet_crowdloan_rewards::Pallet as PalletCrowdloanRewardsBench;
-                    use parachain_staking::Pallet as ParachainStakingBench;
-                    use pallet_author_mapping::Pallet as PalletAuthorMappingBench;
-                    let whitelist: Vec<TrackedStorageKey> = vec![];
-
-                    let mut batches = Vec::<BenchmarkBatch>::new();
-                    let params = (&config, &whitelist);
-
-                    add_benchmark!(
-                        params,
-                        batches,
-                        parachain_staking,
-                        ParachainStakingBench::<Runtime>
-                    );
-                    // add_benchmark!(
-                    //     params,
-                    //     batches,
-                    //     pallet_crowdloan_rewards,
-                    //     PalletCrowdloanRewardsBench::<Runtime>
-                    // );
-                    add_benchmark!(
-                        params,
-                        batches,
-                        pallet_author_mapping,
-                        PalletAuthorMappingBench::<Runtime>
-                    );
-                    add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
-
-                    if batches.is_empty() {
-                        return Err("Benchmark not found for this pallet.".into());
-                    }
-                    Ok(batches)
-                }
-            }
+			impl frame_benchmarking::Benchmark<Block> for Runtime {
+				fn benchmark_metadata(extra: bool) -> (
+					Vec<frame_benchmarking::BenchmarkList>,
+					Vec<frame_support::traits::StorageInfo>,
+				) {
+					use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
+					use frame_support::traits::StorageInfoTrait;
+
+					use frame_system_benchmarking::Pallet as SystemBench;
+					use frame_benchmarking::baseline::Pallet as Baseline;
+
+					let mut list = Vec::<BenchmarkList>::new();
+					list_benchmark!(list, extra, pallet_balances, Balances);
+					list_benchmark!(list, extra, pallet_multisig, Multisig);
+					list_benchmark!(list, extra, pallet_proxy, Proxy);
+					list_benchmark!(list, extra, pallet_scheduler, Scheduler);
+					list_benchmark!(list, extra, pallet_timestamp, Timestamp);
+					list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
+					list_benchmark!(list, extra, pallet_utility, Utility);
+
+					let storage_info = AllPalletsWithSystem::storage_info();
+					return (list, storage_info)
+				}
+
+				fn dispatch_benchmark(
+					config: frame_benchmarking::BenchmarkConfig
+				) -> Result<
+					Vec<frame_benchmarking::BenchmarkBatch>,
+					sp_runtime::RuntimeString,
+				> {
+					use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
+					// Trying to add benchmarks directly to some pallets caused cyclic dependency issues.
+					// To get around that, we separated the benchmarks into its own crate.
+					use frame_system_benchmarking::Pallet as SystemBench;
+					use frame_benchmarking::baseline::Pallet as Baseline;
+
+					impl frame_system_benchmarking::Config for Runtime {}
+					impl frame_benchmarking::baseline::Config for Runtime {}
+
+					let whitelist: Vec<TrackedStorageKey> = vec![
+						// Block Number
+						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
+						// Total Issuance
+						hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
+						// Execution Phase
+						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
+						// Event Count
+						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
+						// System Events
+						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+						// Treasury Account
+						hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
+					];
+
+					let mut batches = Vec::<BenchmarkBatch>::new();
+					let params = (&config, &whitelist);
+					add_benchmark!(params, batches, pallet_balances, Balances);
+					add_benchmark!(params, batches, pallet_multisig, Multisig);
+					add_benchmark!(params, batches, pallet_proxy, Proxy);
+					add_benchmark!(params, batches, pallet_scheduler, Scheduler);
+					add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
+					add_benchmark!(params, batches, pallet_timestamp, Timestamp);
+					add_benchmark!(params, batches, pallet_utility, Utility);
+
+					if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
+					Ok(batches)
+				}
+			}
         }
     };
 }
diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml
index 570b53d0a..d400bdf3d 100644
--- a/runtime/gdev/Cargo.toml
+++ b/runtime/gdev/Cargo.toml
@@ -16,27 +16,46 @@ targets = ['x86_64-unknown-linux-gnu']
 [features]
 default = ['std']
 runtime-benchmarks = [
-    'frame-benchmarking',
+    'common-runtime/runtime-benchmarks',
+    'frame-benchmarking/runtime-benchmarks',
     'frame-support/runtime-benchmarks',
     'frame-system-benchmarking',
     'frame-system/runtime-benchmarks',
     'hex-literal',
+    'pallet-authority-members/runtime-benchmarks',
+    'pallet-babe/runtime-benchmarks',
     'pallet-balances/runtime-benchmarks',
+    'pallet-certification/runtime-benchmarks',
+    'pallet-collective/runtime-benchmarks',
+    'pallet-duniter-test-parameters/runtime-benchmarks',
+    'pallet-duniter-account/runtime-benchmarks',
+    'pallet-duniter-wot/runtime-benchmarks',
+    'pallet-grandpa/runtime-benchmarks',
     'pallet-identity/runtime-benchmarks',
+    'pallet-membership/runtime-benchmarks',
+    'pallet-provide-randomness/runtime-benchmarks',
+    'pallet-im-online/runtime-benchmarks',
+    'pallet-multisig/runtime-benchmarks',
+    'pallet-preimage/runtime-benchmarks',
+    'pallet-proxy/runtime-benchmarks',
+    'pallet-scheduler/runtime-benchmarks',
+    'pallet-timestamp/runtime-benchmarks',
     'pallet-treasury/runtime-benchmarks',
     'pallet-universal-dividend/runtime-benchmarks',
-    'common-runtime/runtime-benchmarks',
+    'pallet-upgrade-origin/runtime-benchmarks',
+    'pallet-utility/runtime-benchmarks',
     'sp-runtime/runtime-benchmarks',
 ]
 std = [
     'codec/std',
+	'common-runtime/std',
     'frame-executive/std',
     'frame-support/std',
     'frame-system-rpc-runtime-api/std',
     'frame-system/std',
     "frame-try-runtime/std",
-    'pallet-atomic-swap/std',
     'log/std',
+    'pallet-atomic-swap/std',
     'pallet-authority-discovery/std',
     'pallet-authority-members/std',
     'pallet-babe/std',
@@ -52,8 +71,10 @@ std = [
     'pallet-provide-randomness/std',
     'pallet-im-online/std',
     'pallet-multisig/std',
+	"pallet-offences/std",
     'pallet-preimage/std',
     'pallet-proxy/std',
+	"pallet-scheduler/std",
     'pallet-session/std',
     'pallet-sudo/std',
     'pallet-universal-dividend/std',
@@ -62,8 +83,9 @@ std = [
     'pallet-transaction-payment-rpc-runtime-api/std',
     'pallet-transaction-payment/std',
     'pallet-treasury/std',
-    'common-runtime/std',
-    'serde',
+    'pallet-utility/std',
+	"serde/std",
+	"serde_derive",
     'sp-api/std',
     'sp-arithmetic/std',
     'sp-authority-discovery/std',
@@ -128,15 +150,14 @@ codec = { package = "parity-scale-codec", version = "2.3.1", features = ["derive
 log = { version = "0.4.17", default-features = false }
 hex-literal = { version = '0.3.1', optional = true }
 scale-info = { version = "1.0", default-features = false, features = ["derive"] }
-serde = { version = "1.0.101", optional = true, features = ["derive"] }
+serde = { version = "1.0.101", default-features = false }
+serde_derive = { version = "1.0.101", optional = true }
 
 # substrate
-frame-benchmarking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', optional = true }
 frame-try-runtime = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false, optional = true }
 frame-executive = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
 frame-support = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
 frame-system = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
-frame-system-benchmarking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', optional = true }
 frame-system-rpc-runtime-api = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false}
 pallet-atomic-swap = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
 pallet-authority-discovery = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
@@ -171,3 +192,7 @@ sp-session = { git = 'https://github.com/librelois/substrate.git', branch = 'dun
 sp-std = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
 sp-transaction-pool = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
 sp-version = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false }
+
+# substrate benchmarking
+frame-benchmarking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false, optional = true }
+frame-system-benchmarking = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-02', default-features = false, optional = true }
diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs
index f4c3dcd12..c599fd4d3 100644
--- a/runtime/gdev/src/lib.rs
+++ b/runtime/gdev/src/lib.rs
@@ -22,6 +22,10 @@
 #[cfg(feature = "std")]
 include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
 
+#[cfg(feature = "runtime-benchmarks")]
+#[macro_use]
+extern crate frame_benchmarking;
+
 pub mod parameters;
 
 pub use self::parameters::*;
-- 
GitLab