,
+ /// Transaction pool instance.
+ pub pool: Arc,
+ /// Remote access to the blockchain (async).
+ pub remote_blockchain: Arc>,
+ /// Fetcher instance.
+ pub fetcher: Arc,
+}
+
+/// Extra dependencies for BABE.
+pub struct BabeDeps {
+ /// BABE protocol config.
+ pub babe_config: Config,
+ /// BABE pending epoch changes.
+ pub shared_epoch_changes: SharedEpochChanges,
+ /// The keystore that manages the keys of the node.
+ pub keystore: KeyStorePtr,
+}
+
+/// Extra dependencies for GRANDPA
+pub struct GrandpaDeps {
+ /// Voting round info.
+ pub shared_voter_state: SharedVoterState,
+ /// Authority set info.
+ pub shared_authority_set: SharedAuthoritySet,
+}
+
+/// Full client dependencies.
+pub struct FullDeps {
+ /// The client instance to use.
+ pub client: Arc,
+ /// Transaction pool instance.
+ pub pool: Arc,
+ /// The SelectChain Strategy
+ pub select_chain: SC,
+ /// Whether to deny unsafe calls
+ pub deny_unsafe: DenyUnsafe,
+ /// BABE specific dependencies.
+ pub babe: BabeDeps,
+ /// GRANDPA specific dependencies.
+ pub grandpa: GrandpaDeps,
+}
+
+/// Instantiate all Full RPC extensions.
+pub fn create_full(deps: FullDeps) -> jsonrpc_core::IoHandler
+where
+ C: ProvideRuntimeApi,
+ C: HeaderBackend + HeaderMetadata + 'static,
+ C: Send + Sync + 'static,
+ C::Api: substrate_frame_rpc_system::AccountNonceApi,
+ C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<
+ Block,
+ Balance,
+ UncheckedExtrinsic,
+ >,
+ C::Api: BabeApi,
+ C::Api: BlockBuilder,
+ P: TransactionPool + 'static,
+ M: jsonrpc_core::Metadata + Default,
+ SC: SelectChain + 'static,
+{
+ use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
+ use substrate_frame_rpc_system::{FullSystem, SystemApi};
+
+ let mut io = jsonrpc_core::IoHandler::default();
+ let FullDeps {
+ client,
+ pool,
+ select_chain,
+ deny_unsafe,
+ babe,
+ grandpa,
+ } = deps;
+ let BabeDeps {
+ keystore,
+ babe_config,
+ shared_epoch_changes,
+ } = babe;
+ let GrandpaDeps {
+ shared_voter_state,
+ shared_authority_set,
+ } = grandpa;
+
+ io.extend_with(SystemApi::to_delegate(FullSystem::new(
+ client.clone(),
+ pool,
+ deny_unsafe,
+ )));
+ // Making synchronous calls in light client freezes the browser currently,
+ // more context: https://github.com/paritytech/substrate/pull/3480
+ // These RPCs should use an asynchronous caller instead.
+ io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
+ client.clone(),
+ )));
+ io.extend_with(sc_consensus_babe_rpc::BabeApi::to_delegate(
+ BabeRpcHandler::new(
+ client,
+ shared_epoch_changes,
+ keystore,
+ babe_config,
+ select_chain,
+ deny_unsafe,
+ ),
+ ));
+ io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
+ GrandpaRpcHandler::new(shared_authority_set, shared_voter_state),
+ ));
+
+ io
+}
+
+/// Instantiate all Light RPC extensions.
+pub fn create_light(deps: LightDeps) -> jsonrpc_core::IoHandler
+where
+ C: sp_blockchain::HeaderBackend,
+ C: Send + Sync + 'static,
+ F: sc_client_api::light::Fetcher + 'static,
+ P: TransactionPool + 'static,
+ M: jsonrpc_core::Metadata + Default,
+{
+ use substrate_frame_rpc_system::{LightSystem, SystemApi};
+
+ let LightDeps {
+ client,
+ pool,
+ remote_blockchain,
+ fetcher,
+ } = deps;
+ let mut io = jsonrpc_core::IoHandler::default();
+ io.extend_with(SystemApi::::to_delegate(
+ LightSystem::new(client, remote_blockchain, fetcher, pool),
+ ));
+
+ io
+}
diff --git a/node/src/service.rs b/node/src/service.rs
index 64bf0a03d9..0aeed1e7a1 100644
--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -16,107 +16,141 @@
#![warn(unused_extern_crates)]
-// Clippy linter warning.
-#![allow(clippy::type_complexity)] // disable it because this is foreign code and can be changed any time
-
-// Clippy linter warning.
-#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-
-//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
-
-use client_db::Backend;
-use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
-use inherents::InherentDataProviders;
-use network::{construct_simple_protocol, NetworkService};
-use node_runtime::{self, opaque::Block, GenesisConfig, RuntimeApi};
-use offchain::OffchainWorkers;
-use primitives::Blake2Hasher;
-use runtime_primitives::traits::Block as BlockT;
-use std::sync::Arc;
-use substrate_client::{Client, LocalCallExecutor, LongestChain};
-pub use substrate_executor::{native_executor_instance, NativeExecutor};
-use substrate_service::{
- error::Error as ServiceError, AbstractService, Configuration, NetworkStatus, Service,
- ServiceBuilder,
-};
-use transaction_pool::{self, txpool::Pool as TransactionPool};
+// Substrate implementation issue.
+#![allow(clippy::redundant_closure_call)]
-construct_simple_protocol! {
- /// Demo protocol attachment for substrate.
- pub struct NodeProtocol where Block = Block { }
-}
+//! Service implementation. Specialized wrapper over substrate service.
-// Declare an instance of the native executor named `Executor`. Include the wasm binary as the
-// equivalent wasm code.
-native_executor_instance!(
- pub Executor,
- node_runtime::api::dispatch,
- node_runtime::native_version
-);
+use node_runtime::opaque::Block;
+use node_runtime::RuntimeApi;
+use sc_consensus::LongestChain;
+use sc_finality_grandpa::{
+ self as grandpa, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
+};
+use sc_service::{
+ config::Configuration, error::Error as ServiceError, AbstractService, ServiceBuilder,
+};
+use sp_inherents::InherentDataProviders;
+use std::sync::Arc;
+
+use crate::node_executor;
+use crate::node_rpc;
/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
-#[macro_export]
macro_rules! new_full_start {
($config:expr) => {{
- // type RpcExtension = jsonrpc_core::IoHandler;
+ use std::sync::Arc;
+
let mut import_setup = None;
- let inherent_data_providers = inherents::InherentDataProviders::new();
+ let mut rpc_setup = None;
+ let inherent_data_providers = sp_inherents::InherentDataProviders::new();
- let builder = substrate_service::ServiceBuilder::new_full::<
- node_runtime::opaque::Block,
- node_runtime::RuntimeApi,
- crate::service::Executor,
+ let builder = sc_service::ServiceBuilder::new_full::<
+ Block,
+ RuntimeApi,
+ node_executor::Executor,
>($config)?
- .with_select_chain(|_config, backend| {
- Ok(substrate_client::LongestChain::new(backend.clone()))
- })?
- .with_transaction_pool(|config, client| {
- Ok(transaction_pool::txpool::Pool::new(
- config,
- transaction_pool::FullChainApi::new(client),
+ .with_select_chain(|_config, backend| Ok(sc_consensus::LongestChain::new(backend.clone())))?
+ .with_transaction_pool(|builder| {
+ let pool_api = sc_transaction_pool::FullChainApi::new(builder.client().clone());
+ let config = builder.config();
+
+ Ok(sc_transaction_pool::BasicPool::new(
+ config.transaction_pool.clone(),
+ std::sync::Arc::new(pool_api),
+ builder.prometheus_registry(),
))
})?
- .with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
- let select_chain = select_chain
- .take()
- .ok_or_else(|| substrate_service::Error::SelectChainRequired)?;
- let (grandpa_block_import, grandpa_link) =
- grandpa::block_import::<_, _, _, node_runtime::RuntimeApi, _>(
+ .with_import_queue(
+ |_config,
+ client,
+ mut select_chain,
+ _transaction_pool,
+ spawn_task_handle,
+ prometheus_registry| {
+ let select_chain = select_chain
+ .take()
+ .ok_or_else(|| sc_service::Error::SelectChainRequired)?;
+ let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(),
- &*client,
+ &(client.clone() as Arc<_>),
select_chain,
)?;
- let justification_import = grandpa_block_import.clone();
-
- let (block_import, babe_link) = babe::block_import(
- babe::Config::get_or_compute(&*client)?,
- grandpa_block_import,
- client.clone(),
- client.clone(),
- )?;
-
- let import_queue = babe::import_queue(
- babe_link.clone(),
- block_import.clone(),
- Some(Box::new(justification_import)),
- None,
- client.clone(),
- client,
- inherent_data_providers.clone(),
- )?;
-
- import_setup = Some((block_import, grandpa_link, babe_link));
- Ok(import_queue)
+ let justification_import = grandpa_block_import.clone();
+
+ let (block_import, babe_link) = sc_consensus_babe::block_import(
+ sc_consensus_babe::Config::get_or_compute(&*client)?,
+ grandpa_block_import,
+ client.clone(),
+ )?;
+
+ let import_queue = sc_consensus_babe::import_queue(
+ babe_link.clone(),
+ block_import.clone(),
+ Some(Box::new(justification_import)),
+ None,
+ client,
+ inherent_data_providers.clone(),
+ spawn_task_handle,
+ prometheus_registry,
+ )?;
+
+ import_setup = Some((block_import, grandpa_link, babe_link));
+ Ok(import_queue)
+ },
+ )?
+ .with_rpc_extensions_builder(|builder| {
+ let grandpa_link = import_setup
+ .as_ref()
+ .map(|s| &s.1)
+ .expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
+
+ let shared_authority_set = grandpa_link.shared_authority_set().clone();
+ let shared_voter_state = grandpa::SharedVoterState::empty();
+
+ rpc_setup = Some((shared_voter_state.clone()));
+
+ let babe_link = import_setup
+ .as_ref()
+ .map(|s| &s.2)
+ .expect("BabeLink is present for full services or set up failed; qed.");
+
+ let babe_config = babe_link.config().clone();
+ let shared_epoch_changes = babe_link.epoch_changes().clone();
+
+ let client = builder.client().clone();
+ let pool = builder.pool().clone();
+ let select_chain = builder
+ .select_chain()
+ .cloned()
+ .expect("SelectChain is present for full services or set up failed; qed.");
+ let keystore = builder.keystore().clone();
+
+ Ok(move |deny_unsafe| {
+ let deps = node_rpc::FullDeps {
+ client: client.clone(),
+ pool: pool.clone(),
+ select_chain: select_chain.clone(),
+ deny_unsafe,
+ babe: node_rpc::BabeDeps {
+ babe_config: babe_config.clone(),
+ shared_epoch_changes: shared_epoch_changes.clone(),
+ keystore: keystore.clone(),
+ },
+ grandpa: node_rpc::GrandpaDeps {
+ shared_voter_state: shared_voter_state.clone(),
+ shared_authority_set: shared_authority_set.clone(),
+ },
+ };
+
+ node_rpc::create_full(deps)
+ })
})?;
- // We don't have any custom rpc commands...
- // .with_rpc_extensions(|client, pool| -> RpcExtension {
- // node_rpc::create(client, pool)
- // })?;
- (builder, import_setup, inherent_data_providers)
+ (builder, import_setup, inherent_data_providers, rpc_setup)
}};
}
@@ -126,58 +160,57 @@ macro_rules! new_full_start {
/// concrete types instead.
macro_rules! new_full {
($config:expr, $with_startup_data: expr) => {{
- use futures::sync::mpsc;
- use network::DhtEvent;
+ use futures::prelude::*;
+ use sc_network::Event;
+ use sc_client_api::ExecutorProvider;
+ use sp_core::traits::BareCryptoStorePtr;
let (
- is_authority,
+ role,
force_authoring,
name,
- disable_grandpa
+ disable_grandpa,
) = (
- $config.roles.is_authority(),
+ $config.role.clone(),
$config.force_authoring,
- $config.name.clone(),
- $config.disable_grandpa
+ $config.network.node_name.clone(),
+ $config.disable_grandpa,
);
- // sentry nodes announce themselves as authorities to the network
- // and should run the same protocols authorities do, but it should
- // never actively participate in any consensus process.
- let participates_in_consensus = is_authority && !$config.sentry_mode;
-
- let (builder, mut import_setup, inherent_data_providers) = new_full_start!($config);
-
- // Dht event channel from the network to the authority discovery module. Use bounded channel to ensure
- // back-pressure. Authority discovery is triggering one event per authority within the current authority set.
- // This estimates the authority set size to be somewhere below 10 000 thereby setting the channel buffer size to
- // 10 000.
- let (dht_event_tx, _dht_event_rx) =
- mpsc::channel::(10_000);
+ let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
+ new_full_start!($config);
- let service = builder.with_network_protocol(|_| Ok(crate::service::NodeProtocol::new()))?
- .with_finality_proof_provider(|client, backend|
- Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, client)) as _)
- )?
- .with_dht_event_tx(dht_event_tx)?
- .build()?;
+ let service = builder
+ .with_finality_proof_provider(|client, backend| {
+ // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
+ let provider = client as Arc>;
+ Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
+ })?
+ .build_full()?;
let (block_import, grandpa_link, babe_link) = import_setup.take()
- .expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
+ .expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
+
+ let shared_voter_state = rpc_setup.take()
+ .expect("The SharedVoterState is present for Full Services or setup failed before. qed");
($with_startup_data)(&block_import, &babe_link);
- if participates_in_consensus {
- let proposer = substrate_basic_authorship::ProposerFactory {
- client: service.client(),
- transaction_pool: service.transaction_pool(),
- };
+ if let sc_service::config::Role::Authority { .. } = &role {
+ let proposer = sc_basic_authorship::ProposerFactory::new(
+ service.client(),
+ service.transaction_pool(),
+ service.prometheus_registry().as_ref(),
+ );
let client = service.client();
let select_chain = service.select_chain()
- .ok_or(substrate_service::Error::SelectChainRequired)?;
+ .ok_or(sc_service::Error::SelectChainRequired)?;
+
+ let can_author_with =
+ sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
- let babe_config = babe::BabeParams {
+ let babe_config = sc_consensus_babe::BabeParams {
keystore: service.keystore(),
client,
select_chain,
@@ -187,62 +220,95 @@ macro_rules! new_full {
inherent_data_providers: inherent_data_providers.clone(),
force_authoring,
babe_link,
+ can_author_with,
};
- let babe = babe::start_babe(babe_config)?;
- service.spawn_essential_task(babe);
- }
+ let babe = sc_consensus_babe::start_babe(babe_config)?;
+ service.spawn_essential_task_handle().spawn_blocking("babe-proposer", babe);
+ }
+
+ // Spawn authority discovery module.
+ if matches!(role, sc_service::config::Role::Authority{..} | sc_service::config::Role::Sentry {..}) {
+ let (sentries, authority_discovery_role) = match role {
+ sc_service::config::Role::Authority { ref sentry_nodes } => (
+ sentry_nodes.clone(),
+ sc_authority_discovery::Role::Authority (
+ service.keystore(),
+ ),
+ ),
+ sc_service::config::Role::Sentry {..} => (
+ vec![],
+ sc_authority_discovery::Role::Sentry,
+ ),
+ _ => unreachable!("Due to outer matches! constraint; qed.")
+ };
+
+ let network = service.network();
+ let dht_event_stream = network.event_stream("authority-discovery").filter_map(|e| async move { match e {
+ Event::Dht(e) => Some(e),
+ _ => None,
+ }}).boxed();
+ let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new(
+ service.client(),
+ network,
+ sentries,
+ dht_event_stream,
+ authority_discovery_role,
+ service.prometheus_registry(),
+ );
+
+ service.spawn_task_handle().spawn("authority-discovery", authority_discovery);
+ }
- // if the node isn't actively participating in consensus then it doesn't
+ // if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
- let keystore = if participates_in_consensus {
- Some(service.keystore())
+ let keystore = if role.is_authority() {
+ Some(service.keystore() as BareCryptoStorePtr)
} else {
None
- };
-
- let config = grandpa::Config {
- // FIXME #1578 make this available through chainspec
- gossip_duration: std::time::Duration::from_millis(333),
- justification_period: 512,
- name: Some(name),
- observer_enabled: true,
- keystore,
- is_authority,
- };
-
- match (is_authority, disable_grandpa) {
- (false, false) => {
- // start the lightweight GRANDPA observer
- service.spawn_task(Box::new(grandpa::run_grandpa_observer(
- config,
- grandpa_link,
- service.network(),
- service.on_exit(),
- )?));
- },
- (true, false) => {
- // start the full GRANDPA voter
- let grandpa_config = grandpa::GrandpaParams {
- config,
- link: grandpa_link,
- network: service.network(),
- inherent_data_providers: inherent_data_providers.clone(),
- on_exit: service.on_exit(),
- telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
- voting_rule: grandpa::VotingRulesBuilder::default().build(),
- };
- // the GRANDPA voter task is considered infallible, i.e.
- // if it fails we take down the service with it.
- service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
- },
- (_, true) => {
- grandpa::setup_disabled_grandpa(
- service.client(),
- &inherent_data_providers,
- service.network(),
- )?;
- },
+ };
+
+ let config = grandpa::Config {
+ // FIXME #1578 make this available through chainspec
+ gossip_duration: std::time::Duration::from_millis(333),
+ justification_period: 512,
+ name: Some(name),
+ observer_enabled: false,
+ keystore,
+ is_authority: role.is_network_authority(),
+ };
+
+ let enable_grandpa = !disable_grandpa;
+ if enable_grandpa {
+ // start the full GRANDPA voter
+ // NOTE: non-authorities could run the GRANDPA observer protocol, but at
+ // this point the full voter should provide better guarantees of block
+ // and vote data availability than the observer. The observer has not
+ // been tested extensively yet and having most nodes in a network run it
+ // could lead to finality stalls.
+ let grandpa_config = grandpa::GrandpaParams {
+ config,
+ link: grandpa_link,
+ network: service.network(),
+ inherent_data_providers: inherent_data_providers.clone(),
+ telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
+ voting_rule: grandpa::VotingRulesBuilder::default().build(),
+ prometheus_registry: service.prometheus_registry(),
+ shared_voter_state,
+ };
+
+ // the GRANDPA voter task is considered infallible, i.e.
+ // if it fails we take down the service with it.
+ service.spawn_essential_task_handle().spawn_blocking(
+ "grandpa-voter",
+ grandpa::run_grandpa_voter(grandpa_config)?
+ );
+ } else {
+ grandpa::setup_disabled_grandpa(
+ service.client(),
+ &inherent_data_providers,
+ service.network(),
+ )?;
}
Ok((service, inherent_data_providers))
@@ -252,70 +318,49 @@ macro_rules! new_full {
}}
}
-#[allow(dead_code)]
-type ConcreteBlock = node_runtime::opaque::Block;
-#[allow(dead_code)]
-type ConcreteClient = Client<
- Backend,
- LocalCallExecutor, NativeExecutor>,
- ConcreteBlock,
- node_runtime::RuntimeApi,
->;
-#[allow(dead_code)]
-type ConcreteBackend = Backend;
-
-/// A specialized configuration object for setting up the node..
-pub type NodeConfiguration =
- Configuration;
-
/// Builds a new service for a full client.
-pub fn new_full(config: NodeConfiguration)
--> Result<
- Service<
- ConcreteBlock,
- ConcreteClient,
- LongestChain,
- NetworkStatus,
- NetworkService::Hash>,
- TransactionPool>,
- OffchainWorkers<
- ConcreteClient,
- >::OffchainStorage,
- ConcreteBlock,
- >
- >,
- ServiceError,
->
-{
+pub fn new_full(config: Configuration) -> Result {
new_full!(config).map(|(service, _)| service)
}
/// Builds a new service for a light client.
-pub fn new_light(
- config: NodeConfiguration,
-) -> Result {
- // type RpcExtension = jsonrpc_core::IoHandler;
+pub fn new_light(config: Configuration) -> Result {
let inherent_data_providers = InherentDataProviders::new();
- let service = ServiceBuilder::new_light::(config)?
+ let service = ServiceBuilder::new_light::(config)?
.with_select_chain(|_config, backend| Ok(LongestChain::new(backend.clone())))?
- .with_transaction_pool(|config, client| {
- Ok(TransactionPool::new(
- config,
- transaction_pool::FullChainApi::new(client),
- ))
+ .with_transaction_pool(|builder| {
+ let fetcher = builder
+ .fetcher()
+ .ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
+ let pool_api =
+ sc_transaction_pool::LightChainApi::new(builder.client().clone(), fetcher);
+ let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
+ builder.config().transaction_pool.clone(),
+ Arc::new(pool_api),
+ builder.prometheus_registry(),
+ sc_transaction_pool::RevalidationType::Light,
+ );
+ Ok(pool)
})?
.with_import_queue_and_fprb(
- |_config, client, backend, fetcher, _select_chain, _tx_pool| {
+ |_config,
+ client,
+ backend,
+ fetcher,
+ _select_chain,
+ _tx_pool,
+ spawn_task_handle,
+ registry| {
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| {
"Trying to start light import queue without active fetch checker"
})?;
- let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>(
+ let grandpa_block_import = grandpa::light_block_import(
client.clone(),
backend,
- &*client,
+ &(client.clone() as Arc<_>),
Arc::new(fetch_checker),
)?;
@@ -323,35 +368,49 @@ pub fn new_light(
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();
- let (babe_block_import, babe_link) = babe::block_import(
- babe::Config::get_or_compute(&*client)?,
+ let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
+ sc_consensus_babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
- client.clone(),
)?;
- let import_queue = babe::import_queue(
+ let import_queue = sc_consensus_babe::import_queue(
babe_link,
babe_block_import,
None,
Some(Box::new(finality_proof_import)),
- client.clone(),
client,
inherent_data_providers.clone(),
+ spawn_task_handle,
+ registry,
)?;
Ok((import_queue, finality_proof_request_builder))
},
)?
- .with_network_protocol(|_| Ok(NodeProtocol::new()))?
.with_finality_proof_provider(|client, backend| {
- Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
+ // GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
+ let provider = client as Arc>;
+ Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
+ })?
+ .with_rpc_extensions(|builder| {
+ let fetcher = builder
+ .fetcher()
+ .ok_or_else(|| "Trying to start node RPC without active fetcher")?;
+ let remote_blockchain = builder
+ .remote_backend()
+ .ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
+
+ let light_deps = node_rpc::LightDeps {
+ remote_blockchain,
+ fetcher,
+ client: builder.client().clone(),
+ pool: builder.pool(),
+ };
+
+ Ok(node_rpc::create_light(light_deps))
})?
- // We don't have any custom rpc extensions
- // .with_rpc_extensions(|client, pool| -> RpcExtension {
- // node_rpc::create(client, pool)
- // })?
- .build()?;
+ .build_light()?;
Ok(service)
}
diff --git a/runtime-modules/common/Cargo.toml b/runtime-modules/common/Cargo.toml
index df598a6ca8..b4c98bd9a7 100644
--- a/runtime-modules/common/Cargo.toml
+++ b/runtime-modules/common/Cargo.toml
@@ -1,52 +1,24 @@
[package]
-name = 'substrate-common-module'
-version = '1.2.0'
+name = 'pallet-common'
+version = '3.0.0'
authors = ['Joystream contributors']
edition = '2018'
+[dependencies]
+serde = { version = "1.0.101", optional = true, features = ["derive"] }
+codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+
[features]
default = ['std']
std = [
- 'sr-primitives/std',
- 'srml-support/std',
- 'system/std',
- 'timestamp/std',
+ 'serde',
'codec/std',
- 'serde'
+ 'sp-runtime/std',
+ 'frame-support/std',
+ 'system/std',
+ 'pallet-timestamp/std',
]
-
-
-[dependencies.sr-primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.srml-support]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-support'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.system]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-system'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '1.0.0'
-
-[dependencies.serde]
-features = ['derive']
-optional = true
-version = '1.0.101'
-
-[dependencies.timestamp]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-timestamp'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
\ No newline at end of file
diff --git a/runtime-modules/common/src/currency.rs b/runtime-modules/common/src/currency.rs
index 50d9ebaef0..2daa057358 100644
--- a/runtime-modules/common/src/currency.rs
+++ b/runtime-modules/common/src/currency.rs
@@ -1,5 +1,5 @@
-use sr_primitives::traits::Convert;
-use srml_support::traits::{Currency, LockableCurrency, ReservableCurrency};
+use frame_support::traits::{Currency, LockableCurrency, ReservableCurrency};
+use sp_runtime::traits::Convert;
pub trait GovernanceCurrency: system::Trait + Sized {
type Currency: Currency
diff --git a/runtime-modules/common/src/lib.rs b/runtime-modules/common/src/lib.rs
index b14afebe86..6201b26c0f 100644
--- a/runtime-modules/common/src/lib.rs
+++ b/runtime-modules/common/src/lib.rs
@@ -24,10 +24,10 @@ pub struct BlockAndTime {
/// Gathers current block and time information for the runtime.
/// If this function is used inside a config() at genesis the timestamp will be 0
/// because the timestamp is actually produced by validators.
-pub fn current_block_time(
+pub fn current_block_time(
) -> BlockAndTime {
BlockAndTime {
block: >::block_number(),
- time: >::now(),
+ time: >::now(),
}
}
diff --git a/runtime-modules/content-working-group/Cargo.toml b/runtime-modules/content-working-group/Cargo.toml
index d7066ab24b..dbf5ab8837 100644
--- a/runtime-modules/content-working-group/Cargo.toml
+++ b/runtime-modules/content-working-group/Cargo.toml
@@ -1,131 +1,48 @@
[package]
-name = 'substrate-content-working-group-module'
-version = '1.1.0'
+name = 'pallet-content-working-group'
+version = '3.0.0'
authors = ['Joystream contributors']
edition = '2018'
+[dependencies]
+serde = { version = "1.0.101", optional = true, features = ["derive"] }
+codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
+sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
+stake = { package = 'pallet-stake', default-features = false, path = '../stake'}
+hiring = { package = 'pallet-hiring', default-features = false, path = '../hiring'}
+minting = { package = 'pallet-token-mint', default-features = false, path = '../token-minting'}
+recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../recurring-reward'}
+versioned_store = { package = 'pallet-versioned-store', default-features = false, path = '../versioned-store'}
+versioned_store_permissions = { package = 'pallet-versioned-store-permissions', default-features = false, path = '../versioned-store-permissions'}
+common = { package = 'pallet-common', default-features = false, path = '../common'}
+
+[dev-dependencies]
+sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
+
[features]
default = ['std']
std = [
- 'sr-primitives/std',
- 'srml-support/std',
+ 'serde',
+ 'codec/std',
+ 'sp-std/std',
+ 'frame-support/std',
'system/std',
- 'serde',
- 'codec/std',
- 'primitives/std',
- 'rstd/std',
- 'membership/std',
- 'forum/std',
- 'hiring/std',
- 'stake/std',
- 'minting/std',
+ 'sp-arithmetic/std',
+ 'sp-runtime/std',
+ 'membership/std',
+ 'stake/std',
+ 'hiring/std',
+ 'minting/std',
+ 'recurringrewards/std',
'versioned_store/std',
'versioned_store_permissions/std',
- 'recurringrewards/std',
- 'common/std',
+ 'common/std',
]
-
-
-[dependencies.sr-primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.srml-support]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-support'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.system]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-system'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.rstd]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-std'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.serde]
-features = ['derive']
-optional = true
-version = '1.0.101'
-
-[dependencies.primitives]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'substrate-primitives'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '1.0.0'
-
-[dependencies.forum]
-default_features = false
-package = 'substrate-forum-module'
-path = '../forum'
-
-[dependencies.minting]
-default_features = false
-package = 'substrate-token-mint-module'
-path = '../token-minting'
-
-[dependencies.stake]
-default_features = false
-package = 'substrate-stake-module'
-path = '../stake'
-
-[dependencies.recurringrewards]
-default_features = false
-package = 'substrate-recurring-reward-module'
-path = '../recurring-reward'
-
-[dependencies.hiring]
-default_features = false
-package = 'substrate-hiring-module'
-path = '../hiring'
-
-[dependencies.versioned_store]
-default_features = false
-package ='substrate-versioned-store'
-path = '../versioned-store'
-
-[dependencies.versioned_store_permissions]
-default_features = false
-package = 'substrate-versioned-store-permissions-module'
-path = '../versioned-store-permissions'
-
-[dependencies.membership]
-default_features = false
-package = 'substrate-membership-module'
-path = '../membership'
-
-[dependencies.common]
-default_features = false
-package = 'substrate-common-module'
-path = '../common'
-
-[dev-dependencies.runtime-io]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'sr-io'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dev-dependencies.balances]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-balances'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
-
-[dev-dependencies.timestamp]
-default_features = false
-git = 'https://github.com/paritytech/substrate.git'
-package = 'srml-timestamp'
-rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
diff --git a/runtime-modules/content-working-group/src/genesis.rs b/runtime-modules/content-working-group/src/genesis.rs
index 5dd1fdfc8e..e4cb8741e3 100644
--- a/runtime-modules/content-working-group/src/genesis.rs
+++ b/runtime-modules/content-working-group/src/genesis.rs
@@ -1,36 +1,13 @@
#![cfg(test)]
use crate::{Trait, *};
-pub use primitives::{map, Blake2Hasher, H256};
-use rstd::prelude::*;
+use sp_std::map;
-/// DIRTY IMPORT BECAUSE
-/// InputValidationLengthConstraint has not been factored out yet!!!
use common::constraints::InputValidationLengthConstraint;
-/// The way a map (linked_map) is represented in the GenesisConfig produced by decl_storage
-//pub type GenesisConfigMap = std::vec::Vec<(K, V)>;
-
/// Builder of genesis configuration of content working group.
pub struct GenesisConfigBuilder {
mint_capacity: minting::BalanceOf,
- /*
- lead_by_id: GenesisConfigMap, Lead>,
- next_lead_id: LeadId,
- curator_opening_by_id: GenesisConfigMap, CuratorOpening, CuratorApplicationId>>,
- next_curator_opening_id: CuratorOpeningId,
- curator_application_by_id: GenesisConfigMap, CuratorApplication, T::MemberId, T::ApplicationId>>,
- next_curator_application_id: CuratorApplicationId,
- channel_by_id: GenesisConfigMap, Channel>>,
- next_channel_id: ChannelId,
- channel_id_by_handle: GenesisConfigMap, ChannelId>,
- curator_by_id: GenesisConfigMap, Curator, CuratorApplicationId, PrincipalId>>,
- next_curator_id: CuratorId,
- principal_by_id: GenesisConfigMap, Principal, ChannelId>>,
- next_principal_id: PrincipalId,
-
- unstaker_by_stake_id: GenesisConfigMap, CuratorId>>,
- */
channel_creation_enabled: bool,
channel_handle_constraint: InputValidationLengthConstraint,
channel_description_constraint: InputValidationLengthConstraint,
@@ -47,20 +24,7 @@ impl GenesisConfigBuilder {
self.mint_capacity = capacity;
self
}
- /*
- pub fn set_channel_handle_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self {
- self.channel_description_constraint = constraint;
- self
- }
- pub fn set_channel_description_constraint(mut self, constraint: InputValidationLengthConstraint) -> Self {
- self.channel_description_constraint = constraint;
- self
- }
- pub fn set_channel_creation_enabled(mut self, channel_creation_enabled: bool) -> Self {
- self.channel_creation_enabled = channel_creation_enabled;
- self
- }
- */
+
pub fn build(self) -> GenesisConfig {
GenesisConfig {
mint_capacity: self.mint_capacity,
@@ -68,7 +32,6 @@ impl GenesisConfigBuilder {
next_curator_opening_id: CuratorOpeningId::::default(),
curator_application_by_id: map![], //GenesisConfigMap,
next_curator_application_id: CuratorApplicationId::::default(),
-
channel_by_id: map![], //GenesisConfigMap,
next_channel_id: ChannelId::::default(),
channel_id_by_handle: map![], //GenesisConfigMap, ChannelId>,
@@ -78,12 +41,10 @@ impl GenesisConfigBuilder {
next_principal_id: PrincipalId::::default(),
channel_creation_enabled: self.channel_creation_enabled,
unstaker_by_stake_id: map![], //GenesisConfigMap,
-
channel_handle_constraint: self.channel_handle_constraint,
channel_description_constraint: self.channel_description_constraint,
curator_application_human_readable_text: self.curator_application_human_readable_text,
curator_exit_rationale_text: self.curator_exit_rationale_text,
-
channel_title_constraint: self.channel_title_constraint,
channel_avatar_constraint: self.channel_avatar_constraint,
channel_banner_constraint: self.channel_banner_constraint,
@@ -101,25 +62,6 @@ impl Default for GenesisConfigBuilder {
Self {
mint_capacity: minting::BalanceOf::::from(10000),
-
- /*
- current_lead_id: LeadId::::default(), //Option,
- lead_by_id: map![], //GenesisConfigMap,
- next_lead_id: 0,
- curator_opening_by_id: map![], //GenesisConfigMap,
- next_curator_opening_id: 0,
- curator_application_by_id: map![], //GenesisConfigMap,
- next_curator_application_id: 0,
- channel_by_id: map![], //GenesisConfigMap,
- next_channel_id: 0,
- channel_id_by_handle: map![], //GenesisConfigMap, ChannelId>,
- curator_by_id: map![], //GenesisConfigMap,
- next_curator_id: 0,
- principal_by_id: map![], //GenesisConfigMap,
- next_principal_id: 0,
-
- unstaker_by_stake_id: map![], //GenesisConfigMap,
- */
channel_creation_enabled: true,
channel_handle_constraint: default_constraint.clone(),
channel_description_constraint: default_constraint.clone(),
diff --git a/runtime-modules/content-working-group/src/lib.rs b/runtime-modules/content-working-group/src/lib.rs
index 2054101967..a58a049a45 100755
--- a/runtime-modules/content-working-group/src/lib.rs
+++ b/runtime-modules/content-working-group/src/lib.rs
@@ -20,15 +20,14 @@ pub mod genesis;
use serde::{Deserialize, Serialize};
use codec::{Decode, Encode};
-use rstd::borrow::ToOwned;
-use rstd::collections::btree_map::BTreeMap;
-use rstd::collections::btree_set::BTreeSet;
-use rstd::convert::From;
-use rstd::prelude::*;
-use sr_primitives::traits::{One, Zero};
-use srml_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
-use srml_support::{decl_event, decl_module, decl_storage, dispatch, ensure};
-use system::{self, ensure_root, ensure_signed};
+use frame_support::traits::{Currency, ExistenceRequirement, WithdrawReasons};
+use frame_support::{decl_event, decl_module, decl_storage, ensure};
+use sp_arithmetic::traits::{One, Zero};
+use sp_std::borrow::ToOwned;
+use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
+use sp_std::vec;
+use sp_std::vec::Vec;
+use system::{ensure_root, ensure_signed};
use common::constraints::InputValidationLengthConstraint;
@@ -42,8 +41,6 @@ pub trait Trait:
+ versioned_store_permissions::Trait
+ membership::Trait
{
- // + Sized
-
/// The event type.
type Event: From> + Into<::Event>;
}
@@ -93,6 +90,10 @@ pub type CuratorApplicationIdToCuratorIdMap = BTreeMap = BTreeSet>;
+//TODO: Convert errors to the Substrate decl_error! macro.
+/// Result with string error message. This exists for backward compatibility purpose.
+pub type DispatchResult = Result<(), &'static str>;
+
/*
* MOVE ALL OF THESE OUT TO COMMON LATER
*/
@@ -718,10 +719,7 @@ pub struct OpeningPolicyCommitment {
/// Staking policy for role itself
pub role_staking_policy: Option>,
- // Slashing terms during application
- // pub application_slashing_terms: SlashingTerms,
-
- // Slashing terms during role, NOT application itself!
+ /// Slashing terms during role, NOT application itself!
pub role_slashing_terms: SlashingTerms,
/// When filling an opening: Unstaking period for application stake of successful applicants
@@ -769,12 +767,6 @@ impl Default for WorkingGroupUnstaker {
// can this be made generic, or does that undermine the whole orhpan rule spirit?
pub error: E,
@@ -783,7 +775,9 @@ pub struct WrappedError {
/// ....
macro_rules! ensure_on_wrapped_error {
($call:expr) => {{
- { $call }.map_err(|err| WrappedError { error: err })
+ { $call }
+ .map_err(|err| WrappedError { error: err })
+ .map_err(<&str>::from)
}};
}
@@ -791,7 +785,7 @@ macro_rules! ensure_on_wrapped_error {
//derive_from_impl(hiring::BeginAcceptingApplicationsError)
//derive_from_impl(hiring::BeginAcceptingApplicationsError)
-impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
hiring::BeginAcceptingApplicationsError::OpeningDoesNotExist => {
@@ -804,7 +798,7 @@ impl rstd::convert::From>
}
}
-impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
hiring::AddOpeningError::OpeningMustActivateInTheFuture => {
@@ -833,7 +827,7 @@ impl rstd::convert::From> for &str {
}
}
-impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
hiring::BeginReviewError::OpeningDoesNotExist => {
@@ -846,7 +840,7 @@ impl rstd::convert::From> for &str {
}
}
-impl rstd::convert::From>> for &str {
+impl sp_std::convert::From>> for &str {
fn from(wrapper: WrappedError>) -> Self {
match wrapper.error {
hiring::FillOpeningError::::OpeningDoesNotExist => MSG_FULL_CURATOR_OPENING_OPENING_DOES_NOT_EXIST,
@@ -884,7 +878,7 @@ impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
hiring::DeactivateApplicationError::ApplicationDoesNotExist => {
@@ -906,7 +900,9 @@ impl rstd::convert::From> for &
}
}
-impl rstd::convert::From> for &str {
+impl sp_std::convert::From>
+ for &str
+{
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
membership::ControllerAccountForMemberCheckFailed::NotMember => {
@@ -919,7 +915,7 @@ impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
hiring::AddApplicationError::OpeningDoesNotExist => {
@@ -944,7 +940,7 @@ impl rstd::convert::From> for &str {
}
}
-impl rstd::convert::From> for &str {
+impl sp_std::convert::From> for &str {
fn from(wrapper: WrappedError) -> Self {
match wrapper.error {
membership::MemberControllerAccountDidNotSign::UnsignedOrigin => {
@@ -974,83 +970,83 @@ decl_storage! {
trait Store for Module as ContentWorkingGroup {
/// The mint currently funding the rewards for this module.
- pub Mint get(mint) : ::MintId;
+ pub Mint get(fn mint) : ::MintId;
/// The current lead.
- pub CurrentLeadId get(current_lead_id) : Option>;
+ pub CurrentLeadId get(fn current_lead_id) : Option>;
/// Maps identifier to corresponding lead.
- pub LeadById get(lead_by_id): linked_map LeadId => Lead;
+ pub LeadById get(fn lead_by_id): map hasher(blake2_128_concat)
+ LeadId => Lead;
/// Next identifier for new current lead.
- pub NextLeadId get(next_lead_id): LeadId;
+ pub NextLeadId get(fn next_lead_id): LeadId;
/// Maps identifeir to curator opening.
- pub CuratorOpeningById get(curator_opening_by_id) config(): linked_map CuratorOpeningId => CuratorOpening, CuratorApplicationId>;
+ pub CuratorOpeningById get(fn curator_opening_by_id) config(): map hasher(blake2_128_concat)
+ CuratorOpeningId => CuratorOpening, CuratorApplicationId>;
/// Next identifier valuefor new curator opening.
- pub NextCuratorOpeningId get(next_curator_opening_id) config(): CuratorOpeningId;
+ pub NextCuratorOpeningId get(fn next_curator_opening_id) config(): CuratorOpeningId;
/// Maps identifier to curator application on opening.
- pub CuratorApplicationById get(curator_application_by_id) config(): linked_map CuratorApplicationId => CuratorApplication, T::MemberId, T::ApplicationId>;
+ pub CuratorApplicationById get(fn curator_application_by_id) config(): map hasher(blake2_128_concat)
+ CuratorApplicationId => CuratorApplication, T::MemberId, T::ApplicationId>;
/// Next identifier value for new curator application.
- pub NextCuratorApplicationId get(next_curator_application_id) config(): CuratorApplicationId;
+ pub NextCuratorApplicationId get(fn next_curator_application_id) config(): CuratorApplicationId;
/// Maps identifier to corresponding channel.
- pub ChannelById get(channel_by_id) config(): linked_map ChannelId => Channel>;
+ pub ChannelById get(fn channel_by_id) config(): map hasher(blake2_128_concat)
+ ChannelId => Channel>;
/// Identifier to be used by the next channel introduced.
- pub NextChannelId get(next_channel_id) config(): ChannelId;
+ pub NextChannelId get(fn next_channel_id) config(): ChannelId;
/// Maps (unique) channel handle to the corresponding identifier for the channel.
/// Mapping is required to allow efficient (O(log N)) on-chain verification that a proposed handle is indeed unique
/// at the time it is being proposed.
- pub ChannelIdByHandle get(channel_id_by_handle) config(): linked_map Vec => ChannelId;
+ pub ChannelIdByHandle get(fn channel_id_by_handle) config(): map hasher(blake2_128_concat)
+ Vec => ChannelId;
/// Maps identifier to corresponding curator.
- pub CuratorById get(curator_by_id) config(): linked_map CuratorId => Curator, CuratorApplicationId, PrincipalId>;
+ pub CuratorById get(fn curator_by_id) config(): map hasher(blake2_128_concat)
+ CuratorId => Curator, CuratorApplicationId, PrincipalId>;
/// Next identifier for new curator.
- pub NextCuratorId get(next_curator_id) config(): CuratorId;
+ pub NextCuratorId get(fn next_curator_id) config(): CuratorId;
/// Maps identifier to principal.
- pub PrincipalById get(principal_by_id) config(): linked_map PrincipalId => Principal, ChannelId>;
+ pub PrincipalById get(fn principal_by_id) config(): map hasher(blake2_128_concat)
+ PrincipalId => Principal, ChannelId>;
/// Next identifier for
- pub NextPrincipalId get(next_principal_id) config(): PrincipalId;
+ pub NextPrincipalId get(fn next_principal_id) config(): PrincipalId;
/// Whether it is currently possible to create a channel via `create_channel` extrinsic.
- pub ChannelCreationEnabled get(channel_creation_enabled) config(): bool;
+ pub ChannelCreationEnabled get(fn channel_creation_enabled) config(): bool;
/// Recover curator by the role stake which is currently unstaking.
- pub UnstakerByStakeId get(unstaker_by_stake_id) config(): linked_map StakeId => WorkingGroupUnstaker, CuratorId>;
-
- // Limits
-
- /// Limits the total number of curators which can be active.
- //pub MaxSimultanouslyActiveCurators get(max_simultanously_active_curators) config(): Option;
+ pub UnstakerByStakeId get(fn unstaker_by_stake_id) config(): map hasher(blake2_128_concat)
+ StakeId => WorkingGroupUnstaker, CuratorId>;
- // Limits the total number of openings which are not yet deactivated.
- // pub MaxSimultaneouslyActiveOpenings get(max_simultaneously_active_openings) config(): Option,
// Vector length input guards
-
- pub ChannelHandleConstraint get(channel_handle_constraint) config(): InputValidationLengthConstraint;
- pub ChannelTitleConstraint get(channel_title_constraint) config(): InputValidationLengthConstraint;
- pub ChannelDescriptionConstraint get(channel_description_constraint) config(): InputValidationLengthConstraint;
- pub ChannelAvatarConstraint get(channel_avatar_constraint) config(): InputValidationLengthConstraint;
- pub ChannelBannerConstraint get(channel_banner_constraint) config(): InputValidationLengthConstraint;
- pub OpeningHumanReadableText get(opening_human_readable_text) config(): InputValidationLengthConstraint;
- pub CuratorApplicationHumanReadableText get(curator_application_human_readable_text) config(): InputValidationLengthConstraint;
- pub CuratorExitRationaleText get(curator_exit_rationale_text) config(): InputValidationLengthConstraint;
+ pub ChannelHandleConstraint get(fn channel_handle_constraint) config(): InputValidationLengthConstraint;
+ pub ChannelTitleConstraint get(fn channel_title_constraint) config(): InputValidationLengthConstraint;
+ pub ChannelDescriptionConstraint get(fn channel_description_constraint) config(): InputValidationLengthConstraint;
+ pub ChannelAvatarConstraint get(fn channel_avatar_constraint) config(): InputValidationLengthConstraint;
+ pub ChannelBannerConstraint get(fn channel_banner_constraint) config(): InputValidationLengthConstraint;
+ pub OpeningHumanReadableText get(fn opening_human_readable_text) config(): InputValidationLengthConstraint;
+ pub CuratorApplicationHumanReadableText get(fn curator_application_human_readable_text) config(): InputValidationLengthConstraint;
+ pub CuratorExitRationaleText get(fn curator_exit_rationale_text) config(): InputValidationLengthConstraint;
}
add_extra_genesis {
config(mint_capacity): minting::BalanceOf;
- // config(mint_adjustment): minting::Adjustment, T::BlockNumber> (add serialize/deserialize derivation for type)
build(|config: &GenesisConfig| {
// create mint
- let mint_id = >::add_mint(config.mint_capacity, None).expect("Failed to create a mint for the content working group");
+ let mint_id = >::add_mint(config.mint_capacity, None)
+ .expect("Failed to create a mint for the content working group");
Mint::