From a0f430c6accb00e4d4d3ebd0c2ebbfa75044b6fa Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 24 Sep 2020 11:48:13 +0200 Subject: [PATCH] Sort out the module index (ty @ascjones) Sort out the RefCount type (ty @dvc94ch) Random tweaks to make test-node more similar to the vanilla node-template --- src/frame/balances.rs | 2 +- src/frame/system.rs | 2 +- src/metadata.rs | 8 +++++--- test-node/runtime/src/lib.rs | 11 ++++++++--- test-node/src/chain_spec.rs | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/frame/balances.rs b/src/frame/balances.rs index 9ebf6d6388..598421c8f1 100644 --- a/src/frame/balances.rs +++ b/src/frame/balances.rs @@ -146,7 +146,7 @@ mod tests { let event = client .transfer_and_watch(&alice, &bob.account_id(), 10_000) .await - .unwrap() + .expect("sending an xt works") .transfer() .unwrap() .unwrap(); diff --git a/src/frame/system.rs b/src/frame/system.rs index 7c6db4dba4..b0cb80fcbb 100644 --- a/src/frame/system.rs +++ b/src/frame/system.rs @@ -118,7 +118,7 @@ pub trait System { } /// Type used to encode the number of references an account has. -pub type RefCount = u8; +pub type RefCount = u32; /// Information of an account. #[derive(Clone, Debug, Eq, PartialEq, Default, Decode, Encode)] diff --git a/src/metadata.rs b/src/metadata.rs index deae0778b4..18ea8181fb 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -163,6 +163,7 @@ impl Metadata { #[derive(Clone, Debug)] pub struct ModuleMetadata { + index: u8, name: String, storage: HashMap, // constants @@ -509,6 +510,7 @@ impl TryFrom for Metadata { modules.insert( module_name.clone(), ModuleMetadata { + index: module.index, name: module_name.clone(), storage: storage_map, }, @@ -523,7 +525,7 @@ impl TryFrom for Metadata { modules_with_calls.insert( module_name.clone(), ModuleWithCalls { - index: modules_with_calls.len() as u8, + index: module.index, calls: call_map, }, ); @@ -536,7 +538,7 @@ impl TryFrom for Metadata { modules_with_events.insert( module_name.clone(), ModuleWithEvents { - index: modules_with_events.len() as u8, + index: module.index, name: module_name.clone(), events: event_map, }, @@ -549,7 +551,7 @@ impl TryFrom for Metadata { modules_with_errors.insert( module_name.clone(), ModuleWithErrors { - index: modules_with_errors.len() as u8, + index: module.index, name: module_name.clone(), errors: error_map, }, diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index ae78b2477d..3a94d77339 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -169,18 +169,22 @@ pub fn native_version() -> NativeVersion { } } +const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10); parameter_types! { pub const BlockHashCount: BlockNumber = 2400; /// We allow for 2 seconds of compute with a 6 second average block time. pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); - /// Assume 10% of weight for average on_initialize calls. - pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get() - .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get(); + /// Assume 10% of weight for average on_initialize calls. + pub MaximumExtrinsicWeight: Weight = + AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) + * MaximumBlockWeight::get(); pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const Version: RuntimeVersion = VERSION; } +// const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct()); + impl frame_system::Trait for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = (); @@ -234,6 +238,7 @@ impl frame_system::Trait for Runtime { type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); + // type SystemWeightInfo = weights::frame_system::WeightInfo; /// Provides information about the pallet setup in the runtime. type PalletInfo = PalletInfo; } diff --git a/test-node/src/chain_spec.rs b/test-node/src/chain_spec.rs index a9cc64e42d..7ee9f0476d 100644 --- a/test-node/src/chain_spec.rs +++ b/test-node/src/chain_spec.rs @@ -101,7 +101,7 @@ pub fn development_config() -> Result { // Properties None, // Extensions - None, + Default::default(), )) }