Move to polkadot-sdk

Still a WIP, and using an experimental branch with 2 not-yet-merged PRs merged.
This commit is contained in:
Luke Parker
2023-11-27 06:01:47 -05:00
parent 008da698bc
commit d038aa95fd
21 changed files with 673 additions and 812 deletions

View File

@@ -16,13 +16,12 @@ fn account_from_name(name: &'static str) -> PublicKey {
}
fn testnet_genesis(
wasm_binary: &[u8],
validators: &[&'static str],
endowed_accounts: Vec<PublicKey>,
) -> RuntimeGenesisConfig {
let validators = validators.iter().map(|name| account_from_name(name)).collect::<Vec<_>>();
RuntimeGenesisConfig {
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData },
system: SystemConfig { _config: PhantomData },
transaction_payment: Default::default(),
@@ -67,6 +66,7 @@ fn testnet_genesis(
pub fn development_config() -> Result<ChainSpec, &'static str> {
let wasm_binary = WASM_BINARY.ok_or("Development wasm not available")?;
#[allow(deprecated)]
Ok(ChainSpec::from_genesis(
// Name
"Development Network",
@@ -75,7 +75,6 @@ pub fn development_config() -> Result<ChainSpec, &'static str> {
ChainType::Development,
|| {
testnet_genesis(
wasm_binary,
&["Alice"],
vec![
account_from_name("Alice"),
@@ -99,12 +98,15 @@ pub fn development_config() -> Result<ChainSpec, &'static str> {
None,
// Extensions
None,
// Code
wasm_binary,
))
}
pub fn testnet_config() -> Result<ChainSpec, &'static str> {
let wasm_binary = WASM_BINARY.ok_or("Testnet wasm not available")?;
#[allow(deprecated)]
Ok(ChainSpec::from_genesis(
// Name
"Local Test Network",
@@ -113,7 +115,6 @@ pub fn testnet_config() -> Result<ChainSpec, &'static str> {
ChainType::Local,
|| {
testnet_genesis(
wasm_binary,
&["Alice", "Bob", "Charlie", "Dave"],
vec![
account_from_name("Alice"),
@@ -137,5 +138,7 @@ pub fn testnet_config() -> Result<ChainSpec, &'static str> {
None,
// Extensions
None,
// Code
wasm_binary,
))
}

View File

@@ -8,7 +8,7 @@ use sp_consensus_babe::{SlotDuration, inherents::InherentDataProvider as BabeInh
use sp_io::SubstrateHostFunctions;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, WasmExecutor};
use sc_network_common::sync::warp::WarpSyncParams;
use sc_network_sync::warp::WarpSyncParams;
use sc_network::{Event, NetworkEventStream};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, TFullClient};
@@ -40,7 +40,7 @@ type PartialComponents = sc_service::PartialComponents<
FullClient,
FullBackend,
SelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
BabeBlockImport,
@@ -104,6 +104,7 @@ pub fn new_partial(config: &Configuration) -> Result<PartialComponents, ServiceE
let (grandpa_block_import, grandpa_link) = grandpa::block_import(
client.clone(),
512,
&client,
select_chain.clone(),
telemetry.as_ref().map(Telemetry::handle),
@@ -186,6 +187,8 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
block_announce_validator_builder: None,
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)),
// TODO: Add a BlockRequestHandler here
block_relay: None,
})?;
if config.offchain_worker.enabled {
@@ -199,7 +202,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(transaction_pool.clone())),
network_provider: network.clone(),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle()),
@@ -311,7 +313,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
grandpa::run_grandpa_voter(grandpa::GrandpaParams {
config: grandpa::Config {
gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512,
justification_generation_period: 10,
name: Some(name),
observer_enabled: false,
keystore: if role.is_authority() { Some(keystore) } else { None },