diff --git a/Cargo.lock b/Cargo.lock index af59d9ece1b82..e918ca65c23d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,7 +490,7 @@ dependencies = [ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-keystore 2.0.0", "sp-core 2.0.0", - "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3053,7 +3053,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-timestamp 2.0.0", "sp-transaction-pool 2.0.0", - "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-build-script-utils 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3801,7 +3801,6 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -4367,12 +4366,26 @@ dependencies = [ [[package]] name = "proc-macro-error" -version = "0.2.6" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-error-attr 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-error-attr" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn-mid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4738,11 +4751,6 @@ dependencies = [ "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ref_thread_local" -version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "regex" version = "1.3.1" @@ -5029,7 +5037,7 @@ dependencies = [ "sp-panic-handler 2.0.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", - "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6671,20 +6679,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-error 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6913,6 +6921,16 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn-mid" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" version = "0.12.3" @@ -8460,7 +8478,8 @@ dependencies = [ "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" "checksum primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a0253db64c26d8b4e7896dd2063b516d2a1b9e0a5da26b5b78335f236d1e9522" "checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" -"checksum proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" +"checksum proc-macro-error 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "53c98547ceaea14eeb26fcadf51dc70d01a2479a7839170eae133721105e4428" +"checksum proc-macro-error-attr 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c2bf5d493cf5d3e296beccfd61794e445e830dfc8070a9c248ad3ee071392c6c" "checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" "checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" @@ -8500,7 +8519,6 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" @@ -8560,8 +8578,8 @@ dependencies = [ "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "30b3a3e93f5ad553c38b3301c8a0a0cec829a36783f6a0c467fc4bf553a5f5bf" -"checksum structopt-derive 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea692d40005b3ceba90a9fe7a78fa8d4b82b0ce627eebbffc329aab850f3410e" +"checksum structopt 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "884ae79d6aad1e738f4a70dff314203fd498490a63ebc4d03ea83323c40b7b72" +"checksum structopt-derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a97f829a34a0a9d5b353a881025a23b8c9fd09d46be6045df6b22920dbd7a93" "checksum strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" "checksum strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" "checksum substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" @@ -8569,6 +8587,7 @@ dependencies = [ "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" +"checksum syn-mid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd3937748a7eccff61ba5b90af1a20dbf610858923a9192ea0ecb0cb77db1d0" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 0ce5115831a28..47efe3c70235f 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -31,7 +31,7 @@ hex-literal = "0.2.1" jsonrpc-core = "14.0.3" log = "0.4.8" rand = "0.7.2" -structopt = "0.3.3" +structopt = "=0.3.7" # primitives sp-authority-discovery = { version = "2.0.0", path = "../../../primitives/authority-discovery" } @@ -107,7 +107,7 @@ tempfile = "3.1.0" [build-dependencies] sc-cli = { version = "2.0.0", package = "sc-cli", path = "../../../client/cli" } build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } -structopt = "0.3.3" +structopt = "=0.3.7" vergen = "3.0.4" [features] diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index 8cd8cb9f33d8c..3b11ff31252d0 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -20,8 +20,8 @@ use tokio::runtime::{Builder as RuntimeBuilder, Runtime}; use sc_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error}; use sc_service::{AbstractService, Roles as ServiceRoles, Configuration}; use log::info; -use structopt::{StructOpt, clap::App}; -use sc_cli::{display_role, parse_and_prepare, AugmentClap, GetSharedParams, ParseAndPrepare}; +use structopt::StructOpt; +use sc_cli::{display_role, parse_and_prepare, GetSharedParams, ParseAndPrepare}; use crate::{service, ChainSpec, load_spec}; use crate::factory_impl::FactoryState; use node_transaction_factory::RuntimeAdapter; @@ -88,12 +88,6 @@ pub struct FactoryCmd { pub import_params: ImportParams, } -impl AugmentClap for FactoryCmd { - fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { - FactoryCmd::augment_clap(app) - } -} - /// Parse command line arguments into service configuration. pub fn run(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Result<()> where I: IntoIterator, diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index e31419d3b9f2e..c8d79afbced11 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -11,4 +11,4 @@ sc-keystore = { version = "2.0.0", path = "../../../client/keystore" } node-cli = { version = "2.0.0", path = "../../node/cli" } sp-core = { version = "2.0.0", path = "../../../primitives/core" } rand = "0.7.2" -structopt = "0.3.3" +structopt = "=0.3.7" diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 49f327405bac3..460cc2a05a32e 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -31,7 +31,7 @@ sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" sc-telemetry = { version = "2.0.0", path = "../telemetry" } sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } names = "0.11.0" -structopt = "0.3.3" +structopt = "=0.3.7" sc-tracing = { version = "2.0.0", path = "../tracing" } [target.'cfg(not(target_os = "unknown"))'.dependencies] diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index d1b3388432d10..19ee599e022d5 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -48,7 +48,7 @@ use std::{ use names::{Generator, Name}; use regex::Regex; -use structopt::{StructOpt, clap::AppSettings}; +use structopt::{StructOpt, StructOptInternal, clap::AppSettings}; #[doc(hidden)] pub use structopt::clap::App; use params::{ @@ -57,7 +57,7 @@ use params::{ NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd, }; pub use params::{NoCustom, CoreParams, SharedParams, ImportParams, ExecutionStrategy}; -pub use traits::{GetSharedParams, AugmentClap}; +pub use traits::GetSharedParams; use app_dirs::{AppInfo, AppDataType}; use log::info; use lazy_static::lazy_static; @@ -196,7 +196,7 @@ pub fn parse_and_prepare<'a, CC, RP, I>( ) -> ParseAndPrepare<'a, CC, RP> where CC: StructOpt + Clone + GetSharedParams, - RP: StructOpt + Clone + AugmentClap, + RP: StructOpt + Clone + StructOptInternal, I: IntoIterator, ::Item: Into + Clone, { diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index e8d00978a8d79..780dcd49830b0 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::traits::{AugmentClap, GetSharedParams}; +use crate::traits::GetSharedParams; use std::{str::FromStr, path::PathBuf}; -use structopt::{StructOpt, clap::{arg_enum, App, AppSettings, SubCommand, Arg}}; +use structopt::{StructOpt, StructOptInternal, clap::{arg_enum, App, AppSettings, SubCommand, Arg}}; pub use crate::execution_strategy::ExecutionStrategy; @@ -208,7 +208,7 @@ pub struct NetworkConfigurationParams { #[allow(missing_docs)] #[structopt(flatten)] - pub node_key_params: NodeKeyParams + pub node_key_params: NodeKeyParams, } arg_enum! { @@ -278,7 +278,7 @@ pub struct NodeKeyParams { /// If the file does not exist, it is created with a newly generated secret key of /// the chosen type. #[structopt(long = "node-key-file", value_name = "FILE")] - pub node_key_file: Option + pub node_key_file: Option, } /// Parameters used to create the pool configuration. @@ -623,14 +623,14 @@ impl StructOpt for Keyring { unimplemented!("Should not be called for `TestAccounts`.") } - fn from_clap(m: &::structopt::clap::ArgMatches) -> Self { + fn from_clap(m: &structopt::clap::ArgMatches) -> Self { Keyring { account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant), } } } -impl AugmentClap for Keyring { +impl StructOptInternal for Keyring { fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| { let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::>(); @@ -646,12 +646,6 @@ impl AugmentClap for Keyring { } } -impl Keyring { - fn is_subcommand() -> bool { - false - } -} - /// Default to verbosity level 0, if none is provided. fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box> { let pos = s.find(' '); @@ -705,8 +699,6 @@ fn parse_cors(s: &str) -> Result> { Ok(if is_all { Cors::All } else { Cors::List(origins) }) } -impl_augment_clap!(RunCmd); - /// The `build-spec` command used to build a specification. #[derive(Debug, StructOpt, Clone)] pub struct BuildSpecCmd { @@ -895,7 +887,7 @@ pub enum CoreParams { impl StructOpt for CoreParams where CC: StructOpt + GetSharedParams, - RP: StructOpt + AugmentClap + RP: StructOpt + StructOptInternal, { fn clap<'a, 'b>() -> App<'a, 'b> { RP::augment_clap( @@ -964,7 +956,7 @@ impl StructOpt for NoCustom { } } -impl AugmentClap for NoCustom { +impl StructOptInternal for NoCustom { fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { app } @@ -985,7 +977,7 @@ pub struct MergeParameters { pub right: R, } -impl StructOpt for MergeParameters where L: StructOpt + AugmentClap, R: StructOpt { +impl StructOpt for MergeParameters where L: StructOpt + StructOptInternal, R: StructOpt { fn clap<'a, 'b>() -> App<'a, 'b> { L::augment_clap(R::clap()) } diff --git a/client/cli/src/traits.rs b/client/cli/src/traits.rs index dddba0b25ab2c..2f4007c846f90 100644 --- a/client/cli/src/traits.rs +++ b/client/cli/src/traits.rs @@ -14,30 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use structopt::{StructOpt, clap::App}; use crate::params::SharedParams; -/// Something that can augment a clap app with further parameters. -/// `derive(StructOpt)` is implementing this function by default, so a macro `impl_augment_clap!` -/// is provided to simplify the implementation of this trait. -pub trait AugmentClap: StructOpt { - /// Augment the given clap `App` with further parameters. - fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b>; -} - -/// Macro for implementing the `AugmentClap` trait. -/// This requires that the given type uses `derive(StructOpt)`! -#[macro_export] -macro_rules! impl_augment_clap { - ( $type:ident ) => { - impl $crate::AugmentClap for $type { - fn augment_clap<'a, 'b>(app: $crate::App<'a, 'b>) -> $crate::App<'a, 'b> { - $type::augment_clap(app) - } - } - } -} - /// Supports getting common params. pub trait GetSharedParams { /// Returns shared params if any. diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 574c2d3eb6f3d..d05a7654d1240 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -16,9 +16,6 @@ sp-core = { version = "2.0.0", default-features = false, path = "../../primitive frame-support = { version = "2.0.0", default-features = false, path = "../support" } frame-system = { version = "2.0.0", default-features = false, path = "../system" } -[dev-dependencies] -ref_thread_local = "0.0.0" - [features] default = ["std"] std = [ diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 2a1cb0746f816..150664126d010 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -18,8 +18,7 @@ #![cfg(test)] -use std::collections::HashSet; -use ref_thread_local::{ref_thread_local, RefThreadLocal}; +use std::{cell::RefCell, collections::HashSet}; use sp_runtime::testing::Header; use sp_runtime::Perbill; use sp_core::H256; @@ -30,23 +29,23 @@ impl_outer_origin!{ pub enum Origin for Runtime where system = frame_system {} } -ref_thread_local! { - static managed ALIVE: HashSet = HashSet::new(); +thread_local! { + static ALIVE: RefCell> = Default::default(); } pub fn make_account(who: u64) { - ALIVE.borrow_mut().insert(who); + ALIVE.with(|a| a.borrow_mut().insert(who)); Indices::on_new_account(&who); } pub fn kill_account(who: u64) { - ALIVE.borrow_mut().remove(&who); + ALIVE.with(|a| a.borrow_mut().remove(&who)); } pub struct TestIsDeadAccount {} impl IsDeadAccount for TestIsDeadAccount { fn is_dead_account(who: &u64) -> bool { - !ALIVE.borrow_mut().contains(who) + !ALIVE.with(|a| a.borrow_mut().contains(who)) } } @@ -70,6 +69,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } + impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; @@ -88,6 +88,7 @@ impl frame_system::Trait for Runtime { type Version = (); type ModuleToIndex = (); } + impl Trait for Runtime { type AccountIndex = u64; type IsDeadAccount = TestIsDeadAccount; @@ -97,9 +98,11 @@ impl Trait for Runtime { pub fn new_test_ext() -> sp_io::TestExternalities { { - let mut h = ALIVE.borrow_mut(); - h.clear(); - for i in 1..5 { h.insert(i); } + ALIVE.with(|a| { + let mut h = a.borrow_mut(); + h.clear(); + for i in 1..5 { h.insert(i); } + }); } let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap();