diff --git a/Cargo.lock b/Cargo.lock index d6e027a..064c92d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2414,7 +2414,6 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.4 dependencies = [ "frame-support 4.0.0-dev", "frame-system 4.0.0-dev", - "frame-try-runtime", "parity-scale-codec", "scale-info", "sp-core 7.0.0", @@ -4578,6 +4577,71 @@ dependencies = [ "rust-kzg-blst", ] +[[package]] +name = "melodot-runtime" +version = "0.0.1" +dependencies = [ + "frame-benchmarking 4.0.0-dev", + "frame-election-provider-support", + "frame-executive-ext", + "frame-support 4.0.0-dev", + "frame-system 4.0.0-dev", + "frame-system-benchmarking", + "frame-system-ext", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "melo-auto-config", + "melo-core-primitives", + "node-primitives", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-bounties", + "pallet-collective", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-grandpa", + "pallet-im-online", + "pallet-melo-store", + "pallet-membership", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-preimage", + "pallet-scheduler", + "pallet-session 4.0.0-dev", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp 4.0.0-dev", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "sp-api 4.0.0-dev", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-aura", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core 7.0.0", + "sp-inherents 4.0.0-dev", + "sp-io 7.0.0", + "sp-offchain", + "sp-runtime 7.0.0", + "sp-session 4.0.0-dev", + "sp-staking 4.0.0-dev", + "sp-std 5.0.0", + "sp-transaction-pool", + "sp-version 5.0.0", + "static_assertions", + "substrate-wasm-builder", +] + [[package]] name = "memchr" version = "2.5.0" @@ -4986,7 +5050,7 @@ dependencies = [ "frame-system 4.0.0-dev", "futures", "jsonrpsee", - "node-template-runtime", + "melodot-runtime", "pallet-transaction-payment", "pallet-transaction-payment-rpc", "sc-basic-authorship", @@ -5020,73 +5084,6 @@ dependencies = [ "try-runtime-cli", ] -[[package]] -name = "node-template-runtime" -version = "4.0.0-dev" -dependencies = [ - "frame-benchmarking 4.0.0-dev", - "frame-election-provider-support", - "frame-executive", - "frame-executive-ext", - "frame-support 4.0.0-dev", - "frame-system 4.0.0-dev", - "frame-system-benchmarking", - "frame-system-ext", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "melo-auto-config", - "melo-core-primitives", - "node-primitives", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-bounties", - "pallet-collective", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-grandpa", - "pallet-im-online", - "pallet-melo-store", - "pallet-membership", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-preimage", - "pallet-scheduler", - "pallet-session 4.0.0-dev", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-template", - "pallet-timestamp 4.0.0-dev", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "parity-scale-codec", - "scale-info", - "sp-api 4.0.0-dev", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-aura", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core 7.0.0", - "sp-inherents 4.0.0-dev", - "sp-io 7.0.0", - "sp-offchain", - "sp-runtime 7.0.0", - "sp-session 4.0.0-dev", - "sp-staking 4.0.0-dev", - "sp-std 5.0.0", - "sp-transaction-pool", - "sp-version 5.0.0", - "static_assertions", - "substrate-wasm-builder", -] - [[package]] name = "nohash-hasher" version = "0.2.0" @@ -5735,20 +5732,6 @@ dependencies = [ "sp-std 5.0.0", ] -[[package]] -name = "pallet-template" -version = "4.0.0-dev" -dependencies = [ - "frame-benchmarking 4.0.0-dev", - "frame-support 4.0.0-dev", - "frame-system 4.0.0-dev", - "parity-scale-codec", - "scale-info", - "sp-core 7.0.0", - "sp-io 7.0.0", - "sp-runtime 7.0.0", -] - [[package]] name = "pallet-timestamp" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index c858589..8478197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ members = [ "crates/melo-erasure-coding", "crates/network-das", "crates/pallet-melo-store", - "pallets/template", "runtime", ] diff --git a/crates/pallet-melo-store/src/lib.rs b/crates/pallet-melo-store/src/lib.rs index 8b33ca3..86011d4 100644 --- a/crates/pallet-melo-store/src/lib.rs +++ b/crates/pallet-melo-store/src/lib.rs @@ -142,6 +142,7 @@ pub mod pallet { /// The maximum number of keys that can be added. type MaxKeys: Get; + #[pallet::constant] type MaxBlobNum: Get; #[pallet::constant] diff --git a/node/Cargo.toml b/node/Cargo.toml index ad6dac9..a9746a1 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -59,7 +59,7 @@ frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/parityte frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } # Local Dependencies -node-template-runtime = { version = "4.0.0-dev", path = "../runtime" } +melodot-runtime = { version = "0.0.1", path = "../runtime" } # CLI-specific dependencies try-runtime-cli = { version = "0.10.0-dev", optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } @@ -71,10 +71,10 @@ substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/pa default = [] # Dependencies that are only required if runtime benchmarking should be build. runtime-benchmarks = [ - "node-template-runtime/runtime-benchmarks", + "melodot-runtime/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", ] # Enable features that allow the runtime to be tried and debugged. Name might be subject to change # in the near future. -try-runtime = ["node-template-runtime/try-runtime", "try-runtime-cli/try-runtime"] \ No newline at end of file +try-runtime = ["melodot-runtime/try-runtime", "try-runtime-cli/try-runtime"] \ No newline at end of file diff --git a/pallets/template/Cargo.toml b/pallets/template/Cargo.toml deleted file mode 100644 index 77c42a5..0000000 --- a/pallets/template/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "pallet-template" -version = "4.0.0-dev" -description = "FRAME pallet template for defining custom runtime logic." -authors = ["Substrate DevHub "] -homepage = "https://substrate.io" -edition = "2021" -license = "MIT-0" -publish = false -repository = "https://github.com/substrate-developer-hub/substrate-node-template/" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ - "derive", -] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[dev-dependencies] -sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", - "scale-info/std", -] -runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/template/README.md b/pallets/template/README.md deleted file mode 100644 index d0d5953..0000000 --- a/pallets/template/README.md +++ /dev/null @@ -1 +0,0 @@ -License: MIT-0 \ No newline at end of file diff --git a/pallets/template/src/benchmarking.rs b/pallets/template/src/benchmarking.rs deleted file mode 100644 index 5a26241..0000000 --- a/pallets/template/src/benchmarking.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! Benchmarking setup for pallet-template -#![cfg(feature = "runtime-benchmarks")] -use super::*; - -#[allow(unused)] -use crate::Pallet as Template; -use frame_benchmarking::v2::*; -use frame_system::RawOrigin; - -#[benchmarks] -mod benchmarks { - use super::*; - - #[benchmark] - fn do_something() { - let value = 100u32.into(); - let caller: T::AccountId = whitelisted_caller(); - #[extrinsic_call] - do_something(RawOrigin::Signed(caller), value); - - assert_eq!(Something::::get(), Some(value)); - } - - #[benchmark] - fn cause_error() { - Something::::put(100u32); - let caller: T::AccountId = whitelisted_caller(); - #[extrinsic_call] - cause_error(RawOrigin::Signed(caller)); - - assert_eq!(Something::::get(), Some(101u32)); - } - - impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test); -} diff --git a/pallets/template/src/lib.rs b/pallets/template/src/lib.rs deleted file mode 100644 index edf7769..0000000 --- a/pallets/template/src/lib.rs +++ /dev/null @@ -1,108 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -/// Edit this file to define custom logic or remove it if it is not needed. -/// Learn more about FRAME and the core library of Substrate FRAME pallets: -/// -pub use pallet::*; - -#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; -pub mod weights; -pub use weights::*; - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - - #[pallet::pallet] - pub struct Pallet(_); - - /// Configure the pallet by specifying the parameters and types on which it depends. - #[pallet::config] - pub trait Config: frame_system::Config { - /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// Type representing the weight of this pallet - type WeightInfo: WeightInfo; - } - - // The pallet's runtime storage items. - // https://docs.substrate.io/main-docs/build/runtime-storage/ - #[pallet::storage] - #[pallet::getter(fn something)] - // Learn more about declaring storage items: - // https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items - pub type Something = StorageValue<_, u32>; - - // Pallets use events to inform users when important changes are made. - // https://docs.substrate.io/main-docs/build/events-errors/ - #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { - /// Event documentation should end with an array that provides descriptive names for event - /// parameters. [something, who] - SomethingStored { something: u32, who: T::AccountId }, - } - - // Errors inform users that something went wrong. - #[pallet::error] - pub enum Error { - /// Error names should be descriptive. - NoneValue, - /// Errors should have helpful documentation associated with them. - StorageOverflow, - } - - // Dispatchable functions allows users to interact with the pallet and invoke state changes. - // These functions materialize as "extrinsics", which are often compared to transactions. - // Dispatchable functions must be annotated with a weight and must return a DispatchResult. - #[pallet::call] - impl Pallet { - /// An example dispatchable that takes a singles value as a parameter, writes the value to - /// storage and emits an event. This function must be dispatched by a signed extrinsic. - #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::do_something())] - pub fn do_something(origin: OriginFor, something: u32) -> DispatchResult { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://docs.substrate.io/main-docs/build/origins/ - let who = ensure_signed(origin)?; - - // Update storage. - >::put(something); - - // Emit an event. - Self::deposit_event(Event::SomethingStored { something, who }); - // Return a successful DispatchResultWithPostInfo - Ok(()) - } - - /// An example dispatchable that may throw a custom error. - #[pallet::call_index(1)] - #[pallet::weight(T::WeightInfo::cause_error())] - pub fn cause_error(origin: OriginFor) -> DispatchResult { - let _who = ensure_signed(origin)?; - - // Read a value from storage. - match >::get() { - // Return an error if the value has not been set. - None => Err(Error::::NoneValue.into()), - Some(old) => { - // Increment the value read from storage; will error in the event of overflow. - let new = old.checked_add(1).ok_or(Error::::StorageOverflow)?; - // Update the value in storage with the incremented result. - >::put(new); - Ok(()) - }, - } - } - } -} diff --git a/pallets/template/src/mock.rs b/pallets/template/src/mock.rs deleted file mode 100644 index b4d6905..0000000 --- a/pallets/template/src/mock.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate as pallet_template; -use frame_support::traits::{ConstU16, ConstU64}; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system, - TemplateModule: pallet_template, - } -); - -impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -impl pallet_template::Config for Test { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -// Build genesis storage according to the mock runtime. -pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::default().build_storage::().unwrap().into() -} diff --git a/pallets/template/src/tests.rs b/pallets/template/src/tests.rs deleted file mode 100644 index 7c2b853..0000000 --- a/pallets/template/src/tests.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::{mock::*, Error, Event}; -use frame_support::{assert_noop, assert_ok}; - -#[test] -fn it_works_for_default_value() { - new_test_ext().execute_with(|| { - // Go past genesis block so events get deposited - System::set_block_number(1); - // Dispatch a signed extrinsic. - assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); - // Read pallet storage and assert an expected result. - assert_eq!(TemplateModule::something(), Some(42)); - // Assert that the correct event was deposited - System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into()); - }); -} - -#[test] -fn correct_error_for_none_value() { - new_test_ext().execute_with(|| { - // Ensure the expected error is thrown when no value is present. - assert_noop!( - TemplateModule::cause_error(RuntimeOrigin::signed(1)), - Error::::NoneValue - ); - }); -} diff --git a/pallets/template/src/weights.rs b/pallets/template/src/weights.rs deleted file mode 100644 index e8fbc09..0000000 --- a/pallets/template/src/weights.rs +++ /dev/null @@ -1,91 +0,0 @@ - -//! Autogenerated weights for pallet_template -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 - -// Executed Command: -// ../../target/release/node-template -// benchmark -// pallet -// --chain -// dev -// --pallet -// pallet_template -// --extrinsic -// * -// --steps=50 -// --repeat=20 -// --execution=wasm -// --wasm-execution=compiled -// --output -// pallets/template/src/weights.rs -// --template -// ../../.maintain/frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for pallet_template. -pub trait WeightInfo { - fn do_something() -> Weight; - fn cause_error() -> Weight; -} - -/// Weights for pallet_template using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: TemplateModule Something (r:0 w:1) - /// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn do_something() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: TemplateModule Something (r:1 w:1) - /// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cause_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `32` - // Estimated: `1489` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(6_000_000, 1489) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - /// Storage: TemplateModule Something (r:0 w:1) - /// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn do_something() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: TemplateModule Something (r:1 w:1) - /// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cause_error() -> Weight { - // Proof Size summary in bytes: - // Measured: `32` - // Estimated: `1489` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(6_000_000, 1489) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } -} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 22ee0d8..80ab195 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,11 +1,12 @@ [package] -name = "node-template-runtime" -version = "4.0.0-dev" -description = "A fresh FRAME-based Substrate node, ready for hacking." -authors = ["Substrate DevHub "] -homepage = "https://substrate.io/" +name = "melodot-runtime" +version = "0.0.1" +description = "Melodot Runtime" +authors = ["DKLee "] +repository = "https://github.com/ZeroDAO/melodot" +keywords = ["substrate"] edition = "2021" -license = "MIT-0" +license = "Apache-2.0" include = [ "/src", "/build.rs", @@ -52,7 +53,6 @@ frame-election-provider-support = { default-features = false, git = "https://git frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } frame-try-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" } -frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } @@ -74,15 +74,14 @@ sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkad node-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } # Used for the node template's RPCs -frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } -pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } # Used for runtime benchmarking -frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" } -frame-system-benchmarking = {default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" } +frame-system-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" } # Local Dependencies -pallet-template = { default-features = false, path = "../pallets/template" } frame-executive-ext = { default-features = false, path = "../crates/frame-executive-ext" } frame-system-ext = { default-features = false, path = "../crates/frame-system-ext" } melo-core-primitives = { version = "0.1.0", default-features = false, path = "../crates/core-primitives"} @@ -102,7 +101,6 @@ std = [ "pallet-authorship/std", "codec/std", "scale-info/std", - "frame-executive/std", "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", @@ -111,7 +109,6 @@ std = [ "pallet-balances/std", "pallet-grandpa/std", "pallet-sudo/std", - "pallet-template/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", @@ -160,7 +157,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", - "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", @@ -174,7 +170,6 @@ runtime-benchmarks = [ ] try-runtime = [ "frame-try-runtime/try-runtime", - "frame-executive/try-runtime", "frame-executive-ext/try-runtime", "frame-system/try-runtime", "frame-support/try-runtime", @@ -182,7 +177,6 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-grandpa/try-runtime", "pallet-sudo/try-runtime", - "pallet-template/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-im-online/try-runtime", diff --git a/runtime/src/apis.rs b/runtime/src/apis.rs index 437d352..56f7914 100644 --- a/runtime/src/apis.rs +++ b/runtime/src/apis.rs @@ -33,8 +33,8 @@ use crate::{ #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("node-template"), - impl_name: create_runtime_str!("node-template"), + spec_name: create_runtime_str!("melodot"), + impl_name: create_runtime_str!("melodot"), authoring_version: 1, spec_version: 1, impl_version: 1, diff --git a/runtime/src/config.rs b/runtime/src/config.rs index 8641127..441ea93 100644 --- a/runtime/src/config.rs +++ b/runtime/src/config.rs @@ -15,8 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! A set of constant values used in substrate runtime. - +//! A set of configuration types used to configure the FRAME pallets. #![allow(clippy::identity_op)] use frame_support::{ dispatch::DispatchClass, @@ -71,6 +70,8 @@ pub mod core { pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 1 * time::HOURS; + + pub const MAX_BLOB_NUMBER: u32 = 100; } /// Money matters. @@ -116,8 +117,11 @@ pub mod system { parameter_types! { pub const BlockHashCount: BlockNumber = 2400; pub const Version: RuntimeVersion = VERSION; + + pub MaxBlobNumber: u32 = core::MAX_BLOB_NUMBER; pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, core::NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() .base_block(BlockExecutionWeight::get()) .for_class(DispatchClass::all(), |weights| { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7001283..8f056c9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -72,8 +72,7 @@ use pallet_transaction_payment::{ConstFeeMultiplier, CurrencyAdapter, Multiplier pub use sp_runtime::BuildStorage; pub use sp_runtime::{FixedU128, Perbill, Permill}; -/// Import the template pallet. -pub use pallet_template; +use melo_core_primitives::Header as ExtendedHeader; /// An index to a block. pub type BlockNumber = u32; @@ -97,6 +96,9 @@ pub type Hash = sp_core::H256; /// Time type pub type Moment = u64; +/// Block header type as expected by this runtime. +pub type Header = ExtendedHeader; + /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -107,7 +109,7 @@ pub mod opaque { pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; /// Opaque block header type. - pub type Header = generic::Header; + pub type Header = ExtendedHeader; /// Opaque block type. pub type Block = generic::Block; /// Opaque block identifier type. @@ -152,7 +154,7 @@ impl frame_system::Config for Runtime { /// The hashing algorithm used. type Hashing = BlakeTwo256; /// The header type. - type Header = generic::Header; + type Header = Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -259,12 +261,6 @@ impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; } -/// Configure the pallet-template in pallets/template. -impl pallet_template::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_template::weights::SubstrateWeight; -} - #[auto_config(skip_weight)] impl pallet_session::Config for Runtime { type WeightInfo = (); @@ -678,6 +674,21 @@ impl pallet_preimage::Config for Runtime { type ByteDeposit = PreimageByteDeposit; } +impl frame_system_ext::Config for Runtime { + type CommitList = MeloStore; + type ExtendedHeader = Header; +} + +#[auto_config(skip_weight)] +impl pallet_melo_store::Config for Runtime { + type AuthorityId = ImOnlineId; + type MaxBlobNum = system::MaxBlobNumber; + type MaxKeys = consensus::MaxKeys; + type ValidatorSet = Historical; + type WeightInfo = (); + type UnsignedPriority = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub struct Runtime @@ -686,42 +697,46 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic, { + // Basic stuff. System: frame_system, Timestamp: pallet_timestamp, + + // Consensus support. Babe: pallet_babe, Grandpa: pallet_grandpa, - Balances: pallet_balances, - TransactionPayment: pallet_transaction_payment, - Sudo: pallet_sudo, - - TemplateModule: pallet_template, - Session: pallet_session, Staking: pallet_staking, + ImOnline: pallet_im_online, + AuthorityDiscovery: pallet_authority_discovery, + Offences: pallet_offences, + Historical: pallet_session_historical::{Pallet}, + NominationPools: pallet_nomination_pools, + Scheduler: pallet_scheduler, VoterList: pallet_bags_list::, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase, + // Currency stuff. + Balances: pallet_balances, + TransactionPayment: pallet_transaction_payment, + + // Governance support. + Sudo: pallet_sudo, TechnicalCommittee: pallet_collective::, TechnicalMembership: pallet_membership::, Council: pallet_collective::, - - ElectionProviderMultiPhase: pallet_election_provider_multi_phase, Democracy: pallet_democracy, Treasury: pallet_treasury, - ImOnline: pallet_im_online, - AuthorityDiscovery: pallet_authority_discovery, - Offences: pallet_offences, - Historical: pallet_session_historical::{Pallet}, - NominationPools: pallet_nomination_pools, - Scheduler: pallet_scheduler, Bounties: pallet_bounties, Preimage: pallet_preimage, + + // Melodot. + MeloStore: pallet_melo_store, + SystemExt: frame_system_ext, } ); /// The address format for describing accounts. pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; /// The SignedExtension to the basic transaction logic. @@ -742,7 +757,7 @@ pub type UncheckedExtrinsic = /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; /// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< +pub type Executive = frame_executive_ext::Executive< Runtime, Block, frame_system::ChainContext, @@ -759,9 +774,24 @@ mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_timestamp, Timestamp] - [pallet_template, TemplateModule] + + [pallet_babe, crate::Babe] + [pallet_timestamp, crate::Timestamp] + [pallet_balances, crate::Balances] + [pallet_election_provider_multi_phase, crate::ElectionProviderMultiPhase] + [pallet_staking, crate::Staking] + [pallet_democracy, crate::Democracy] + [pallet_collective, crate::Council] + [pallet_collective, crate::TechnicalCommittee] + [pallet_elections_phragmen, crate::Elections] + [pallet_grandpa, crate::Grandpa] + [pallet_treasury, crate::Treasury] + [pallet_im_online, crate::ImOnline] + [pallet_scheduler, crate::Scheduler] + [pallet_bounties, crate::Bounties] + + [pallet_melo_store, crate::MeloStore] + [frame_system_ext, crate::SystemExt] ); }