Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
19b67cd
Export GRANDPA AuthorityPair when full_crypto is enabled (#4872)
h4x3rotab Feb 10, 2020
8b6b093
Create Benchmarking Setup for Identity Pallet #4695 (#4818)
shawntabrizi Feb 10, 2020
f735d3e
Fix vesting logic (#4864)
gavofyork Feb 10, 2020
7e8ac2e
Update trie-db to the latest (#4874)
cecton Feb 10, 2020
ae03ee9
Fix timer panics in the wasm light client (#4561)
expenses Feb 10, 2020
0d4586b
Don't expose `Benchmarking` host functions by default (#4875)
bkchr Feb 10, 2020
571e3c4
Add trace on import block. (#4871)
seerscode Feb 10, 2020
1fa3f7f
Refactor and document allocator (#4855)
pepyakin Feb 10, 2020
d472cd6
Avoid challenging those that can't be suspended anyway (#4804)
gavofyork Feb 10, 2020
b388338
Add trait to get module and call names. (#4854)
seerscode Feb 10, 2020
26a4b73
Fix runtime-interface tests on windows (#4805)
bkchr Feb 10, 2020
613a3bc
update primitive types to 0.6.2 (#4866)
NikVolf Feb 10, 2020
671cb85
Run offchain workers at hash, not number. (#4878)
tomusdrw Feb 10, 2020
50bb62f
Use prefixed iterator from trie. (#4858)
cheme Feb 11, 2020
a5a61df
Add support for json output in subkey (#4882)
hbakkum-dotstar Feb 11, 2020
1dd662b
impl Randomness trait for Babe and remove unused RandomBeacon trait (…
rphmeier Feb 11, 2020
60f0569
Pause Kademlia if too many connections (#4828)
tomaka Feb 11, 2020
657484a
Refactor tx factory 1 (#4870)
seerscode Feb 11, 2020
7647c39
pallet-evm: optional nonce parameter (#4893)
sorpaas Feb 11, 2020
d0e354a
Increase the penality for being offline (#4889)
tomaka Feb 11, 2020
00a400f
Add a sub command to generate a node key file (#4884)
hbakkum-dotstar Feb 11, 2020
10332c9
Benchmark Timestamp Pallet (#4891)
seerscode Feb 12, 2020
f5f7852
Add command-line flag to enable yamux flow control. (#4892)
twittner Feb 12, 2020
2723b9c
Do not allow zero Existential Deposit when using Balances (#4894)
shawntabrizi Feb 12, 2020
ea721a1
network: Use "one shot" protocol handler. (#3520)
twittner Feb 12, 2020
2290645
Benchmark the Balances Pallet (#4879)
shawntabrizi Feb 12, 2020
e1668c2
client/network-gossip: Integrate GossipEngine tasks into Future impl …
mxinden Feb 12, 2020
b955d17
add some more docs on PreRuntime digests (#4896)
rphmeier Feb 12, 2020
1b42f24
serialize partial_fee into string (#4898)
xlc Feb 12, 2020
47076a9
add sr25519 bench (#4905)
NikVolf Feb 12, 2020
d78534e
Fix chain-spec and make sure it does not breaks again (#4906)
bkchr Feb 13, 2020
b01bd0d
Full block import benchmark (#4865)
NikVolf Feb 13, 2020
d940c02
Per-things trait. (#4904)
kianenigma Feb 13, 2020
0b2ae97
executor: Migrate wasmtime backend to a high-level API (#4686)
pepyakin Feb 13, 2020
b36497a
reference sc-service with rocksdb feature (#4918)
NikVolf Feb 13, 2020
067c884
pallet-evm: add support for transaction-level create2 (#4907)
sorpaas Feb 13, 2020
7d544ef
pallet-evm: refactor duplicate code in call/create/create2 (#4922)
sorpaas Feb 13, 2020
d02c720
Adds a test to ensure that we clear the heap between calls into runti…
bkchr Feb 14, 2020
29454c3
Composite accounts (#4820)
gavofyork Feb 14, 2020
a6e7c05
Allow to distinguish out of gas from other traps (#4883)
athei Feb 14, 2020
16bb192
Adds fork-awareness and finalization notifications to transaction poo…
seunlanlege Feb 14, 2020
b27d50c
Adds `with_pair!` macro to application-crypto (#4885)
bkchr Feb 14, 2020
877e193
Remove rename for finalized event and add some docs. (#4930)
tomusdrw Feb 15, 2020
7aba7ff
Merged commit '877e193b314d42c9d77bb1740e70656b26bd0ff9' from Substrate
hoani Feb 16, 2020
9469920
Reverted #4820 (substrate), add doughnut and delegatedDispatchVerifie…
hoani Feb 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
382 changes: 253 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"client/executor/wasmtime",
"client/executor/runtime-test",
"client/finality-grandpa",
"client/informant",
"client/tracing",
"client/keystore",
"client/network",
Expand Down
2 changes: 0 additions & 2 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
grandpa_link,
service.network(),
service.on_exit(),
service.spawn_task_handle(),
)?);
},
(true, false) => {
Expand All @@ -172,7 +171,6 @@ pub fn new_full(config: Configuration<GenesisConfig>)
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
executor: service.spawn_task_handle(),
};

// the GRANDPA voter task is considered infallible, i.e.
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sp_std::prelude::*;
use sp_core::OpaqueMetadata;
use sp_runtime::{
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, MultiSignature
impl_opaque_keys, MultiSignature,
};
use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
Expand Down
7 changes: 4 additions & 3 deletions bin/node/cli/browser-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
async function start() {
log('Loading WASM');
await init('./pkg/node_cli_bg.wasm');
log('Successfully loaded WASM');
log('Fetching chain spec');
const chain_spec_response = await fetch("https://raw.githubusercontent.com/paritytech/substrate/master/bin/node/cli/res/flaming-fir.json");
const chain_spec_text = await chain_spec_response.text();

// Build our client.
log('Starting client');
let client = await start_client(ws());
let client = await start_client(chain_spec_text, 'info', ws());
log('Client started');

client.rpcSubscribe('{"method":"chain_subscribeNewHead","params":[],"id":1,"jsonrpc":"2.0"}',
Expand Down
14 changes: 7 additions & 7 deletions bin/node/cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use crate::ChainSpec;
use crate::chain_spec::ChainSpec;
use log::info;
use wasm_bindgen::prelude::*;
use sc_service::Configuration;
use browser_utils::{
Transport, Client,
browser_configuration, set_console_error_panic_hook, init_console_log,
};
use std::str::FromStr;

/// Starts the client.
#[wasm_bindgen]
pub async fn start_client(wasm_ext: Transport) -> Result<Client, JsValue> {
start_inner(wasm_ext)
pub async fn start_client(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, JsValue> {
start_inner(chain_spec, log_level, wasm_ext)
.await
.map_err(|err| JsValue::from_str(&err.to_string()))
}

async fn start_inner(wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
async fn start_inner(chain_spec: String, log_level: String, wasm_ext: Transport) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
init_console_log(log::Level::Info)?;

let chain_spec = ChainSpec::FlamingFir.load()
init_console_log(log::Level::from_str(&log_level)?)?;
let chain_spec = ChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
.map_err(|e| format!("{:?}", e))?;

let config: Configuration<_, _> = browser_configuration(wasm_ext, chain_spec)
Expand Down
33 changes: 28 additions & 5 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,17 @@ pub fn testnet_genesis(
}),
pallet_democracy: Some(DemocracyConfig::default()),
pallet_collective_Instance1: Some(CouncilConfig {
members: endowed_accounts.iter().cloned()
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
phantom: Default::default(),
}),
pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
members: endowed_accounts.iter().cloned()
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
phantom: Default::default(),
}),
pallet_contracts: Some(ContractsConfig {
Expand Down Expand Up @@ -291,7 +295,10 @@ pub fn testnet_genesis(
pallet_membership_Instance1: Some(Default::default()),
pallet_treasury: Some(Default::default()),
pallet_society: Some(SocietyConfig {
members: endowed_accounts[0..3].to_vec(),
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
pot: 0,
max_members: 999,
}),
Expand Down Expand Up @@ -355,6 +362,7 @@ pub(crate) mod tests {
use super::*;
use crate::service::{new_full, new_light};
use sc_service_test;
use sp_runtime::BuildStorage;

fn local_testnet_genesis_instant_single() -> GenesisConfig {
testnet_genesis(
Expand Down Expand Up @@ -404,4 +412,19 @@ pub(crate) mod tests {
|config| new_light(config),
);
}

#[test]
fn test_create_development_chain_spec() {
development_config().build_storage().unwrap();
}

#[test]
fn test_create_local_testnet_chain_spec() {
local_testnet_config().build_storage().unwrap();
}

#[test]
fn test_staging_test_net_chain_spec() {
staging_testnet_config().build_storage().unwrap();
}
}
33 changes: 6 additions & 27 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,13 @@ pub enum Subcommand {
/// Please note: this command currently only works on an empty database!
#[derive(Debug, StructOpt, Clone)]
pub struct FactoryCmd {
/// How often to repeat. This option only has an effect in mode `MasterToNToM`.
#[structopt(long="rounds", default_value = "1")]
pub rounds: u64,
/// Number of blocks to generate.
#[structopt(long="blocks", default_value = "1")]
pub blocks: u32,

/// MasterToN: Manufacture `num` transactions from the master account
/// to `num` randomly created accounts, one each.
///
/// MasterTo1: Manufacture `num` transactions from the master account
/// to exactly one other randomly created account.
///
/// MasterToNToM: Manufacture `num` transactions from the master account
/// to `num` randomly created accounts.
/// From each of these randomly created accounts manufacture
/// a transaction to another randomly created account.
/// Repeat this `rounds` times. If `rounds` = 1 the behavior
/// is the same as `MasterToN`.{n}
/// A -> B, A -> C, A -> D, ... x `num`{n}
/// B -> E, C -> F, D -> G, ...{n}
/// ... x `rounds`
///
/// These three modes control manufacturing.
#[structopt(long="mode", default_value = "MasterToN")]
pub mode: node_transaction_factory::Mode,

/// Number of transactions to generate. In mode `MasterNToNToM` this is
/// the number of transactions per round.
#[structopt(long="num", default_value = "8")]
pub num: u64,
/// Number of transactions to push per block.
#[structopt(long="transactions", default_value = "8")]
pub transactions: u32,

#[allow(missing_docs)]
#[structopt(flatten)]
Expand Down
5 changes: 2 additions & 3 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ where
}

let factory_state = FactoryState::new(
cli_args.mode.clone(),
cli_args.num,
cli_args.rounds,
cli_args.blocks,
cli_args.transactions,
);

let service_builder = new_full_start!(config).0;
Expand Down
124 changes: 30 additions & 94 deletions bin/node/cli/src/factory_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,17 @@ use sp_runtime::{
generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount}
};
use node_transaction_factory::RuntimeAdapter;
use node_transaction_factory::modes::Mode;
use sp_inherents::InherentData;
use sp_timestamp;
use sp_finality_tracker;

type AccountPublic = <Signature as Verify>::Signer;

pub struct FactoryState<N> {
block_no: N,

mode: Mode,
start_number: u32,
rounds: u32,
round: u32,
block_in_round: u32,
num: u32,
blocks: u32,
transactions: u32,
block_number: N,
index: u32,
}

type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
Expand Down Expand Up @@ -79,63 +74,35 @@ impl RuntimeAdapter for FactoryState<Number> {
type Number = Number;

fn new(
mode: Mode,
num: u64,
rounds: u64,
blocks: u32,
transactions: u32,
) -> FactoryState<Self::Number> {
FactoryState {
mode,
num: num as u32,
round: 0,
rounds: rounds as u32,
block_in_round: 0,
block_no: 0,
start_number: 0,
blocks,
transactions,
block_number: 0,
index: 0,
}
}

fn block_no(&self) -> Self::Number {
self.block_no
}

fn block_in_round(&self) -> Self::Number {
self.block_in_round
}

fn rounds(&self) -> Self::Number {
self.rounds
}

fn num(&self) -> Self::Number {
self.num
}

fn round(&self) -> Self::Number {
self.round
}

fn start_number(&self) -> Self::Number {
self.start_number
}

fn mode(&self) -> &Mode {
&self.mode
fn block_number(&self) -> u32 {
self.block_number
}

fn set_block_no(&mut self, val: Self::Number) {
self.block_no = val;
fn blocks(&self) -> u32 {
self.blocks
}

fn set_block_in_round(&mut self, val: Self::Number) {
self.block_in_round = val;
fn transactions(&self) -> u32 {
self.transactions
}

fn set_round(&mut self, val: Self::Number) {
self.round = val;
fn set_block_number(&mut self, value: u32) {
self.block_number = value;
}

fn transfer_extrinsic(
&self,
&mut self,
sender: &Self::AccountId,
key: &Self::Secret,
destination: &Self::AccountId,
Expand All @@ -144,10 +111,12 @@ impl RuntimeAdapter for FactoryState<Number> {
genesis_hash: &<Self::Block as BlockT>::Hash,
prior_block_hash: &<Self::Block as BlockT>::Hash,
) -> <Self::Block as BlockT>::Extrinsic {
let index = self.extract_index(&sender, prior_block_hash);
let phase = self.extract_phase(*prior_block_hash);
let phase = self.block_number() as Self::Phase;
let extra = Self::build_extra(self.index, phase);
self.index += 1;

sign::<Self>(CheckedExtrinsic {
signed: Some((sender.clone(), Self::build_extra(index, phase))),
signed: Some((sender.clone(), extra)),
function: Call::Balances(
BalancesCall::transfer(
pallet_indices::address::Address::Id(destination.clone().into()),
Expand All @@ -158,12 +127,12 @@ impl RuntimeAdapter for FactoryState<Number> {
}

fn inherent_extrinsics(&self) -> InherentData {
let timestamp = (self.block_no as u64 + 1) * MinimumPeriod::get();
let timestamp = (self.block_number as u64 + 1) * MinimumPeriod::get();

let mut inherent = InherentData::new();
inherent.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Failed putting timestamp inherent");
inherent.put_data(sp_finality_tracker::INHERENT_IDENTIFIER, &self.block_no)
inherent.put_data(sp_finality_tracker::INHERENT_IDENTIFIER, &self.block_number)
.expect("Failed putting finalized number inherent");
inherent
}
Expand All @@ -181,49 +150,16 @@ impl RuntimeAdapter for FactoryState<Number> {
}

/// Generates a random `AccountId` from `seed`.
fn gen_random_account_id(seed: &Self::Number) -> Self::AccountId {
let pair: sr25519::Pair = sr25519::Pair::from_seed(&gen_seed_bytes(*seed));
fn gen_random_account_id(seed: u32) -> Self::AccountId {
let pair: sr25519::Pair = sr25519::Pair::from_seed(&gen_seed_bytes(seed));
AccountPublic::from(pair.public()).into_account()
}

/// Generates a random `Secret` from `seed`.
fn gen_random_account_secret(seed: &Self::Number) -> Self::Secret {
let pair: sr25519::Pair = sr25519::Pair::from_seed(&gen_seed_bytes(*seed));
fn gen_random_account_secret(seed: u32) -> Self::Secret {
let pair: sr25519::Pair = sr25519::Pair::from_seed(&gen_seed_bytes(seed));
pair
}

fn extract_index(
&self,
_account_id: &Self::AccountId,
_block_hash: &<Self::Block as BlockT>::Hash,
) -> Self::Index {
// TODO get correct index for account via api. See #2587.
// This currently prevents the factory from being used
// without a preceding purge of the database.
if self.mode == Mode::MasterToN || self.mode == Mode::MasterTo1 {
self.block_no() as Self::Index
} else {
match self.round() {
0 =>
// if round is 0 all transactions will be done with master as a sender
self.block_no() as Self::Index,
_ =>
// if round is e.g. 1 every sender account will be new and not yet have
// any transactions done
0
}
}
}

fn extract_phase(
&self,
_block_hash: <Self::Block as BlockT>::Hash
) -> Self::Phase {
// TODO get correct phase via api. See #2587.
// This currently prevents the factory from being used
// without a preceding purge of the database.
self.block_no() as Self::Phase
}
}

fn gen_seed_bytes(seed: u32) -> [u8; 32] {
Expand Down
Loading