Skip to content

Commit d12309b

Browse files
authored
Merge pull request #827 from opentensor/feat/polkadot-sdk-v1.16.0
Feat/polkadot sdk v1.16.0
2 parents 9385f06 + 85a506a commit d12309b

File tree

9 files changed

+2039
-1344
lines changed

9 files changed

+2039
-1344
lines changed

Cargo.lock

Lines changed: 1858 additions & 1181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 71 additions & 71 deletions
Large diffs are not rendered by default.

node/src/chain_spec/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub mod finney;
55
pub mod localnet;
66
pub mod testnet;
77

8-
use node_subtensor_runtime::{AccountId, Block, RuntimeGenesisConfig, Signature, WASM_BINARY};
8+
use node_subtensor_runtime::{AccountId, Block, Signature, WASM_BINARY};
99
use sc_chain_spec_derive::ChainSpecExtension;
1010
use sc_service::ChainType;
1111
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -32,7 +32,7 @@ pub struct Extensions {
3232
}
3333

3434
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
35-
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig, Extensions>;
35+
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
3636

3737
/// Generate a crypto pair from seed.
3838
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {

node/src/command.rs

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ pub use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFER
1212
pub use node_subtensor_runtime::EXISTENTIAL_DEPOSIT;
1313
#[cfg(feature = "runtime-benchmarks")]
1414
pub use sp_keyring::Sr25519Keyring;
15-
#[cfg(feature = "runtime-benchmarks")]
16-
use sp_runtime::traits::HashingFor;
1715

1816
use node_subtensor_runtime::Block;
1917
use sc_cli::SubstrateCli;
20-
use sc_service::{Configuration, PartialComponents};
18+
use sc_service::{
19+
config::{ExecutorConfiguration, RpcConfiguration},
20+
Configuration, PartialComponents,
21+
};
2122

2223
impl SubstrateCli for Cli {
2324
fn impl_name() -> String {
@@ -149,7 +150,9 @@ pub fn run() -> sc_cli::Result<()> {
149150
);
150151
}
151152

152-
cmd.run::<HashingFor<Block>, service::ExecutorDispatch>(config)
153+
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ()>(Some(
154+
config.chain_spec,
155+
))
153156
}
154157
BenchmarkCmd::Block(cmd) => {
155158
let PartialComponents { client, .. } = service::new_partial(&config)?;
@@ -210,7 +213,18 @@ pub fn run() -> sc_cli::Result<()> {
210213
let runner = cli.create_runner(&cli.run)?;
211214
runner.run_node_until_exit(|config| async move {
212215
let config = override_default_heap_pages(config, 60_000);
213-
service::new_full(config).map_err(sc_cli::Error::Service)
216+
match config.network.network_backend {
217+
sc_network::config::NetworkBackendType::Libp2p => service::new_full::<
218+
sc_network::NetworkWorker<
219+
node_subtensor_runtime::opaque::Block,
220+
<node_subtensor_runtime::opaque::Block as sp_runtime::traits::Block>::Hash,
221+
>,
222+
>(config)
223+
.map_err(sc_cli::Error::Service),
224+
sc_network::config::NetworkBackendType::Litep2p =>
225+
service::new_full::<sc_network::Litep2pNetworkBackend>(config)
226+
.map_err(sc_cli::Error::Service),
227+
}
214228
})
215229
}
216230
}
@@ -219,7 +233,6 @@ pub fn run() -> sc_cli::Result<()> {
219233
/// Override default heap pages
220234
fn override_default_heap_pages(config: Configuration, pages: u64) -> Configuration {
221235
Configuration {
222-
default_heap_pages: Some(pages),
223236
impl_name: config.impl_name,
224237
impl_version: config.impl_version,
225238
role: config.role,
@@ -232,20 +245,7 @@ fn override_default_heap_pages(config: Configuration, pages: u64) -> Configurati
232245
state_pruning: config.state_pruning,
233246
blocks_pruning: config.blocks_pruning,
234247
chain_spec: config.chain_spec,
235-
wasm_method: config.wasm_method,
236248
wasm_runtime_overrides: config.wasm_runtime_overrides,
237-
rpc_addr: config.rpc_addr,
238-
rpc_max_connections: config.rpc_max_connections,
239-
rpc_cors: config.rpc_cors,
240-
rpc_methods: config.rpc_methods,
241-
rpc_max_request_size: config.rpc_max_request_size,
242-
rpc_max_response_size: config.rpc_max_response_size,
243-
rpc_id_provider: config.rpc_id_provider,
244-
rpc_max_subs_per_conn: config.rpc_max_subs_per_conn,
245-
rpc_port: config.rpc_port,
246-
rpc_message_buffer_capacity: config.rpc_message_buffer_capacity,
247-
rpc_batch_config: config.rpc_batch_config,
248-
rpc_rate_limit: config.rpc_rate_limit,
249249
prometheus_config: config.prometheus_config,
250250
telemetry_endpoints: config.telemetry_endpoints,
251251
offchain_worker: config.offchain_worker,
@@ -254,11 +254,30 @@ fn override_default_heap_pages(config: Configuration, pages: u64) -> Configurati
254254
dev_key_seed: config.dev_key_seed,
255255
tracing_targets: config.tracing_targets,
256256
tracing_receiver: config.tracing_receiver,
257-
max_runtime_instances: config.max_runtime_instances,
258257
announce_block: config.announce_block,
259258
data_path: config.data_path,
260259
base_path: config.base_path,
261-
informant_output_format: config.informant_output_format,
262-
runtime_cache_size: config.runtime_cache_size,
260+
executor: ExecutorConfiguration {
261+
default_heap_pages: Some(pages),
262+
wasm_method: config.executor.wasm_method,
263+
max_runtime_instances: config.executor.max_runtime_instances,
264+
runtime_cache_size: config.executor.runtime_cache_size,
265+
},
266+
rpc: RpcConfiguration {
267+
addr: config.rpc.addr,
268+
max_connections: config.rpc.max_connections,
269+
cors: config.rpc.cors,
270+
methods: config.rpc.methods,
271+
max_request_size: config.rpc.max_request_size,
272+
max_response_size: config.rpc.max_response_size,
273+
id_provider: config.rpc.id_provider,
274+
max_subs_per_conn: config.rpc.max_subs_per_conn,
275+
port: config.rpc.port,
276+
message_buffer_capacity: config.rpc.message_buffer_capacity,
277+
batch_config: config.rpc.batch_config,
278+
rate_limit: config.rpc.rate_limit,
279+
rate_limit_whitelisted_ips: config.rpc.rate_limit_whitelisted_ips,
280+
rate_limit_trust_proxy_headers: config.rpc.rate_limit_trust_proxy_headers,
281+
},
263282
}
264283
}

node/src/rpc.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use sp_api::ProvideRuntimeApi;
1515
use sp_block_builder::BlockBuilder;
1616
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
1717

18-
pub use sc_rpc_api::DenyUnsafe;
19-
2018
/// Dependencies for GRANDPA
2119
pub struct GrandpaDeps<B> {
2220
/// Voting round info.
@@ -37,8 +35,6 @@ pub struct FullDeps<C, P, B> {
3735
pub client: Arc<C>,
3836
/// Transaction pool instance.
3937
pub pool: Arc<P>,
40-
/// Whether to deny unsafe calls
41-
pub deny_unsafe: DenyUnsafe,
4238
/// Grandpa block import setup.
4339
pub grandpa: GrandpaDeps<B>,
4440
/// Backend used by the node.
@@ -72,15 +68,14 @@ where
7268
let FullDeps {
7369
client,
7470
pool,
75-
deny_unsafe,
7671
grandpa,
7772
_backend: _,
7873
} = deps;
7974

8075
// Custom RPC methods for Paratensor
8176
module.merge(SubtensorCustom::new(client.clone()).into_rpc())?;
8277

83-
module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
78+
module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
8479
module.merge(TransactionPayment::new(client).into_rpc())?;
8580

8681
let GrandpaDeps {

node/src/service.rs

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use sc_client_api::{Backend, BlockBackend};
66
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
77
use sc_consensus_grandpa::SharedVoterState;
88
use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging;
9-
use sc_executor::sp_wasm_interface::{Function, HostFunctionRegistry, HostFunctions};
10-
pub use sc_executor::NativeElseWasmExecutor;
11-
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
9+
pub use sc_executor::WasmExecutor;
10+
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncConfig};
1211
use sc_telemetry::{Telemetry, TelemetryWorker};
1312
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
1413
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
@@ -18,42 +17,8 @@ use std::{sync::Arc, time::Duration};
1817
/// imported and generated.
1918
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
2019

21-
// Our native executor instance.
22-
pub struct ExecutorDispatch;
23-
24-
// appeasing the compiler, this is a no-op
25-
impl HostFunctions for ExecutorDispatch {
26-
fn host_functions() -> Vec<&'static dyn Function> {
27-
vec![]
28-
}
29-
30-
fn register_static<T>(_registry: &mut T) -> core::result::Result<(), T::Error>
31-
where
32-
T: HostFunctionRegistry,
33-
{
34-
Ok(())
35-
}
36-
}
37-
38-
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
39-
// Always enable runtime benchmark host functions, the genesis state
40-
// was built with them so we're stuck with them forever.
41-
//
42-
// They're just a noop, never actually get used if the runtime was not compiled with
43-
// `runtime-benchmarks`.
44-
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
45-
46-
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
47-
node_subtensor_runtime::api::dispatch(method, data)
48-
}
49-
50-
fn native_version() -> sc_executor::NativeVersion {
51-
node_subtensor_runtime::native_version()
52-
}
53-
}
54-
5520
pub(crate) type FullClient =
56-
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;
21+
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<sp_io::SubstrateHostFunctions>>;
5722
type FullBackend = sc_service::TFullBackend<Block>;
5823
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
5924

@@ -90,7 +55,7 @@ pub fn new_partial(
9055
})
9156
.transpose()?;
9257

93-
let executor = sc_service::new_native_or_wasm_executor(config);
58+
let executor = sc_service::new_wasm_executor::<sp_io::SubstrateHostFunctions>(&config.executor);
9459

9560
let (client, backend, keystore_container, task_manager) =
9661
sc_service::new_full_parts::<Block, RuntimeApi, _>(
@@ -163,7 +128,11 @@ pub fn new_partial(
163128
}
164129

165130
// Builds a new service for a full client.
166-
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
131+
pub fn new_full<
132+
N: sc_network::NetworkBackend<Block, <Block as sp_runtime::traits::Block>::Hash>,
133+
>(
134+
config: Configuration,
135+
) -> Result<TaskManager, ServiceError> {
167136
let sc_service::PartialComponents {
168137
client,
169138
backend,
@@ -175,7 +144,12 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
175144
other: (block_import, grandpa_link, mut telemetry),
176145
} = new_partial(&config)?;
177146

178-
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
147+
let mut net_config = sc_network::config::FullNetworkConfiguration::<
148+
Block,
149+
<Block as sp_runtime::traits::Block>::Hash,
150+
N,
151+
>::new(&config.network, config.prometheus_registry().cloned());
152+
let metrics = N::register_notification_metrics(config.prometheus_registry());
179153

180154
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
181155
&client
@@ -186,8 +160,13 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
186160
&config.chain_spec,
187161
);
188162

163+
let peer_store_handle = net_config.peer_store_handle();
189164
let (grandpa_protocol_config, grandpa_notification_service) =
190-
sc_consensus_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone());
165+
sc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
166+
grandpa_protocol_name.clone(),
167+
metrics.clone(),
168+
peer_store_handle,
169+
);
191170
net_config.add_notification_protocol(grandpa_protocol_config);
192171

193172
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
@@ -205,8 +184,9 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
205184
spawn_handle: task_manager.spawn_handle(),
206185
import_queue,
207186
block_announce_validator_builder: None,
208-
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)),
187+
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
209188
block_relay: None,
189+
metrics,
210190
})?;
211191

212192
if config.offchain_worker.enabled {
@@ -221,7 +201,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
221201
transaction_pool: Some(OffchainTransactionPoolFactory::new(
222202
transaction_pool.clone(),
223203
)),
224-
network_provider: network.clone(),
204+
network_provider: Arc::new(network.clone()),
225205
enable_http_requests: true,
226206
custom_extensions: |_| vec![],
227207
})
@@ -239,7 +219,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
239219
let shared_authority_set = grandpa_link.shared_authority_set().clone();
240220
let shared_voter_state = SharedVoterState::empty();
241221

242-
let role = config.role.clone();
222+
let role = config.role;
243223
let force_authoring = config.force_authoring;
244224
let backoff_authoring_blocks = Some(BackoffAuthoringOnFinalizedHeadLagging {
245225
unfinalized_slack: 6,
@@ -254,11 +234,10 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
254234
let pool = transaction_pool.clone();
255235

256236
Box::new(
257-
move |deny_unsafe, subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
237+
move |subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
258238
let deps = crate::rpc::FullDeps {
259239
client: client.clone(),
260240
pool: pool.clone(),
261-
deny_unsafe,
262241
grandpa: crate::rpc::GrandpaDeps {
263242
shared_voter_state: shared_voter_state.clone(),
264243
shared_authority_set: shared_authority_set.clone(),

pallets/commitments/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(non_camel_case_types)]
22

3-
use super::*;
43
use crate as pallet_commitments;
54
use frame_support::derive_impl;
65
use frame_support::traits::ConstU64;

0 commit comments

Comments
 (0)