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

@@ -23,45 +23,45 @@ name = "serai-node"
clap = { version = "4", features = ["derive"] }
futures = "0.3"
jsonrpsee = { version = "0.16", features = ["server"] }
jsonrpsee = { version = "0.20", features = ["server"] }
sp-core = { git = "https://github.com/serai-dex/substrate" }
sp-timestamp = { git = "https://github.com/serai-dex/substrate" }
sp-io = { git = "https://github.com/serai-dex/substrate" }
sp-blockchain = { git = "https://github.com/serai-dex/substrate" }
sp-api = { git = "https://github.com/serai-dex/substrate" }
sp-block-builder = { git = "https://github.com/serai-dex/substrate" }
sp-consensus-babe = { git = "https://github.com/serai-dex/substrate" }
sp-core = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-timestamp = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-io = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-blockchain = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-api = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-block-builder = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sp-consensus-babe = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
frame-benchmarking = { git = "https://github.com/serai-dex/substrate" }
frame-benchmarking = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
serai-runtime = { path = "../runtime", features = ["std"] }
sc-offchain = { git = "https://github.com/serai-dex/substrate" }
sc-transaction-pool = { git = "https://github.com/serai-dex/substrate" }
sc-transaction-pool-api = { git = "https://github.com/serai-dex/substrate" }
sc-basic-authorship = { git = "https://github.com/serai-dex/substrate" }
sc-executor = { git = "https://github.com/serai-dex/substrate" }
sc-service = { git = "https://github.com/serai-dex/substrate" }
sc-client-api = { git = "https://github.com/serai-dex/substrate" }
sc-network-common = { git = "https://github.com/serai-dex/substrate" }
sc-network = { git = "https://github.com/serai-dex/substrate" }
sc-offchain = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-transaction-pool = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-transaction-pool-api = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-basic-authorship = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-executor = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-service = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-client-api = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-network-sync = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-network = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-consensus = { git = "https://github.com/serai-dex/substrate" }
sc-consensus-babe = { git = "https://github.com/serai-dex/substrate" }
sc-consensus-grandpa = { git = "https://github.com/serai-dex/substrate" }
sc-authority-discovery = { git = "https://github.com/serai-dex/substrate" }
sc-consensus = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-consensus-babe = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-consensus-grandpa = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-authority-discovery = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-telemetry = { git = "https://github.com/serai-dex/substrate" }
sc-cli = { git = "https://github.com/serai-dex/substrate" }
sc-telemetry = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-cli = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
sc-rpc-api = { git = "https://github.com/serai-dex/substrate" }
sc-rpc-api = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
substrate-frame-rpc-system = { git = "https://github.com/serai-dex/substrate" }
pallet-transaction-payment-rpc = { git = "https://github.com/serai-dex/substrate" }
substrate-frame-rpc-system = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
pallet-transaction-payment-rpc = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate" }
substrate-build-script-utils = { git = "https://github.com/serai-dex/polkadot-sdk", branch = "experimental" }
[features]
default = []

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 },