,
/// Transaction pool instance.
pub pool: Arc,
- /// Whether to deny unsafe calls
- pub deny_unsafe: DenyUnsafe,
}
/// Instantiate all RPC extensions.
@@ -48,9 +45,9 @@ where
use substrate_frame_rpc_system::{System, SystemApiServer};
let mut module = RpcExtension::new(());
- let FullDeps { client, pool, deny_unsafe } = deps;
+ let FullDeps { client, pool } = deps;
- module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
+ module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
Ok(module)
}
diff --git a/node/src/service.rs b/node/src/service.rs
index 4953916..71cd2db 100644
--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -3,7 +3,6 @@
// std
use std::{sync::Arc, time::Duration};
-use cumulus_client_cli::CollatorOptions;
// Local Runtime Types
use node_template_runtime::{
opaque::{Block, Hash},
@@ -11,13 +10,15 @@ use node_template_runtime::{
};
// Cumulus Imports
+use cumulus_client_cli::CollatorOptions;
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
- BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
+ BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
+ StartRelayChainTasksParams,
};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
@@ -29,36 +30,15 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
-use sc_executor::{
- HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
-};
+use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
-use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;
-/// Native executor type.
-pub struct ParachainNativeExecutor;
-
-impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
- type ExtendHostFunctions = (
- cumulus_client_service::storage_proof_size::HostFunctions,
- frame_benchmarking::benchmarking::HostFunctions,
- );
-
- fn dispatch(method: &str, data: &[u8]) -> Option> {
- node_template_runtime::api::dispatch(method, data)
- }
-
- fn native_version() -> sc_executor::NativeVersion {
- node_template_runtime::native_version()
- }
-}
-
-type ParachainExecutor = NativeElseWasmExecutor;
+type ParachainExecutor = WasmExecutor;
type ParachainClient = TFullClient;
@@ -72,7 +52,7 @@ pub type Service = PartialComponents<
ParachainBackend,
(),
sc_consensus::DefaultImportQueue,
- sc_transaction_pool::FullPool,
+ sc_transaction_pool::TransactionPoolHandle,
(ParachainBlockImport, Option, Option),
>;
@@ -93,19 +73,18 @@ pub fn new_partial(config: &Configuration) -> Result
.transpose()?;
let heap_pages = config
+ .executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
- let wasm = WasmExecutor::builder()
- .with_execution_method(config.wasm_method)
+ let executor = ParachainExecutor::builder()
+ .with_execution_method(config.executor.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
- .with_max_runtime_instances(config.max_runtime_instances)
- .with_runtime_cache_size(config.runtime_cache_size)
+ .with_max_runtime_instances(config.executor.max_runtime_instances)
+ .with_runtime_cache_size(config.executor.runtime_cache_size)
.build();
- let executor = ParachainExecutor::new_with_wasm_executor(wasm);
-
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::(
config,
@@ -122,12 +101,15 @@ pub fn new_partial(config: &Configuration) -> Result
telemetry
});
- let transaction_pool = sc_transaction_pool::BasicPool::new_full(
- config.transaction_pool.clone(),
- config.role.is_authority().into(),
- config.prometheus_registry(),
- task_manager.spawn_essential_handle(),
- client.clone(),
+ let transaction_pool = Arc::from(
+ sc_transaction_pool::Builder::new(
+ task_manager.spawn_essential_handle(),
+ client.clone(),
+ config.role.is_authority().into(),
+ )
+ .with_options(config.transaction_pool.clone())
+ .with_prometheus(config.prometheus_registry())
+ .build(),
);
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
@@ -138,7 +120,7 @@ pub fn new_partial(config: &Configuration) -> Result
config,
telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager,
- )?;
+ );
Ok(PartialComponents {
backend,
@@ -152,11 +134,97 @@ pub fn new_partial(config: &Configuration) -> Result
})
}
+/// Build the import queue for the parachain runtime.
+fn build_import_queue(
+ client: Arc,
+ block_import: ParachainBlockImport,
+ config: &Configuration,
+ telemetry: Option,
+ task_manager: &TaskManager,
+) -> sc_consensus::DefaultImportQueue {
+ cumulus_client_consensus_aura::equivocation_import_queue::fully_verifying_import_queue::<
+ sp_consensus_aura::sr25519::AuthorityPair,
+ _,
+ _,
+ _,
+ _,
+ >(
+ client,
+ block_import,
+ move |_, _| async move {
+ let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
+ Ok(timestamp)
+ },
+ &task_manager.spawn_essential_handle(),
+ config.prometheus_registry(),
+ telemetry,
+ )
+}
+
+#[allow(clippy::too_many_arguments)]
+fn start_consensus(
+ client: Arc,
+ backend: Arc,
+ block_import: ParachainBlockImport,
+ prometheus_registry: Option<&Registry>,
+ telemetry: Option,
+ task_manager: &TaskManager,
+ relay_chain_interface: Arc,
+ transaction_pool: Arc>,
+ keystore: KeystorePtr,
+ relay_chain_slot_duration: Duration,
+ para_id: ParaId,
+ collator_key: CollatorPair,
+ overseer_handle: OverseerHandle,
+ announce_block: Arc>) + Send + Sync>,
+) -> Result<(), sc_service::Error> {
+ let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
+ task_manager.spawn_handle(),
+ client.clone(),
+ transaction_pool,
+ prometheus_registry,
+ telemetry.clone(),
+ );
+
+ let proposer = Proposer::new(proposer_factory);
+
+ let collator_service = CollatorService::new(
+ client.clone(),
+ Arc::new(task_manager.spawn_handle()),
+ announce_block,
+ client.clone(),
+ );
+
+ let params = AuraParams {
+ create_inherent_data_providers: move |_, ()| async move { Ok(()) },
+ block_import,
+ para_client: client.clone(),
+ para_backend: backend,
+ relay_client: relay_chain_interface,
+ code_hash_provider: move |block_hash| {
+ client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash())
+ },
+ keystore,
+ collator_key,
+ para_id,
+ overseer_handle,
+ relay_chain_slot_duration,
+ proposer,
+ collator_service,
+ authoring_duration: Duration::from_millis(2000),
+ reinitialize: false,
+ };
+ let fut = aura::run::(
+ params,
+ );
+ task_manager.spawn_essential_handle().spawn("aura", None, fut);
+
+ Ok(())
+}
+
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
-///
-/// 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(
+pub async fn start_parachain_node(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
@@ -167,7 +235,13 @@ async fn start_node_impl(
let params = new_partial(¶chain_config)?;
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
- let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network);
+
+ let prometheus_registry = parachain_config.prometheus_registry().cloned();
+ let net_config = sc_network::config::FullNetworkConfiguration::<
+ _,
+ _,
+ sc_network::NetworkWorker,
+ >::new(¶chain_config.network, prometheus_registry.clone());
let client = params.client.clone();
let backend = params.backend.clone();
@@ -185,10 +259,11 @@ async fn start_node_impl(
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
let validator = parachain_config.role.is_authority();
- let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();
+ // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
+ // when starting the network.
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
build_network(BuildNetworkParams {
parachain_config: ¶chain_config,
@@ -206,9 +281,7 @@ async fn start_node_impl(
if parachain_config.offchain_worker.enabled {
use futures::FutureExt;
- task_manager.spawn_handle().spawn(
- "offchain-workers-runner",
- "offchain-work",
+ let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(params.keystore_container.keystore()),
@@ -216,13 +289,15 @@ async fn start_node_impl(
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
- network_provider: network.clone(),
+ network_provider: Arc::new(network.clone()),
is_validator: parachain_config.role.is_authority(),
- enable_http_requests: true,
+ enable_http_requests: false,
custom_extensions: move |_| vec![],
- })
- .run(client.clone(), task_manager.spawn_handle())
- .boxed(),
+ })?;
+ task_manager.spawn_handle().spawn(
+ "offchain-workers-runner",
+ "offchain-work",
+ offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
);
}
@@ -230,12 +305,9 @@ async fn start_node_impl(
let client = client.clone();
let transaction_pool = transaction_pool.clone();
- Box::new(move |deny_unsafe, _| {
- let deps = crate::rpc::FullDeps {
- client: client.clone(),
- pool: transaction_pool.clone(),
- deny_unsafe,
- };
+ Box::new(move |_| {
+ let deps =
+ crate::rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone() };
crate::rpc::create_full(deps).map_err(Into::into)
})
@@ -249,7 +321,7 @@ async fn start_node_impl(
config: parachain_config,
keystore: params.keystore_container.keystore(),
backend: backend.clone(),
- network: network.clone(),
+ network,
sync_service: sync_service.clone(),
system_rpc_tx,
tx_handler_controller,
@@ -261,7 +333,7 @@ async fn start_node_impl(
// Here you can check whether the hardware meets your chains' requirements. Putting a link
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
- match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
+ match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, false) {
Err(err) if validator => {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'.",
@@ -312,14 +384,13 @@ async fn start_node_impl(
if validator {
start_consensus(
client.clone(),
- backend.clone(),
+ backend,
block_import,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
&task_manager,
- relay_chain_interface.clone(),
+ relay_chain_interface,
transaction_pool,
- sync_service.clone(),
params.keystore_container.keystore(),
relay_chain_slot_duration,
para_id,
@@ -333,112 +404,3 @@ async fn start_node_impl(
Ok((task_manager, client))
}
-
-/// Build the import queue for the parachain runtime.
-fn build_import_queue(
- client: Arc,
- block_import: ParachainBlockImport,
- config: &Configuration,
- telemetry: Option,
- task_manager: &TaskManager,
-) -> Result, sc_service::Error> {
- let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
-
- Ok(cumulus_client_consensus_aura::equivocation_import_queue::fully_verifying_import_queue::<
- sp_consensus_aura::sr25519::AuthorityPair,
- _,
- _,
- _,
- _,
- >(
- client,
- block_import,
- move |_, _| async move {
- let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
- Ok(timestamp)
- },
- slot_duration,
- &task_manager.spawn_essential_handle(),
- config.prometheus_registry(),
- telemetry,
- ))
-}
-
-#[allow(clippy::too_many_arguments)]
-fn start_consensus(
- client: Arc,
- backend: Arc,
- block_import: ParachainBlockImport,
- prometheus_registry: Option<&Registry>,
- telemetry: Option,
- task_manager: &TaskManager,
- relay_chain_interface: Arc,
- transaction_pool: Arc>,
- sync_oracle: Arc>,
- keystore: KeystorePtr,
- relay_chain_slot_duration: Duration,
- para_id: ParaId,
- collator_key: CollatorPair,
- overseer_handle: OverseerHandle,
- announce_block: Arc>) + Send + Sync>,
-) -> Result<(), sc_service::Error> {
- // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
- // when starting the network.
- let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
- task_manager.spawn_handle(),
- client.clone(),
- transaction_pool,
- prometheus_registry,
- telemetry.clone(),
- );
-
- let proposer = Proposer::new(proposer_factory);
-
- let collator_service = CollatorService::new(
- client.clone(),
- Arc::new(task_manager.spawn_handle()),
- announce_block,
- client.clone(),
- );
-
- let params = AuraParams {
- create_inherent_data_providers: move |_, ()| async move { Ok(()) },
- block_import,
- para_client: client.clone(),
- para_backend: backend.clone(),
- relay_client: relay_chain_interface,
- code_hash_provider: move |block_hash| {
- client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash())
- },
- sync_oracle,
- keystore,
- collator_key,
- para_id,
- overseer_handle,
- relay_chain_slot_duration,
- proposer,
- collator_service,
- // Very limited proposal time.
- authoring_duration: Duration::from_millis(1500),
- reinitialize: false,
- };
-
- let fut =
- aura::run::(
- params,
- );
- task_manager.spawn_essential_handle().spawn("aura", None, fut);
-
- Ok(())
-}
-
-/// Start a parachain node.
-pub async fn start_parachain_node(
- parachain_config: Configuration,
- polkadot_config: Configuration,
- collator_options: CollatorOptions,
- para_id: ParaId,
- hwbench: Option,
-) -> sc_service::error::Result<(TaskManager, Arc)> {
- start_node_impl(parachain_config, polkadot_config, collator_options, para_id, hwbench).await
-}
diff --git a/pallets/fiat-ramps/Cargo.toml b/pallets/fiat-ramps/Cargo.toml
index 84e1c32..8ee66ed 100644
--- a/pallets/fiat-ramps/Cargo.toml
+++ b/pallets/fiat-ramps/Cargo.toml
@@ -7,7 +7,7 @@ description = "An offchain-worker pallet to communicate with EBICS services"
license = "GPL-3.0-or-later"
[dependencies]
-lite-json = { git = "https://github.com/xlc/lite-json.git", branch ="master", default-features = false }
+lite-json = { git = "https://github.com/xlc/lite-json.git", branch = "master", default-features = false }
log = { version = "0.4.17", default-features = false }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
@@ -15,40 +15,40 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
# Substrate packages
-frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "release-polkadot-v1.9.0" }
-sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0", features = ["serde"] }
-sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-sudo = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "stable2412" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412", features = ["serde"] }
+sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-sudo = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
risc0-zkvm = { version = "0.20.1", default-features = false }
serde-json-core = { version = "0.5.1", default-features = false }
[dev-dependencies]
-pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
hex-literal = "0.4.1"
[features]
-default = ['std']
+default = [ 'std' ]
std = [
+ 'codec/std',
'frame-support/std',
'frame-system/std',
- 'codec/std',
- 'scale-info/std',
- 'sp-runtime/std',
- 'sp-std/std',
- 'sp-io/std',
- 'log/std',
'lite-json/std',
- 'sp-core/std',
- 'sp-keystore',
+ 'log/std',
'pallet-balances/std',
- 'pallet-timestamp/std',
'pallet-sudo/std',
- 'serde-json-core/std',
+ 'pallet-timestamp/std',
"risc0-zkvm/std",
+ 'scale-info/std',
+ 'serde-json-core/std',
+ 'sp-core/std',
+ 'sp-io/std',
+ 'sp-keystore',
+ 'sp-runtime/std',
+ 'sp-std/std',
]
risc0-dev-mode = []
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 9e2a6fd..a74f572 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -14,157 +14,160 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
-hex-literal = "0.4.1"
+hex-literal = { version = "0.4.1", default-features = false }
log = { version = "0.4.17", default-features = false }
-scale-info = { default-features = false, features = ["derive"] }
-smallvec = "1.11.0"
+scale-info = { version = "^2", default-features = false, features = ["derive"] }
+smallvec = { version = "1.11.0", default-features = false }
-pallet-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-balances = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-sudo = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-frame-try-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "release-polkadot-v1.9.0" }
-pallet-assets = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-authorship = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-collator-selection = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-message-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-frame-executive = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-block-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-consensus-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-inherents = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-offchain = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-version = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-sp-genesis-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+pallet-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-balances = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+frame-support = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-sudo = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+frame-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+frame-try-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "stable2412" }
+pallet-assets = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-authorship = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-collator-selection = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-message-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+frame-executive = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-block-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-consensus-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-inherents = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-offchain = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-std = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-keyring = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-transaction-pool = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-version = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+sp-genesis-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
-pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-polkadot-parachain-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-polkadot-runtime-common = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-staging-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-staging-xcm-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-staging-xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-parachains-common = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+polkadot-parachain-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+polkadot-runtime-common = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+staging-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+staging-xcm-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+staging-xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+parachains-common = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
-cumulus-pallet-aura-ext = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-dmp-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-parachain-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0", features = ["parameterized-consensus-hook"] }
-cumulus-pallet-session-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-xcmp-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-primitives-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-primitives-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-primitives-timestamp = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-cumulus-primitives-utility = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-staging-parachain-info = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+cumulus-pallet-aura-ext = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-pallet-dmp-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-pallet-parachain-system = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-pallet-session-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-pallet-xcmp-queue = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-primitives-aura = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-primitives-core = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-primitives-timestamp = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+cumulus-primitives-utility = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+staging-parachain-info = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+serde_json = { version = "1.0.132", default-features = false, features = ["alloc"] }
# Used for the node template's RPCs
-frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
# Used for runtime benchmarking
-frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "release-polkadot-v1.9.0" }
-frame-system-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "release-polkadot-v1.9.0" }
+frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "stable2412" }
+frame-system-benchmarking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", optional = true, branch = "stable2412" }
# Local Dependencies
fiat-ramps = { version = "1.0.0", default-features = false, path = "../pallets/fiat-ramps" }
[dev-dependencies]
# substrate
-pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
-pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }
+pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+sp-io = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
# cumulus
-cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-staging-parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-assets-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-pallet-asset-conversion = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-testnet-parachains-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", features = ["westend"] }
+cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+staging-parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+assets-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+pallet-asset-conversion = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+testnet-parachains-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", features = ["westend"] }
# polkadot
-polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-staging-xcm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0" }
-staging-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
-pallet-assets = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.9.0" }
+polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+staging-xcm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }
+staging-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
+pallet-assets = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "stable2412" }
env_logger = "^0.9.0"
[build-dependencies]
-substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", optional = true , branch = "release-polkadot-v1.9.0" }
+substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", optional = true , branch = "stable2412" }
[features]
-default = ["std", "risc0-dev-mode"]
+default = [ "risc0-dev-mode", "std" ]
std = [
- "frame-try-runtime?/std",
- "frame-system-benchmarking?/std",
- "frame-benchmarking?/std",
"codec/std",
- "scale-info/std",
+ "cumulus-pallet-aura-ext/std",
+ "cumulus-pallet-dmp-queue/std",
+ "cumulus-pallet-parachain-system/std",
+ "cumulus-pallet-xcm/std",
+ "cumulus-pallet-xcmp-queue/std",
+ "cumulus-primitives-aura/std",
+ "cumulus-primitives-core/std",
+ "cumulus-primitives-timestamp/std",
+ "cumulus-primitives-utility/std",
+ "fiat-ramps/std",
+ "frame-benchmarking?/std",
"frame-executive/std",
"frame-support/std",
+ "frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
- "frame-try-runtime/std",
+ "frame-try-runtime?/std",
+ "pallet-assets/std",
"pallet-aura/std",
+ "pallet-authorship/std",
"pallet-balances/std",
+ "pallet-collator-selection/std",
+ "pallet-message-queue/std",
+ "pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
+ "pallet-xcm/std",
+ "polkadot-parachain-primitives/std",
+ "polkadot-runtime-common/std",
+ "scale-info/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-inherents/std",
+ "sp-io/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
- "pallet-xcm/std",
- "polkadot-parachain-primitives/std",
- "polkadot-runtime-common/std",
- "staging-xcm/std",
+ "staging-parachain-info/std",
"staging-xcm-builder/std",
"staging-xcm-executor/std",
+ "staging-xcm/std",
"substrate-wasm-builder",
- "cumulus-pallet-aura-ext/std",
- "cumulus-pallet-dmp-queue/std",
- "cumulus-pallet-parachain-system/std",
- "cumulus-pallet-xcm/std",
- "cumulus-pallet-xcmp-queue/std",
- "cumulus-primitives-aura/std",
- "cumulus-primitives-core/std",
- "cumulus-primitives-timestamp/std",
- "cumulus-primitives-utility/std",
- "staging-parachain-info/std",
- "pallet-assets/std",
- "fiat-ramps/std",
- "pallet-collator-selection/std",
- "pallet-message-queue/std",
- "pallet-session/std",
- "pallet-authorship/std",
- "sp-io/std",
+ "serde_json/std",
+ "sp-keyring/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
@@ -177,17 +180,14 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
- "frame-try-runtime/try-runtime",
"frame-executive/try-runtime",
- "frame-system/try-runtime",
"frame-support/try-runtime",
+ "frame-system/try-runtime",
+ "frame-try-runtime?/try-runtime",
"pallet-aura/try-runtime",
"pallet-balances/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
]
-risc0-dev-mode = [
- "fiat-ramps/risc0-dev-mode",
-]
-experimental = ["pallet-aura/experimental"]
+risc0-dev-mode = [ "fiat-ramps/risc0-dev-mode" ]
diff --git a/runtime/src/genesis_config_presets.rs b/runtime/src/genesis_config_presets.rs
new file mode 100644
index 0000000..a0baa28
--- /dev/null
+++ b/runtime/src/genesis_config_presets.rs
@@ -0,0 +1,142 @@
+use crate::{
+ AccountId, BalancesConfig, CollatorSelectionConfig, ParachainInfoConfig, PolkadotXcmConfig,
+ RuntimeGenesisConfig, SessionConfig, SessionKeys, SudoConfig, EXISTENTIAL_DEPOSIT,
+};
+
+use alloc::{vec, vec::Vec};
+use codec::Decode;
+use cumulus_primitives_core::ParaId;
+use hex_literal::hex;
+use parachains_common::AuraId;
+use serde_json::Value;
+use sp_genesis_builder::PresetId;
+use sp_keyring::Sr25519Keyring;
+
+/// The default XCM version to set in genesis config.
+const SAFE_XCM_VERSION: u32 = staging_xcm::prelude::XCM_VERSION;
+/// Parachain id used for gensis config presets of parachain template.
+const PARACHAIN_ID: u32 = 2000;
+
+/// Generate the session keys from individual elements.
+///
+/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
+pub fn template_session_keys(keys: AuraId) -> SessionKeys {
+ SessionKeys { aura: keys }
+}
+
+fn testnet_genesis(
+ invulnerables: Vec<(AccountId, AuraId)>,
+ endowed_accounts: Vec,
+ root: AccountId,
+ id: ParaId,
+) -> Value {
+ let config = RuntimeGenesisConfig {
+ balances: BalancesConfig {
+ balances: endowed_accounts
+ .iter()
+ .cloned()
+ .map(|k| (k, 1u128 << 60))
+ .collect::>(),
+ },
+ parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() },
+ collator_selection: CollatorSelectionConfig {
+ invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect::>(),
+ candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
+ ..Default::default()
+ },
+ session: SessionConfig {
+ keys: invulnerables
+ .into_iter()
+ .map(|(acc, aura)| {
+ (
+ acc.clone(), // account id
+ acc, // validator id
+ template_session_keys(aura), // session keys
+ )
+ })
+ .collect::>(),
+ ..Default::default()
+ },
+ polkadot_xcm: PolkadotXcmConfig {
+ safe_xcm_version: Some(SAFE_XCM_VERSION),
+ ..Default::default()
+ },
+ sudo: SudoConfig { key: Some(root) },
+ ..Default::default()
+ };
+
+ serde_json::to_value(config).expect("Could not build genesis config.")
+}
+
+fn local_testnet_genesis() -> Value {
+ let ocw_account: [u8; 32] =
+ hex!("004771ae35f923e82e77fafd1f4b1878cd4b372a7406c7b88125119f5ffbdc29");
+
+ let demo_account: [u8; 32] =
+ hex!("f82bdd8e8bf7d0023007d0a4b9d8e1bfc1568833c4f8b8ba626c133b6553c434");
+
+ let ocw_account_id = AccountId::decode(&mut &ocw_account[..]).unwrap();
+ let demo_account_id = AccountId::decode(&mut &demo_account[..]).unwrap();
+
+ testnet_genesis(
+ // initial collators.
+ vec![
+ (Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
+ (Sr25519Keyring::Bob.to_account_id(), Sr25519Keyring::Bob.public().into()),
+ ],
+ Sr25519Keyring::well_known()
+ .map(|k| k.to_account_id())
+ .into_iter()
+ .chain(vec![ocw_account_id, demo_account_id])
+ .collect(),
+ Sr25519Keyring::Alice.to_account_id(),
+ PARACHAIN_ID.into(),
+ )
+}
+
+fn development_config_genesis() -> Value {
+ let ocw_account: [u8; 32] =
+ hex!("004771ae35f923e82e77fafd1f4b1878cd4b372a7406c7b88125119f5ffbdc29");
+
+ let demo_account: [u8; 32] =
+ hex!("f82bdd8e8bf7d0023007d0a4b9d8e1bfc1568833c4f8b8ba626c133b6553c434");
+
+ let ocw_account_id = AccountId::decode(&mut &ocw_account[..]).unwrap();
+ let demo_account_id = AccountId::decode(&mut &demo_account[..]).unwrap();
+ testnet_genesis(
+ // initial collators.
+ vec![
+ (Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
+ (Sr25519Keyring::Bob.to_account_id(), Sr25519Keyring::Bob.public().into()),
+ ],
+ Sr25519Keyring::well_known()
+ .map(|k| k.to_account_id())
+ .into_iter()
+ .chain(vec![ocw_account_id, demo_account_id])
+ .collect(),
+ Sr25519Keyring::Alice.to_account_id(),
+ PARACHAIN_ID.into(),
+ )
+}
+
+/// Provides the JSON representation of predefined genesis config for given `id`.
+pub fn get_preset(id: &PresetId) -> Option> {
+ let patch = match id.as_ref() {
+ sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => local_testnet_genesis(),
+ sp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
+ _ => return None,
+ };
+ Some(
+ serde_json::to_string(&patch)
+ .expect("serialization to json is expected to work. qed.")
+ .into_bytes(),
+ )
+}
+
+/// List of supported presets.
+pub fn preset_names() -> Vec {
+ vec![
+ PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
+ PresetId::from(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
+ ]
+}
diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
index 3b392e7..e89dcca 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -6,10 +6,14 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
+mod genesis_config_presets;
pub mod xcm_config;
+extern crate alloc;
+
use codec::{Decode, Encode, MaxEncodedLen};
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
+use pallet_aura::Authorities;
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use scale_info::TypeInfo;
use smallvec::smallvec;
@@ -19,7 +23,7 @@ use sp_core::{
OpaqueMetadata,
};
use sp_runtime::{
- create_runtime_str, generic, impl_opaque_keys,
+ generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, Hash as HashT, IdentifyAccount, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
@@ -34,7 +38,7 @@ use sp_version::RuntimeVersion;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId, XcmpMessageFormat};
use frame_support::{
construct_runtime, derive_impl,
- genesis_builder_helper::{build_config, create_default_config},
+ genesis_builder_helper::{build_state, get_preset},
pallet_prelude::*,
parameter_types,
traits::{
@@ -107,7 +111,7 @@ pub type SignedBlock = generic::SignedBlock;
pub type BlockId = generic::BlockId;
/// The SignedExtension to the basic transaction logic.
-pub type SignedExtra = (
+pub type TxExtension = (
frame_system::CheckNonZeroSender,
frame_system::CheckSpecVersion,
frame_system::CheckTxVersion,
@@ -120,7 +124,7 @@ pub type SignedExtra = (
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
- generic::UncheckedExtrinsic;
+ generic::UncheckedExtrinsic;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
@@ -188,14 +192,14 @@ impl_opaque_keys! {
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
- spec_name: create_runtime_str!("template-parachain"),
- impl_name: create_runtime_str!("template-parachain"),
+ spec_name: alloc::borrow::Cow::Borrowed("template-parachain"),
+ impl_name: alloc::borrow::Cow::Borrowed("template-parachain"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
- state_version: 1,
+ system_version: 1,
};
/// This determines the average expected block time that we are targeting.
@@ -320,9 +324,6 @@ impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
- #[cfg(feature = "experimental")]
- type MinimumPeriod = ConstU64<0>;
- #[cfg(not(feature = "experimental"))]
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
type WeightInfo = ();
}
@@ -352,6 +353,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
+ type DoneSlashHandler = ();
}
pub type StableCoinInstance = pallet_balances::Instance1;
@@ -376,6 +378,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
+ type DoneSlashHandler = ();
}
parameter_types! {
@@ -385,11 +388,12 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
- type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter;
+ type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate;
type OperationalFeeMultiplier = ConstU8<5>;
+ type WeightInfo = ();
}
impl pallet_sudo::Config for Runtime {
@@ -421,12 +425,14 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
+ type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector;
}
impl staging_parachain_info::Config for Runtime {}
parameter_types! {
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block;
+ pub IdleMaxServiceWeight: Weight = Perbill::from_percent(10) * RuntimeBlockWeights::get().max_block;
}
impl pallet_message_queue::Config for Runtime {
@@ -449,6 +455,7 @@ impl pallet_message_queue::Config for Runtime {
type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>;
type MaxStale = sp_core::ConstU32<8>;
type ServiceWeight = MessageQueueServiceWeight;
+ type IdleMaxServiceWeight = IdleMaxServiceWeight;
}
impl cumulus_pallet_aura_ext::Config for Runtime {}
@@ -464,6 +471,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery;
+ type MaxActiveOutboundChannels = sp_core::ConstU32<1>;
+ type MaxPageSize = sp_core::ConstU32<1_000>;
}
parameter_types! {
@@ -490,7 +499,6 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool;
- #[cfg(feature = "experimental")]
type SlotDuration = ConstU64;
}
@@ -522,7 +530,7 @@ impl pallet_collator_selection::Config for Runtime {
type ValidatorRegistration = Session;
type WeightInfo = ();
}
-pub type SignedPayload = generic::SignedPayload;
+pub type SignedPayload = generic::SignedPayload;
parameter_types! {
// interval in milliseconds between two offchain worker instances
@@ -560,30 +568,28 @@ impl frame_system::offchain::CreateSignedTransaction for R
where
RuntimeCall: From,
{
- fn create_transaction>(
+ fn create_signed_transaction<
+ C: frame_system::offchain::AppCrypto,
+ >(
call: RuntimeCall,
public: ::Signer,
account: AccountId,
- index: Nonce,
- ) -> Option<(
- RuntimeCall,
- ::SignaturePayload,
- )> {
+ nonce: Nonce,
+ ) -> Option {
let period = BlockHashCount::get() as u64;
let current_block = System::block_number().saturated_into::().saturating_sub(1);
let tip = 0;
- let extra: SignedExtra = (
+ let extra: TxExtension = (
frame_system::CheckNonZeroSender::::new(),
frame_system::CheckSpecVersion::::new(),
frame_system::CheckTxVersion::::new(),
frame_system::CheckGenesis::::new(),
frame_system::CheckEra::::from(generic::Era::mortal(period, current_block)),
- frame_system::CheckNonce::::from(index),
+ frame_system::CheckNonce::::from(nonce),
frame_system::CheckWeight::::new(),
pallet_transaction_payment::ChargeTransactionPayment::::from(tip),
);
- #[cfg_attr(not(feature = "std"), allow(unused_variables))]
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
log::warn!("SignedPayload error: {:?}", e);
@@ -591,31 +597,42 @@ where
.ok()?;
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
-
+ let (call, tx_ext, _) = raw_payload.deconstruct();
let address = MultiAddress::Id(account);
- let (call, extra, _) = raw_payload.deconstruct();
- Some((call, (address, signature, extra)))
+ let transaction = UncheckedExtrinsic::new_signed(call, address, signature, tx_ext);
+
+ Some(transaction)
}
}
-impl frame_system::offchain::SigningTypes for Runtime {
- type Public = ::Signer;
- type Signature = Signature;
+impl frame_system::offchain::CreateTransactionBase for Runtime
+where
+ RuntimeCall: From,
+{
+ type Extrinsic = UncheckedExtrinsic;
+ type RuntimeCall = RuntimeCall;
}
-impl frame_system::offchain::SendTransactionTypes for Runtime
+impl frame_system::offchain::CreateTransaction for Runtime
where
- RuntimeCall: From,
+ RuntimeCall: From,
{
- type OverarchingCall = RuntimeCall;
- type Extrinsic = UncheckedExtrinsic;
+ type Extension = TxExtension;
+
+ fn create_transaction(call: RuntimeCall, tx_ext: Self::Extension) -> UncheckedExtrinsic {
+ UncheckedExtrinsic::new_transaction(call, tx_ext)
+ }
+}
+
+impl frame_system::offchain::SigningTypes for Runtime {
+ type Public = ::Signer;
+ type Signature = Signature;
}
#[frame_support::pallet]
pub mod mock_msg_queue {
use super::*;
use cumulus_primitives_core::{DmpMessageHandler, XcmpMessageHandler};
- use frame_support::pallet_prelude::*;
use polkadot_core_primitives::BlockNumber as RelayBlockNumber;
#[pallet::config]
@@ -831,7 +848,7 @@ impl_runtime_apis! {
}
fn authorities() -> Vec {
- Aura::authorities().into_inner()
+ Authorities::::get().into_inner()
}
}
impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime {
@@ -1046,12 +1063,16 @@ impl_runtime_apis! {
}
impl sp_genesis_builder::GenesisBuilder for Runtime {
- fn create_default_config() -> Vec {
- create_default_config::()
+ fn build_state(config: Vec) -> sp_genesis_builder::Result {
+ build_state::(config)
+ }
+
+ fn get_preset(id: &Option) -> Option> {
+ get_preset::(id, crate::genesis_config_presets::get_preset)
}
- fn build_config(config: Vec) -> sp_genesis_builder::Result {
- build_config::(config)
+ fn preset_names() -> Vec {
+ crate::genesis_config_presets::preset_names()
}
}
}
diff --git a/runtime/src/xcm_config.rs b/runtime/src/xcm_config.rs
index babf6cd..d0fc04e 100644
--- a/runtime/src/xcm_config.rs
+++ b/runtime/src/xcm_config.rs
@@ -16,7 +16,10 @@ use parachains_common::impls::AssetsFrom;
use polkadot_parachain_primitives::primitives::Sibling;
use sp_core::Get;
use sp_std::{marker::PhantomData, sync::Arc, vec};
-use staging_xcm::latest::{prelude::*, Junctions::X1, Location as MultiLocation};
+use staging_xcm::{
+ latest::{prelude::*, Junctions::X1, Location as MultiLocation},
+ opaque::latest::WESTEND_GENESIS_HASH,
+};
use staging_xcm_builder::WithUniqueTopic;
#[allow(deprecated)]
use staging_xcm_builder::{
@@ -33,7 +36,7 @@ parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::parent();
pub const OurLocation: MultiLocation = MultiLocation::here();
pub AssetHubLocation: MultiLocation = MultiLocation::new(1, X1(Arc::new([Parachain(1000)])));
- pub const RelayNetwork: Option = Some(NetworkId::Westend);
+ pub const RelayNetwork: Option = Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH));
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
}
@@ -199,6 +202,10 @@ impl staging_xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
+ type HrmpNewChannelOpenRequestHandler = ();
+ type HrmpChannelAcceptedHandler = ();
+ type HrmpChannelClosingHandler = ();
+ type XcmRecorder = PolkadotXcm;
}
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
@@ -275,8 +282,8 @@ where
sp_std::boxed::Box::new(
MultiLocation {
parents: 0,
- interior: staging_xcm::lts::Junction::AccountId32 {
- network: Some(NetworkId::Westend),
+ interior: staging_xcm::latest::Junction::AccountId32 {
+ network: Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH)),
id: dest.into(),
}
.into(),
diff --git a/rust-toolchain b/rust-toolchain
new file mode 100644
index 0000000..94dc804
--- /dev/null
+++ b/rust-toolchain
@@ -0,0 +1,5 @@
+[toolchain]
+channel = "1.85"
+components = [ "rustfmt", "clippy" ]
+targets = [ "wasm32-unknown-unknown" ]
+profile = "minimal"
diff --git a/zombienet.toml b/zombienet.toml
index e74c87c..1a0f47e 100644
--- a/zombienet.toml
+++ b/zombienet.toml
@@ -51,7 +51,7 @@ add_to_genesis = true
[[parachains.collators]]
name = "hyperfridge-1"
validator = true
- command = "./target/release/node-template"
+ command = "~/.cargo/target/release/node-template"
args = ["-lxcm=trace"]
register_para = true
@@ -59,7 +59,7 @@ add_to_genesis = true
[[parachains.collators]]
name = "hyperfridge-2"
validator = true
- command = "./target/release/node-template"
+ command = "~/.cargo/target/release/node-template"
args = ["-lxcm=trace"]
register_para = true
@@ -73,4 +73,4 @@ add_to_genesis = true
#sender = 2000
#recipient = 1000
#max_capacity = 5
-#max_message_size = 4096
\ No newline at end of file
+#max_message_size = 4096