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
This commit is contained in:
David Palm
2020-09-24 11:48:13 +02:00
parent 9f0d358b44
commit a0f430c6ac
5 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -146,7 +146,7 @@ mod tests {
let event = client let event = client
.transfer_and_watch(&alice, &bob.account_id(), 10_000) .transfer_and_watch(&alice, &bob.account_id(), 10_000)
.await .await
.unwrap() .expect("sending an xt works")
.transfer() .transfer()
.unwrap() .unwrap()
.unwrap(); .unwrap();
+1 -1
View File
@@ -118,7 +118,7 @@ pub trait System {
} }
/// Type used to encode the number of references an account has. /// Type used to encode the number of references an account has.
pub type RefCount = u8; pub type RefCount = u32;
/// Information of an account. /// Information of an account.
#[derive(Clone, Debug, Eq, PartialEq, Default, Decode, Encode)] #[derive(Clone, Debug, Eq, PartialEq, Default, Decode, Encode)]
+5 -3
View File
@@ -163,6 +163,7 @@ impl Metadata {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ModuleMetadata { pub struct ModuleMetadata {
index: u8,
name: String, name: String,
storage: HashMap<String, StorageMetadata>, storage: HashMap<String, StorageMetadata>,
// constants // constants
@@ -509,6 +510,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
modules.insert( modules.insert(
module_name.clone(), module_name.clone(),
ModuleMetadata { ModuleMetadata {
index: module.index,
name: module_name.clone(), name: module_name.clone(),
storage: storage_map, storage: storage_map,
}, },
@@ -523,7 +525,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
modules_with_calls.insert( modules_with_calls.insert(
module_name.clone(), module_name.clone(),
ModuleWithCalls { ModuleWithCalls {
index: modules_with_calls.len() as u8, index: module.index,
calls: call_map, calls: call_map,
}, },
); );
@@ -536,7 +538,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
modules_with_events.insert( modules_with_events.insert(
module_name.clone(), module_name.clone(),
ModuleWithEvents { ModuleWithEvents {
index: modules_with_events.len() as u8, index: module.index,
name: module_name.clone(), name: module_name.clone(),
events: event_map, events: event_map,
}, },
@@ -549,7 +551,7 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
modules_with_errors.insert( modules_with_errors.insert(
module_name.clone(), module_name.clone(),
ModuleWithErrors { ModuleWithErrors {
index: modules_with_errors.len() as u8, index: module.index,
name: module_name.clone(), name: module_name.clone(),
errors: error_map, errors: error_map,
}, },
+8 -3
View File
@@ -169,18 +169,22 @@ pub fn native_version() -> NativeVersion {
} }
} }
const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
parameter_types! { parameter_types! {
pub const BlockHashCount: BlockNumber = 2400; pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time. /// We allow for 2 seconds of compute with a 6 second average block time.
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND; pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
/// Assume 10% of weight for average on_initialize calls. /// Assume 10% of weight for average on_initialize calls.
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get() pub MaximumExtrinsicWeight: Weight =
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get(); AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
* MaximumBlockWeight::get();
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
pub const Version: RuntimeVersion = VERSION; pub const Version: RuntimeVersion = VERSION;
} }
// const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
impl frame_system::Trait for Runtime { impl frame_system::Trait for Runtime {
/// The basic call filter to use in dispatchable. /// The basic call filter to use in dispatchable.
type BaseCallFilter = (); type BaseCallFilter = ();
@@ -234,6 +238,7 @@ impl frame_system::Trait for Runtime {
type AccountData = pallet_balances::AccountData<Balance>; type AccountData = pallet_balances::AccountData<Balance>;
/// Weight information for the extrinsics of this pallet. /// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = (); type SystemWeightInfo = ();
// type SystemWeightInfo = weights::frame_system::WeightInfo;
/// Provides information about the pallet setup in the runtime. /// Provides information about the pallet setup in the runtime.
type PalletInfo = PalletInfo; type PalletInfo = PalletInfo;
} }
+1 -1
View File
@@ -101,7 +101,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
// Properties // Properties
None, None,
// Extensions // Extensions
None, Default::default(),
)) ))
} }