Skip to content

Commit 3224834

Browse files
committed
Merge branch 'spiigot/add-pallet-drand' into commit-reveal-v3
2 parents 41cfff9 + 4926c1b commit 3224834

File tree

14 files changed

+903
-427
lines changed

14 files changed

+903
-427
lines changed

node/src/benchmarking.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Should only be used for benchmarking as it may break in other contexts.
44
5-
use crate::service::Client;
5+
use crate::client::FullClient;
66

77
use node_subtensor_runtime as runtime;
88
use node_subtensor_runtime::check_nonce;
@@ -21,12 +21,12 @@ use std::{sync::Arc, time::Duration};
2121
//
2222
// Note: Should only be used for benchmarking.
2323
pub struct RemarkBuilder {
24-
client: Arc<Client>,
24+
client: Arc<FullClient>,
2525
}
2626

2727
impl RemarkBuilder {
2828
// Creates a new [`Self`] from the given client.
29-
pub fn new(client: Arc<Client>) -> Self {
29+
pub fn new(client: Arc<FullClient>) -> Self {
3030
Self { client }
3131
}
3232
}
@@ -58,14 +58,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
5858
//
5959
// Note: Should only be used for benchmarking.
6060
pub struct TransferKeepAliveBuilder {
61-
client: Arc<Client>,
61+
client: Arc<FullClient>,
6262
dest: AccountId,
6363
value: Balance,
6464
}
6565

6666
impl TransferKeepAliveBuilder {
6767
// Creates a new [`Self`] from the given client.
68-
pub fn new(client: Arc<Client>, dest: AccountId, value: Balance) -> Self {
68+
pub fn new(client: Arc<FullClient>, dest: AccountId, value: Balance) -> Self {
6969
Self {
7070
client,
7171
dest,
@@ -105,7 +105,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
105105
//
106106
// Note: Should only be used for benchmarking.
107107
pub fn create_benchmark_extrinsic(
108-
client: &Client,
108+
client: &FullClient,
109109
sender: sp_core::sr25519::Pair,
110110
call: runtime::RuntimeCall,
111111
nonce: u32,

node/src/chain_spec/localnet.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use super::*;
55

6-
pub fn localnet_config() -> Result<ChainSpec, String> {
6+
pub fn localnet_config(single_authority: bool) -> Result<ChainSpec, String> {
77
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
88

99
// Give front-ends necessary data to present to users
@@ -32,11 +32,15 @@ pub fn localnet_config() -> Result<ChainSpec, String> {
3232
.with_genesis_config_patch(localnet_genesis(
3333
// Initial PoA authorities (Validators)
3434
// aura | grandpa
35-
vec![
36-
// Keys for debug
37-
authority_keys_from_seed("Alice"),
38-
authority_keys_from_seed("Bob"),
39-
],
35+
if single_authority {
36+
// single authority allows you to run the network using a single node
37+
vec![authority_keys_from_seed("Alice")]
38+
} else {
39+
vec![
40+
authority_keys_from_seed("Alice"),
41+
authority_keys_from_seed("Bob"),
42+
]
43+
},
4044
// Pre-funded accounts
4145
true,
4246
))

node/src/client.rs

+15-73
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,18 @@
1-
use scale_codec::Codec;
2-
// Substrate
3-
use sp_runtime::traits::{Block as BlockT, MaybeDisplay};
4-
5-
use crate::ethereum::EthCompatRuntimeApiCollection;
6-
use crate::service::RuntimeExecutor;
1+
use node_subtensor_runtime::{opaque::Block, RuntimeApi};
2+
use sc_executor::WasmExecutor;
73

84
/// Full backend.
9-
pub type FullBackend<B> = sc_service::TFullBackend<B>;
5+
pub type FullBackend = sc_service::TFullBackend<Block>;
106
/// Full client.
11-
pub type FullClient<B, RA> = sc_service::TFullClient<B, RA, RuntimeExecutor>;
12-
13-
/// A set of APIs that every runtime must implement.
14-
pub trait BaseRuntimeApiCollection<Block: BlockT>:
15-
sp_api::ApiExt<Block>
16-
+ sp_api::Metadata<Block>
17-
+ sp_block_builder::BlockBuilder<Block>
18-
+ sp_offchain::OffchainWorkerApi<Block>
19-
+ sp_session::SessionKeys<Block>
20-
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
21-
{
22-
}
23-
24-
impl<Block, Api> BaseRuntimeApiCollection<Block> for Api
25-
where
26-
Block: BlockT,
27-
Api: sp_api::ApiExt<Block>
28-
+ sp_api::Metadata<Block>
29-
+ sp_block_builder::BlockBuilder<Block>
30-
+ sp_offchain::OffchainWorkerApi<Block>
31-
+ sp_session::SessionKeys<Block>
32-
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
33-
{
34-
}
35-
36-
/// A set of APIs that Subtensor runtime must implement.
37-
pub trait RuntimeApiCollection<
38-
Block: BlockT,
39-
AuraId: Codec,
40-
AccountId: Codec,
41-
Nonce: Codec,
42-
Balance: Codec + MaybeDisplay,
43-
>:
44-
BaseRuntimeApiCollection<Block>
45-
+ EthCompatRuntimeApiCollection<Block>
46-
+ sp_consensus_aura::AuraApi<Block, AuraId>
47-
+ sp_consensus_grandpa::GrandpaApi<Block>
48-
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
49-
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
50-
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
51-
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
52-
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
53-
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>
54-
{
55-
}
56-
57-
impl<Block, AuraId, AccountId, Nonce, Balance, Api>
58-
RuntimeApiCollection<Block, AuraId, AccountId, Nonce, Balance> for Api
59-
where
60-
Block: BlockT,
61-
AuraId: Codec,
62-
AccountId: Codec,
63-
Nonce: Codec,
64-
Balance: Codec + MaybeDisplay,
65-
Api: BaseRuntimeApiCollection<Block>
66-
+ EthCompatRuntimeApiCollection<Block>
67-
+ sp_consensus_aura::AuraApi<Block, AuraId>
68-
+ sp_consensus_grandpa::GrandpaApi<Block>
69-
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
70-
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
71-
+ subtensor_custom_rpc_runtime_api::DelegateInfoRuntimeApi<Block>
72-
+ subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>
73-
+ subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>
74-
+ subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
75-
{
76-
}
7+
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, RuntimeExecutor>;
8+
/// Always enable runtime benchmark host functions, the genesis state
9+
/// was built with them so we're stuck with them forever.
10+
///
11+
/// They're just a noop, never actually get used if the runtime was not compiled with
12+
/// `runtime-benchmarks`.
13+
pub type HostFunctions = (
14+
sp_io::SubstrateHostFunctions,
15+
sp_crypto_ec_utils::bls12_381::host_calls::HostFunctions,
16+
frame_benchmarking::benchmarking::HostFunctions,
17+
);
18+
pub type RuntimeExecutor = WasmExecutor<HostFunctions>;

node/src/command.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ impl SubstrateCli for Cli {
4141

4242
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
4343
Ok(match id {
44-
"local" => Box::new(chain_spec::localnet::localnet_config()?),
44+
"dev" => Box::new(chain_spec::localnet::localnet_config(true)?),
45+
"local" => Box::new(chain_spec::localnet::localnet_config(false)?),
4546
"finney" => Box::new(chain_spec::finney::finney_mainnet_config()?),
4647
"devnet" => Box::new(chain_spec::devnet::devnet_config()?),
4748
"" | "test_finney" => Box::new(chain_spec::testnet::finney_testnet_config()?),

0 commit comments

Comments
 (0)