Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #90 from logion-network/feature/bounded-vec
Browse files Browse the repository at this point in the history
Use pallets v0.2.0 - bounded data - import
  • Loading branch information
benoitdevos authored Feb 29, 2024
2 parents 80d1318 + e549c4f commit 4cfcb0f
Show file tree
Hide file tree
Showing 9 changed files with 1,002 additions and 818 deletions.
1,235 changes: 642 additions & 593 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ members = [
"node",
"runtime",
]
resolver = "2"

[profile.release]
panic = "unwind"
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/pol
sp-inherents = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.5.0" }
sp-keyring = { version = "24.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.5.0" }
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.5.0" }
pallet-lo-authority-list = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-lo-authority-list = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.5.0" }

# These dependencies are used for the node template"s RPCs
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use futures::FutureExt;
use logion_node_runtime::{self, opaque::Block, RuntimeApi};
use logion_node_runtime::{opaque::Block, RuntimeApi};
use sc_client_api::{Backend, BlockBackend};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams, CompatibilityMode};
use sc_consensus_grandpa::SharedVoterState;
Expand Down
14 changes: 7 additions & 7 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, g

# logion dependencies
log = { version = "0.4.17", default-features = false }
logion-shared = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-block-reward = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-lo-authority-list = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-logion-loc = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-logion-vault = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-logion-vote = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
logion-shared = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-block-reward = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-lo-authority-list = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-logion-loc = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-logion-vault = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-logion-vote = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.5.0" }
pallet-recovery = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.5.0" }
pallet-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.5.0" }
pallet-validator-set = { default-features = false, git = "https://github.com/logion-network/substrate-validator-set.git", package = "substrate-validator-set", branch = "polkadot-v1.5.0" }
pallet-verified-recovery = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.1.0" }
pallet-verified-recovery = { git = "https://github.com/logion-network/logion-pallets", default-features = false, tag = "v0.2.0-6" }
pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.5.0" }
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-v1.5.0" }

Expand Down
53 changes: 37 additions & 16 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};

// Additional imports
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_system::EnsureRoot;
use logion_shared::{CreateRecoveryCallFactory, MultisigApproveAsMultiCallFactory, MultisigAsMultiCallFactory, DistributionKey, RewardDistributor as RewardDistributorTrait};
use pallet_logion_loc::{Hasher};
Expand Down Expand Up @@ -127,7 +127,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 161,
spec_version: 162,
impl_version: 2,
apis: RUNTIME_API_VERSIONS,
transaction_version: 5,
Expand Down Expand Up @@ -410,7 +410,10 @@ impl pallet_sudo::Config for Runtime {
}

parameter_types! {
#[derive(Debug, Eq, Clone, PartialEq, TypeInfo)]
pub const MaxBaseUrlLen: u32 = 2000;
pub const MaxWellKnownNodes: u32 = 100;
#[derive(Debug, Eq, Clone, PartialEq, TypeInfo, PartialOrd, Ord)]
pub const MaxPeerIdLength: u32 = 128;
}

Expand Down Expand Up @@ -442,7 +445,7 @@ impl pallet_session::Config for Runtime {
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>; // No benchmark available
}

#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, TypeInfo, Copy)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, TypeInfo, Copy, MaxEncodedLen)]
pub enum Region {
Europe,
}
Expand Down Expand Up @@ -472,15 +475,21 @@ impl pallet_lo_authority_list::Config for Runtime {
type Region = Region;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_lo_authority_list::WeightInfo<Runtime>;
type MaxBaseUrlLen = MaxBaseUrlLen;
type MaxNodes = MaxWellKnownNodes;
type MaxPeerIdLength = MaxPeerIdLength;
}

parameter_types! {
pub const MaxCollectionItemDescriptionSize: usize = 4096;
pub const MaxCollectionItemTokenIdSize: usize = 255;
pub const MaxCollectionItemTokenTypeSize: usize = 255;
pub const MaxFileContentTypeSize: u32 = 255;
pub const MaxFileNameSize: u32 = 255;
pub const MaxTokensRecordDescriptionSize: u32 = 4096;
pub const MaxAccountLocs: u32 = 200;
#[derive(TypeInfo)]
pub const MaxLocMetadata: u32 = 50;
#[derive(TypeInfo)]
pub const MaxLocFiles: u32 = 50;
#[derive(TypeInfo)]
pub const MaxLocLinks: u32 = 50;
pub const MaxCollectionItemFiles: u32 = 10;
pub const MaxCollectionItemTCs: u32 = 10;
pub const MaxTokensRecordFiles: u32 = 10;
}

Expand All @@ -500,13 +509,13 @@ impl pallet_logion_loc::Config for Runtime {
type Hasher = SHA256;
type IsLegalOfficer = LoAuthorityList;
type CollectionItemId = Hash;
type MaxCollectionItemDescriptionSize = MaxCollectionItemDescriptionSize;
type MaxCollectionItemTokenIdSize = MaxCollectionItemTokenIdSize;
type MaxCollectionItemTokenTypeSize = MaxCollectionItemTokenTypeSize;
type TokensRecordId = Hash;
type MaxFileContentTypeSize = MaxFileContentTypeSize;
type MaxFileNameSize = MaxFileNameSize;
type MaxTokensRecordDescriptionSize = MaxTokensRecordDescriptionSize;
type MaxAccountLocs = MaxAccountLocs;
type MaxLocMetadata = MaxLocMetadata;
type MaxLocFiles = MaxLocFiles;
type MaxLocLinks = MaxLocLinks;
type MaxCollectionItemFiles = MaxCollectionItemFiles;
type MaxCollectionItemTCs = MaxCollectionItemTCs;
type MaxTokensRecordFiles = MaxTokensRecordFiles;
type WeightInfo = weights::pallet_logion_loc::WeightInfo<Runtime>;
type Currency = Balances;
Expand Down Expand Up @@ -712,13 +721,20 @@ impl LocSetup<LocId, AccountId> for VoteLocSetup {
}
}


parameter_types! {
#[derive(Debug, PartialEq, TypeInfo)]
pub const MaxBallots: u32 = 12;
}

impl pallet_logion_vote::Config for Runtime {
type LocId = LocId;
type RuntimeEvent = RuntimeEvent;
type IsLegalOfficer = LoAuthorityList;
type LocValidity = LogionLoc;
type LocQuery = LogionLoc;
type LegalOfficerCreation = LoAuthorityList;
type MaxBallots = MaxBallots;
type WeightInfo = weights::pallet_logion_vote::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type LocSetup = VoteLocSetup;
Expand Down Expand Up @@ -869,12 +885,17 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);

parameter_types! {
pub const LogionLocStr: &'static str = "LogionLoc";
}

/// All migrations of the runtime, aside from the ones declared in the pallets.
///
/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`.
#[allow(unused_parens)]
type Migrations = (
pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
pallet_logion_loc::migrations::v23::RemoveUselessMapsAddImported<LogionLocStr, Runtime>,
pallet_lo_authority_list::migrations::v5::AddImported<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
82 changes: 54 additions & 28 deletions runtime/src/weights/pallet_lo_authority_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Autogenerated weights for `pallet_lo_authority_list`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-12-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-02-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `gerard-XPS-13-9305`, CPU: `11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024
Expand Down Expand Up @@ -36,46 +36,72 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_lo_authority_list`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_lo_authority_list::WeightInfo for WeightInfo<T> {
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:54 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:101 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: Some(2185), added: 4660, mode: `MaxEncodedLen`)
/// Storage: `LoAuthorityList::LegalOfficerNodes` (r:0 w:1)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: Some(13002), added: 13497, mode: `MaxEncodedLen`)
fn add_legal_officer() -> Weight {
// Proof Size summary in bytes:
// Measured: `4910`
// Estimated: `139550`
// Minimum execution time: 243_589_000 picoseconds.
Weight::from_parts(258_521_000, 0)
.saturating_add(Weight::from_parts(0, 139550))
.saturating_add(T::DbWeight::get().reads(54))
// Measured: `9309`
// Estimated: `471650`
// Minimum execution time: 418_485_000 picoseconds.
Weight::from_parts(426_943_000, 0)
.saturating_add(Weight::from_parts(0, 471650))
.saturating_add(T::DbWeight::get().reads(101))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:53 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:101 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: Some(2185), added: 4660, mode: `MaxEncodedLen`)
/// Storage: `LoAuthorityList::LegalOfficerNodes` (r:0 w:1)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: Some(13002), added: 13497, mode: `MaxEncodedLen`)
fn remove_legal_officer() -> Weight {
// Proof Size summary in bytes:
// Measured: `4910`
// Estimated: `137075`
// Minimum execution time: 353_828_000 picoseconds.
Weight::from_parts(364_906_000, 0)
.saturating_add(Weight::from_parts(0, 137075))
.saturating_add(T::DbWeight::get().reads(53))
// Measured: `9400`
// Estimated: `471650`
// Minimum execution time: 598_565_000 picoseconds.
Weight::from_parts(621_236_000, 0)
.saturating_add(Weight::from_parts(0, 471650))
.saturating_add(T::DbWeight::get().reads(101))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:53 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:101 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: Some(2185), added: 4660, mode: `MaxEncodedLen`)
/// Storage: `LoAuthorityList::LegalOfficerNodes` (r:0 w:1)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: Some(13002), added: 13497, mode: `MaxEncodedLen`)
fn update_legal_officer() -> Weight {
// Proof Size summary in bytes:
// Measured: `4910`
// Estimated: `137075`
// Minimum execution time: 244_677_000 picoseconds.
Weight::from_parts(253_044_000, 0)
.saturating_add(Weight::from_parts(0, 137075))
.saturating_add(T::DbWeight::get().reads(53))
// Measured: `9400`
// Estimated: `471650`
// Minimum execution time: 410_435_000 picoseconds.
Weight::from_parts(427_006_000, 0)
.saturating_add(Weight::from_parts(0, 471650))
.saturating_add(T::DbWeight::get().reads(101))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:101 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: Some(2185), added: 4660, mode: `MaxEncodedLen`)
/// Storage: `LoAuthorityList::LegalOfficerNodes` (r:0 w:1)
/// Proof: `LoAuthorityList::LegalOfficerNodes` (`max_values`: Some(1), `max_size`: Some(13002), added: 13497, mode: `MaxEncodedLen`)
fn import_host_legal_officer() -> Weight {
// Proof Size summary in bytes:
// Measured: `9309`
// Estimated: `471650`
// Minimum execution time: 406_380_000 picoseconds.
Weight::from_parts(432_396_000, 0)
.saturating_add(Weight::from_parts(0, 471650))
.saturating_add(T::DbWeight::get().reads(101))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `LoAuthorityList::LegalOfficerSet` (r:2 w:1)
/// Proof: `LoAuthorityList::LegalOfficerSet` (`max_values`: None, `max_size`: Some(2185), added: 4660, mode: `MaxEncodedLen`)
fn import_guest_legal_officer() -> Weight {
// Proof Size summary in bytes:
// Measured: `878`
// Estimated: `10310`
// Minimum execution time: 23_398_000 picoseconds.
Weight::from_parts(27_347_000, 0)
.saturating_add(Weight::from_parts(0, 10310))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}
Loading

0 comments on commit 4cfcb0f

Please sign in to comment.