Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit 7aba7ff

Browse files
committed
Merged commit '877e193b314d42c9d77bb1740e70656b26bd0ff9' from Substrate
2 parents f6291e1 + 877e193 commit 7aba7ff

File tree

256 files changed

+11080
-5427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+11080
-5427
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ members = [
3535
"client/executor/wasmtime",
3636
"client/executor/runtime-test",
3737
"client/finality-grandpa",
38+
"client/informant",
3839
"client/tracing",
3940
"client/keystore",
4041
"client/network",

bin/node-template/node/src/chain_spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use sp_core::{Pair, Public, sr25519};
22
use node_template_runtime::{
33
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
4-
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, Signature
4+
IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature
55
};
66
use sp_consensus_aura::sr25519::{AuthorityId as AuraId};
77
use grandpa_primitives::{AuthorityId as GrandpaId};
@@ -128,7 +128,7 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
128128
changes_trie_config: Default::default(),
129129
}),
130130
indices: Some(IndicesConfig {
131-
ids: endowed_accounts.clone(),
131+
indices: vec![],
132132
}),
133133
balances: Some(BalancesConfig {
134134
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),

bin/node-template/node/src/service.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
159159
grandpa_link,
160160
service.network(),
161161
service.on_exit(),
162-
service.spawn_task_handle(),
163162
)?);
164163
},
165164
(true, false) => {
@@ -172,7 +171,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
172171
on_exit: service.on_exit(),
173172
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
174173
voting_rule: grandpa::VotingRulesBuilder::default().build(),
175-
executor: service.spawn_task_handle(),
176174
};
177175

178176
// the GRANDPA voter task is considered infallible, i.e.

bin/node-template/pallets/template/src/mock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ impl system::Trait for Test {
3939
type AvailableBlockRatio = AvailableBlockRatio;
4040
type Version = ();
4141
type ModuleToIndex = ();
42+
type AccountData = ();
43+
type OnNewAccount = ();
44+
type OnReapAccount = ();
4245
type Doughnut = ();
4346
type DelegatedDispatchVerifier = ();
4447
}

bin/node-template/runtime/src/lib.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use sp_std::prelude::*;
1212
use sp_core::OpaqueMetadata;
1313
use sp_runtime::{
1414
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
15-
impl_opaque_keys, MultiSignature
15+
impl_opaque_keys, MultiSignature,
1616
};
1717
use sp_runtime::traits::{
1818
BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
@@ -168,6 +168,12 @@ impl system::Trait for Runtime {
168168
///
169169
/// This type is being generated by `construct_runtime!`.
170170
type ModuleToIndex = ModuleToIndex;
171+
/// What to do if a new account is created.
172+
type OnNewAccount = ();
173+
/// What to do if an account is fully reaped from the system.
174+
type OnReapAccount = Balances;
175+
/// The data to be stored in an account.
176+
type AccountData = balances::AccountData<Balance>;
171177
}
172178

173179
impl DoughnutRuntime for Runtime {
@@ -185,16 +191,21 @@ impl grandpa::Trait for Runtime {
185191
type Event = Event;
186192
}
187193

194+
parameter_types! {
195+
/// How much an index costs.
196+
pub const IndexDeposit: u128 = 100;
197+
}
198+
188199
impl indices::Trait for Runtime {
189200
/// The type for recording indexing into the account enumeration. If this ever overflows, there
190201
/// will be problems!
191202
type AccountIndex = AccountIndex;
192-
/// Use the standard means of resolving an index hint from an id.
193-
type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
194-
/// Determine whether an account is dead.
195-
type IsDeadAccount = Balances;
196203
/// The ubiquitous event type.
197204
type Event = Event;
205+
/// The currency type.
206+
type Currency = Balances;
207+
/// How much an index costs.
208+
type Deposit = IndexDeposit;
198209
}
199210

200211
parameter_types! {
@@ -210,22 +221,16 @@ impl timestamp::Trait for Runtime {
210221

211222
parameter_types! {
212223
pub const ExistentialDeposit: u128 = 500;
213-
pub const CreationFee: u128 = 0;
214224
}
215225

216226
impl balances::Trait for Runtime {
217227
/// The type for recording an account's balance.
218228
type Balance = Balance;
219-
/// What to do if an account is fully reaped from the system.
220-
type OnReapAccount = System;
221-
/// What to do if a new account is created.
222-
type OnNewAccount = Indices;
223229
/// The ubiquitous event type.
224230
type Event = Event;
225231
type DustRemoval = ();
226-
type TransferPayment = ();
227232
type ExistentialDeposit = ExistentialDeposit;
228-
type CreationFee = CreationFee;
233+
type AccountStore = System;
229234
}
230235

231236
parameter_types! {
@@ -258,12 +263,12 @@ construct_runtime!(
258263
NodeBlock = opaque::Block,
259264
UncheckedExtrinsic = UncheckedExtrinsic
260265
{
261-
System: system::{Module, Call, Storage, Config, Event},
266+
System: system::{Module, Call, Config, Storage, Event<T>},
262267
Timestamp: timestamp::{Module, Call, Storage, Inherent},
263268
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
264269
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
265-
Indices: indices,
266-
Balances: balances,
270+
Indices: indices::{Module, Call, Storage, Event<T>, Config<T>},
271+
Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},
267272
TransactionPayment: transaction_payment::{Module, Storage},
268273
Sudo: sudo,
269274
// Used for the module template in `./template.rs`

bin/node/cli/browser-demo/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
async function start() {
1616
log('Loading WASM');
1717
await init('./pkg/node_cli_bg.wasm');
18-
log('Successfully loaded WASM');
18+
log('Fetching chain spec');
19+
const chain_spec_response = await fetch("https://raw.githubusercontent.com/paritytech/substrate/master/bin/node/cli/res/flaming-fir.json");
20+
const chain_spec_text = await chain_spec_response.text();
1921

2022
// Build our client.
21-
log('Starting client');
22-
let client = await start_client(ws());
23+
let client = await start_client(chain_spec_text, 'info', ws());
2324
log('Client started');
2425

2526
client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',

bin/node/cli/src/browser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use crate::ChainSpec;
17+
use crate::chain_spec::ChainSpec;
1818
use log::info;
1919
use wasm_bindgen::prelude::*;
2020
use sc_service::Configuration;
2121
use browser_utils::{
2222
Transport, Client,
2323
browser_configuration, set_console_error_panic_hook, init_console_log,
2424
};
25+
use std::str::FromStr;
2526

2627
/// Starts the client.
2728
#[wasm_bindgen]
28-
pub async fn start_client(wasm_ext: Transport) -> Result<Client, JsValue> {
29-
start_inner(wasm_ext)
29+
pub async fn start_client(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, JsValue> {
30+
start_inner(chain_spec, log_level, wasm_ext)
3031
.await
3132
.map_err(|err| JsValue::from_str(&err.to_string()))
3233
}
3334

34-
async fn start_inner(wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
35+
async fn start_inner(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
3536
set_console_error_panic_hook();
36-
init_console_log(log::Level::Info)?;
37-
38-
let chain_spec = ChainSpec::FlamingFir.load()
37+
init_console_log(log::Level::from_str(&log_level)?)?;
38+
let chain_spec = ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
3939
.map_err(|e| format!("{:?}", e))?;
4040

4141
let config: Configuration<_, _> = browser_configuration(wasm_ext, chain_spec)

bin/node/cli/src/chain_spec.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
2121
use serde::{Serialize, Deserialize};
2222
use node_runtime::{
2323
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig,
24-
GrandpaConfig, ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig,
25-
SocietyConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, WASM_BINARY,
24+
GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig,
25+
IndicesConfig, SocietyConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, WASM_BINARY,
2626
};
2727
use node_runtime::Block;
2828
use node_runtime::constants::currency::*;
@@ -235,9 +235,7 @@ pub fn testnet_genesis(
235235
.collect(),
236236
}),
237237
pallet_indices: Some(IndicesConfig {
238-
ids: endowed_accounts.iter().cloned()
239-
.chain(initial_authorities.iter().map(|x| x.0.clone()))
240-
.collect::<Vec<_>>(),
238+
indices: vec![],
241239
}),
242240
pallet_session: Some(SessionConfig {
243241
keys: initial_authorities.iter().map(|x| {
@@ -257,13 +255,17 @@ pub fn testnet_genesis(
257255
}),
258256
pallet_democracy: Some(DemocracyConfig::default()),
259257
pallet_collective_Instance1: Some(CouncilConfig {
260-
members: endowed_accounts.iter().cloned()
261-
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
258+
members: endowed_accounts.iter()
259+
.take((num_endowed_accounts + 1) / 2)
260+
.cloned()
261+
.collect(),
262262
phantom: Default::default(),
263263
}),
264264
pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
265-
members: endowed_accounts.iter().cloned()
266-
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
265+
members: endowed_accounts.iter()
266+
.take((num_endowed_accounts + 1) / 2)
267+
.cloned()
268+
.collect(),
267269
phantom: Default::default(),
268270
}),
269271
pallet_contracts: Some(ContractsConfig {
@@ -291,7 +293,10 @@ pub fn testnet_genesis(
291293
pallet_membership_Instance1: Some(Default::default()),
292294
pallet_treasury: Some(Default::default()),
293295
pallet_society: Some(SocietyConfig {
294-
members: endowed_accounts[0..3].to_vec(),
296+
members: endowed_accounts.iter()
297+
.take((num_endowed_accounts + 1) / 2)
298+
.cloned()
299+
.collect(),
295300
pot: 0,
296301
max_members: 999,
297302
}),
@@ -355,6 +360,7 @@ pub(crate) mod tests {
355360
use super::*;
356361
use crate::service::{new_full, new_light};
357362
use sc_service_test;
363+
use sp_runtime::BuildStorage;
358364

359365
fn local_testnet_genesis_instant_single() -> GenesisConfig {
360366
testnet_genesis(
@@ -404,4 +410,19 @@ pub(crate) mod tests {
404410
|config| new_light(config),
405411
);
406412
}
413+
414+
#[test]
415+
fn test_create_development_chain_spec() {
416+
development_config().build_storage().unwrap();
417+
}
418+
419+
#[test]
420+
fn test_create_local_testnet_chain_spec() {
421+
local_testnet_config().build_storage().unwrap();
422+
}
423+
424+
#[test]
425+
fn test_staging_test_net_chain_spec() {
426+
staging_testnet_config().build_storage().unwrap();
427+
}
407428
}

bin/node/cli/src/cli.rs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,13 @@ pub enum Subcommand {
5252
/// Please note: this command currently only works on an empty database!
5353
#[derive(Debug, StructOpt, Clone)]
5454
pub struct FactoryCmd {
55-
/// How often to repeat. This option only has an effect in mode `MasterToNToM`.
56-
#[structopt(long="rounds", default_value = "1")]
57-
pub rounds: u64,
55+
/// Number of blocks to generate.
56+
#[structopt(long="blocks", default_value = "1")]
57+
pub blocks: u32,
5858

59-
/// MasterToN: Manufacture `num` transactions from the master account
60-
/// to `num` randomly created accounts, one each.
61-
///
62-
/// MasterTo1: Manufacture `num` transactions from the master account
63-
/// to exactly one other randomly created account.
64-
///
65-
/// MasterToNToM: Manufacture `num` transactions from the master account
66-
/// to `num` randomly created accounts.
67-
/// From each of these randomly created accounts manufacture
68-
/// a transaction to another randomly created account.
69-
/// Repeat this `rounds` times. If `rounds` = 1 the behavior
70-
/// is the same as `MasterToN`.{n}
71-
/// A -> B, A -> C, A -> D, ... x `num`{n}
72-
/// B -> E, C -> F, D -> G, ...{n}
73-
/// ... x `rounds`
74-
///
75-
/// These three modes control manufacturing.
76-
#[structopt(long="mode", default_value = "MasterToN")]
77-
pub mode: node_transaction_factory::Mode,
78-
79-
/// Number of transactions to generate. In mode `MasterNToNToM` this is
80-
/// the number of transactions per round.
81-
#[structopt(long="num", default_value = "8")]
82-
pub num: u64,
59+
/// Number of transactions to push per block.
60+
#[structopt(long="transactions", default_value = "8")]
61+
pub transactions: u32,
8362

8463
#[allow(missing_docs)]
8564
#[structopt(flatten)]

bin/node/cli/src/command.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ where
6767
}
6868

6969
let factory_state = FactoryState::new(
70-
cli_args.mode.clone(),
71-
cli_args.num,
72-
cli_args.rounds,
70+
cli_args.blocks,
71+
cli_args.transactions,
7372
);
7473

7574
let service_builder = new_full_start!(config).0;

0 commit comments

Comments
 (0)