diff --git a/Cargo.lock b/Cargo.lock
index ad7c81613..15303c556 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5095,6 +5095,7 @@ dependencies = [
"frame-support",
"frame-system",
"log",
+ "nimbus-primitives",
"pallet-aura",
"pallet-authorship",
"pallet-balances",
diff --git a/node/src/command.rs b/node/src/command.rs
index b669a69de..65ac483a1 100644
--- a/node/src/command.rs
+++ b/node/src/command.rs
@@ -20,7 +20,7 @@ use crate::{
chain_specs,
cli::{Cli, RelayChainCli, Subcommand},
rpc,
- service::{new_partial, CalamariRuntimeExecutor, DolphinRuntimeExecutor, MantaRuntimeExecutor},
+ service::{new_partial, CalamariRuntimeExecutor, MantaRuntimeExecutor},
service_nimbus::DolphinRuntimeExecutor,
};
use codec::Encode;
@@ -553,6 +553,7 @@ pub fn run_with(cli: Cli) -> Result {
crate::service_nimbus::start_parachain_node::<
dolphin_runtime::RuntimeApi,
DolphinRuntimeExecutor,
+ _,
>(
config,
polkadot_config,
diff --git a/node/src/service_nimbus.rs b/node/src/service_nimbus.rs
index 161980328..eba9cbdeb 100644
--- a/node/src/service_nimbus.rs
+++ b/node/src/service_nimbus.rs
@@ -14,57 +14,59 @@
// You should have received a copy of the GNU General Public License
// along with Manta. If not, see .
-use codec::Codec;
-use core::marker::PhantomData;
+//! Nimbus-based Parachain Node Service
+
+use crate::rpc;
+// use codec::Codec;
+// use core::marker::PhantomData;
use cumulus_client_cli::CollatorOptions;
-use cumulus_client_consensus_common::{
- ParachainBlockImport, ParachainCandidate, ParachainConsensus,
-};
+use cumulus_client_consensus_common::ParachainConsensus;
+// use cumulus_client_consensus_common::{
+// ParachainBlockImport, ParachainCandidate, ParachainConsensus,
+// };
use cumulus_client_network::BlockAnnounceValidator;
use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
-use cumulus_primitives_core::{
- relay_chain::v1::{Hash as PHash, PersistedValidationData},
- ParaId,
-};
-use cumulus_primitives_parachain_inherent::{
- MockValidationDataInherentDataProvider, MockXcmConfig,
-};
+use cumulus_primitives_core::ParaId;
+// use cumulus_primitives_parachain_inherent::{
+// MockValidationDataInherentDataProvider, MockXcmConfig,
+// };
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
+use jsonrpsee::RpcModule;
use polkadot_service::{CollatorPair, NativeExecutionDispatch};
-use crate::rpc;
-use dolphin_runtime::RuntimeApi;
+// use futures::lock::Mutex;
+// use dolphin_runtime::RuntimeApi;
pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
-use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
-use futures::lock::Mutex;
+// use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
use nimbus_consensus::{BuildNimbusConsensusParams, NimbusConsensus};
use nimbus_primitives::NimbusId;
-use sc_client_api::ExecutorProvider;
-use sc_consensus::{
- import_queue::{BasicQueue, Verifier as VerifierT},
- BlockImportParams,
-};
+// use sc_client_api::ExecutorProvider;
+// use sc_consensus::{
+// import_queue::{BasicQueue, Verifier as VerifierT},
+// BlockImportParams,
+// };
use sc_executor::NativeElseWasmExecutor;
use sc_network::NetworkService;
-use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
+pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
+use sc_service::{Configuration, Error, Role, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::{ApiExt, ConstructRuntimeApi};
-use sp_consensus::CacheKeyId;
-use sp_core::crypto::Pair;
+// use sp_consensus::CacheKeyId;
+// use sp_core::crypto::Pair;
use sp_keystore::SyncCryptoStorePtr;
-use sp_runtime::{
- app_crypto::AppKey,
- generic::BlockId,
- traits::{BlakeTwo256, Header as HeaderT},
-};
+use sp_offchain::OffchainWorkerApi;
+use sp_runtime::traits::BlakeTwo256;
+use sp_session::SessionKeys;
+use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
use std::sync::Arc;
use substrate_prometheus_endpoint::Registry;
-// Native Dolphin Parachain executor instance.
+
+/// Native Dolphin Parachain executor instance.
pub struct DolphinRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
@@ -78,6 +80,29 @@ impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor {
}
}
+/// Full Client Implementation Type
+pub type Client = TFullClient>;
+
+/// Default Import Queue Type
+pub type ImportQueue = sc_consensus::DefaultImportQueue>;
+
+/// Full Transaction Pool Type
+pub type TransactionPool = sc_transaction_pool::FullPool>;
+
+/// Components Needed for Chain Ops Subcommands
+pub type PartialComponents = sc_service::PartialComponents<
+ Client,
+ TFullBackend,
+ // (),
+ sc_consensus::LongestChain, Block>, // TODO: Undo this change if ManualSeal turns out to be useless
+ ImportQueue,
+ TransactionPool,
+ (Option, Option),
+>;
+
+/// State Backend Type
+pub type StateBackend = sc_client_api::StateBackendFor, Block>;
+
/// 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
@@ -85,37 +110,16 @@ impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor {
pub fn new_partial(
config: &Configuration,
dev_service: bool,
-) -> Result<
- PartialComponents<
- TFullClient>,
- TFullBackend,
- sc_consensus::LongestChain, Block>, // TODO: Undo this change if ManualSeal turns out to be useless
- sc_consensus::DefaultImportQueue<
- Block,
- TFullClient>,
- >,
- sc_transaction_pool::FullPool<
- Block,
- TFullClient>,
- >,
- (Option, Option),
- >,
- sc_service::Error,
->
+) -> Result, Error>
where
- RuntimeApi: ConstructRuntimeApi>>
- + Send
- + Sync
- + 'static,
- RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue
+ RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static,
+ RuntimeApi::RuntimeApi: TaggedTransactionQueue
+ sp_api::Metadata
- + sp_session::SessionKeys
- + sp_api::ApiExt<
- Block,
- StateBackend = sc_client_api::StateBackendFor, Block>,
- > + sp_offchain::OffchainWorkerApi
+ + SessionKeys
+ + ApiExt
+ + OffchainWorkerApi
+ sp_block_builder::BlockBuilder,
- sc_client_api::StateBackendFor, Block>: sp_api::StateBackend,
+ StateBackend: sp_api::StateBackend,
Executor: NativeExecutionDispatch + 'static,
{
let telemetry = config
@@ -128,14 +132,12 @@ where
Ok((worker, telemetry))
})
.transpose()?;
-
let executor = sc_executor::NativeElseWasmExecutor::::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
config.runtime_cache_size,
);
-
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::(
config,
@@ -143,20 +145,16 @@ where
executor,
)?;
let client = Arc::new(client);
-
let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());
-
let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager
.spawn_handle()
.spawn("telemetry", None, worker.run());
telemetry
});
-
// Although this will not be used by the parachain collator, it will be used by the instant seal
// And sovereign nodes, so we create it anyway.
let select_chain = sc_consensus::LongestChain::new(backend.clone());
-
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
config.role.is_authority().into(),
@@ -164,7 +162,6 @@ where
task_manager.spawn_essential_handle(),
client.clone(),
);
-
let import_queue = nimbus_consensus::import_queue(
client.clone(),
client.clone(),
@@ -174,11 +171,11 @@ where
Ok((time,))
},
&task_manager.spawn_essential_handle(),
- config.prometheus_registry().clone(), // TODO: Check impact of this change on telemetry
+ config.prometheus_registry(), // TODO: Check impact of this change on telemetry
!dev_service,
)?;
- let params = PartialComponents {
+ Ok(PartialComponents {
backend,
client,
import_queue,
@@ -187,9 +184,7 @@ where
transaction_pool,
select_chain,
other: (telemetry, telemetry_worker_handle),
- };
-
- Ok(params)
+ })
}
async fn build_relay_chain_interface(
@@ -198,6 +193,7 @@ async fn build_relay_chain_interface(
telemetry_worker_handle: Option,
task_manager: &mut TaskManager,
collator_options: CollatorOptions,
+ hwbench: Option,
) -> RelayChainResult<(
Arc<(dyn RelayChainInterface + 'static)>,
Option,
@@ -212,6 +208,7 @@ async fn build_relay_chain_interface(
parachain_config,
telemetry_worker_handle,
task_manager,
+ hwbench,
),
}
}
@@ -220,58 +217,48 @@ async fn build_relay_chain_interface(
///
/// This is the actual implementation that is abstract over the executor and the runtime api.
#[sc_tracing::logging::prefix_logs_with("Parachain")]
-async fn start_node_impl(
+async fn start_node_impl(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
- _rpc_ext_builder: RB,
+ full_rpc: FullRpc,
build_consensus: BIC,
+ hwbench: Option,
) -> sc_service::error::Result<(
TaskManager,
Arc>>,
)>
where
- RuntimeApi: ConstructRuntimeApi>>
- + Send
- + Sync
- + 'static,
- RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue
+ RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static,
+ RuntimeApi::RuntimeApi: TaggedTransactionQueue
+ sp_api::Metadata
- + sp_session::SessionKeys
- + sp_api::ApiExt<
- Block,
- StateBackend = sc_client_api::StateBackendFor, Block>,
- > + sp_offchain::OffchainWorkerApi
+ + SessionKeys
+ + ApiExt
+ + OffchainWorkerApi
+ sp_block_builder::BlockBuilder
+ cumulus_primitives_core::CollectCollationInfo
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi
+ nimbus_primitives::AuthorFilterAPI
+ nimbus_primitives::NimbusApi
+ frame_rpc_system::AccountNonceApi,
- sc_client_api::StateBackendFor, Block>: sp_api::StateBackend,
+ StateBackend: sp_api::StateBackend,
Executor: sc_executor::NativeExecutionDispatch + 'static,
- RB: Fn(
- Arc>,
- ) -> Result, sc_service::Error>
- + Send
+ FullRpc: Fn(
+ rpc::FullDeps, TransactionPool>,
+ ) -> Result, Error>
+ 'static,
BIC: FnOnce(
- Arc>>,
+ Arc>,
Option<&Registry>,
Option,
&TaskManager,
Arc,
- Arc<
- sc_transaction_pool::FullPool<
- Block,
- TFullClient>,
- >,
- >,
+ Arc>,
Arc>,
SyncCryptoStorePtr,
bool,
- ) -> Result>, sc_service::Error>,
+ ) -> Result>, Error>,
{
if matches!(parachain_config.role, Role::Light) {
return Err("Light client not supported!".into());
@@ -289,6 +276,7 @@ where
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
+ hwbench.clone(),
)
.await
.map_err(|e| match e {
@@ -318,23 +306,23 @@ where
warp_sync: None,
})?;
- let rpc_extensions_builder = {
+ let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
Box::new(move |deny_unsafe, _| {
- let deps = rpc::FullDeps {
+ let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};
- Ok(rpc::create_full(deps))
+ full_rpc(deps)
})
};
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
- rpc_extensions_builder,
+ rpc_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
@@ -364,10 +352,8 @@ where
params.keystore_container.sync_keystore(),
force_authoring,
)?;
-
let spawner = task_manager.spawn_handle();
-
- let params = StartCollatorParams {
+ start_collator(StartCollatorParams {
para_id: id,
block_status: client.clone(),
announce_block,
@@ -379,11 +365,10 @@ where
import_queue,
collator_key: collator_key.expect("Command line arguments do not allow this. qed"),
relay_chain_slot_duration,
- };
-
- start_collator(params).await?;
+ })
+ .await?;
} else {
- let params = StartFullNodeParams {
+ start_full_node(StartFullNodeParams {
client: client.clone(),
announce_block,
task_manager: &mut task_manager,
@@ -392,73 +377,73 @@ where
relay_chain_slot_duration,
import_queue,
collator_options,
- };
-
- start_full_node(params)?;
+ })?;
}
start_network.start_network();
-
Ok((task_manager, client))
}
/// Start a dolphin parachain node.
-pub async fn start_parachain_node(
+pub async fn start_parachain_node(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
+ hwbench: Option,
+ full_rpc: FullRpc,
) -> sc_service::error::Result<(
TaskManager,
Arc>>,
)>
where
- RuntimeApi: ConstructRuntimeApi>>
- + Send
- + Sync
- + 'static,
+ RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static,
// sp_runtime::generic::Block, OpaqueExtrinsic>
// , RuntimeApi>>>::RuntimeApi: nimbus_primitives::AuthorFilterAPI, OpaqueExtrinsic>, nimbus_primitives::nimbus_crypto::Public>
- RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue
+ RuntimeApi::RuntimeApi: TaggedTransactionQueue
+ sp_api::Metadata
- + sp_session::SessionKeys
- + sp_api::ApiExt<
- Block,
- StateBackend = sc_client_api::StateBackendFor, Block>,
- > + sp_offchain::OffchainWorkerApi
+ + SessionKeys
+ + ApiExt
+ + OffchainWorkerApi
+ sp_block_builder::BlockBuilder
+ cumulus_primitives_core::CollectCollationInfo
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi
+ nimbus_primitives::AuthorFilterAPI
+ nimbus_primitives::NimbusApi
+ frame_rpc_system::AccountNonceApi,
- sc_client_api::StateBackendFor, Block>: sp_api::StateBackend,
+ StateBackend: sp_api::StateBackend,
Executor: sc_executor::NativeExecutionDispatch + 'static,
+ FullRpc: Fn(
+ rpc::FullDeps, TransactionPool>,
+ ) -> Result, Error>
+ + 'static,
{
start_node_impl::(
parachain_config,
polkadot_config,
collator_options,
id,
- |_| Ok(Default::default()),
+ full_rpc,
|client,
prometheus_registry,
telemetry,
task_manager,
relay_chain_interface,
transaction_pool,
- sync_oracle,
+ _sync_oracle,
keystore,
force_authoring| {
+ let spawn_handle = task_manager.spawn_handle();
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
- task_manager.spawn_handle(),
+ spawn_handle,
client.clone(),
transaction_pool,
prometheus_registry,
- telemetry.clone(),
+ telemetry,
);
- let provider = move |_, (relay_parent, validation_data, author_id)| {
+ // NOTE: In nimbus, author_id is unused as it is the RuntimeAPI that identifies the block author
+ let provider = move |_, (relay_parent, validation_data, _author_id)| {
let relay_chain_interface = relay_chain_interface.clone();
async move {
let parachain_inherent =
@@ -478,9 +463,8 @@ where
)
})?;
- let author = nimbus_primitives::InherentDataProvider::(author_id);
-
- Ok((time, parachain_inherent, author))
+ let nimbus_inherent = nimbus_primitives::InherentDataProvider;
+ Ok((time, parachain_inherent, nimbus_inherent))
}
};
@@ -488,18 +472,19 @@ where
para_id: id,
proposer_factory,
block_import: client.clone(),
- parachain_client: client.clone(),
+ parachain_client: client,
keystore,
skip_prediction: force_authoring,
create_inherent_data_providers: provider,
}))
},
+ hwbench,
)
.await
}
/// Builds a new service for an instant-seal local dev full client.
-pub fn start_instant_seal_node(config: Configuration) -> Result
+pub fn start_instant_seal_node(_config: Configuration) -> Result
// where
// RuntimeApi: ConstructRuntimeApi>>
// + Send
@@ -507,7 +492,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result
// + sp_api::Metadata
-// + sp_session::SessionKeys
+// + SessionKeys
// + sp_api::ApiExt<
// Block,
// StateBackend = sc_client_api::StateBackendFor, Block>,
diff --git a/pallets/collator-selection/Cargo.toml b/pallets/collator-selection/Cargo.toml
index 5bdd5cbb0..54167fd6d 100644
--- a/pallets/collator-selection/Cargo.toml
+++ b/pallets/collator-selection/Cargo.toml
@@ -22,6 +22,7 @@ serde = { version = "1.0.137", default-features = false }
frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22", optional = true }
frame-support = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22" }
frame-system = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22" }
+nimbus-primitives = { git = "https://github.com/manta-network/nimbus.git", branch = "polkadot-v0.9.22", default-features = false }
pallet-authorship = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22" }
pallet-session = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22" }
sp-arithmetic = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.22" }
diff --git a/runtime/dolphin/src/lib.rs b/runtime/dolphin/src/lib.rs
index 3b98422ff..45c0d81bb 100644
--- a/runtime/dolphin/src/lib.rs
+++ b/runtime/dolphin/src/lib.rs
@@ -24,7 +24,8 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
-use nimbus_primitives::{AccountLookup, NimbusId};
+use nimbus_primitives::NimbusId;
+// use nimbus_primitives::{AccountLookup, NimbusId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
@@ -40,11 +41,10 @@ use sp_version::RuntimeVersion;
use sp_version::NativeVersion;
use frame_support::{
- construct_runtime, parameter_types,
- traits::{
- ConstU16, ConstU32, ConstU8, Contains, Currency, EnsureOneOf, PrivilegeCmp,
- ValidatorRegistration,
- },
+ construct_runtime,
+ parameter_types,
+ // traits::ValidatorRegistration,
+ traits::{ConstU16, ConstU32, ConstU8, Contains, Currency, EnsureOneOf, PrivilegeCmp},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, Weight,
@@ -59,7 +59,6 @@ use manta_primitives::{
constants::{time::*, STAKING_PALLET_ID, TREASURY_PALLET_ID},
types::{AccountId, Balance, BlockNumber, Hash, Header, Index, Signature},
};
-use nimbus_primitives::NimbusId;
use runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate};
use session_key_primitives::{aura::AuraId, VrfId};
@@ -79,7 +78,6 @@ use fee::WeightToFee;
use impls::DealWithFees;
pub type NegativeImbalance = >::NegativeImbalance;
-// pub type NimbusId = AuraId;
/// 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
@@ -588,8 +586,8 @@ impl pallet_author_inherent::Config for Runtime {
// type AccountLookup = TestConverter;
type AccountLookup = ();
type EventHandler = ();
+ type WeightInfo = (); // TODO: Add benchmarked weights
type CanAuthor = CollatorSelection;
- // type NimbusId = AccountId;
}
parameter_types! {