Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
89 changes: 88 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ members = [
"polkadot/statement-table",
"polkadot/transaction-pool",
"polkadot/validator",
"polkadot/service",
"substrate/bft",
"substrate/client",
"substrate/codec",
Expand Down
2 changes: 1 addition & 1 deletion polkadot/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub trait PolkadotApi {

/// A checked block ID used for the substrate-client implementation of CheckedBlockId;
#[derive(Debug, Clone, Copy)]
pub struct CheckedId(BlockId);
pub struct CheckedId(pub BlockId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making this pub kind of defeats the purpose of the interface


impl CheckedBlockId for CheckedId {
fn block_id(&self) -> &BlockId {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ substrate-rpc-servers = { path = "../../substrate/rpc-servers" }
polkadot-primitives = { path = "../primitives" }
polkadot-executor = { path = "../executor" }
polkadot-runtime = { path = "../runtime" }
polkadot-keystore = { path = "../keystore" }
polkadot-service = { path = "../service" }
1 change: 1 addition & 0 deletions polkadot/cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ error_chain! {
foreign_links {
Io(::std::io::Error) #[doc="IO error"];
Cli(::clap::Error) #[doc="CLI error"];
Service(::service::Error) #[doc="Polkadot service error"];
}
links {
Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
Expand Down
60 changes: 16 additions & 44 deletions polkadot/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ extern crate substrate_rpc_servers as rpc;
extern crate polkadot_primitives;
extern crate polkadot_executor;
extern crate polkadot_runtime;
extern crate polkadot_keystore as keystore;
extern crate polkadot_service as service;

#[macro_use]
extern crate hex_literal;
#[macro_use]
extern crate clap;
#[macro_use]
Expand All @@ -45,11 +43,6 @@ pub mod error;

use std::path::{Path, PathBuf};

use codec::Slicable;
use polkadot_runtime::genesismap::{additional_storage_with_genesis, GenesisConfig};
use client::genesis;
use keystore::Store as Keystore;

/// Parse command line arguments and start the node.
///
/// IANA unassigned port ranges that we could use:
Expand All @@ -69,52 +62,31 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
let log_pattern = matches.value_of("log").unwrap_or("");
init_logger(log_pattern);

// Create client
let executor = polkadot_executor::Executor::new();
let mut storage = Default::default();
let god_key = hex!["3d866ec8a9190c8343c2fc593d21d8a6d0c5c4763aaab2349de3a6111d64d124"];

let genesis_config = GenesisConfig {
validators: vec![god_key.clone()],
authorities: vec![god_key.clone()],
balances: vec![(god_key.clone(), 1u64 << 63)].into_iter().collect(),
block_time: 5, // 5 second block time.
session_length: 720, // that's 1 hour per session.
sessions_per_era: 24, // 24 hours per era.
bonding_duration: 90, // 90 days per bond.
approval_ratio: 667, // 66.7% approvals required for legislation.
};

let prepare_genesis = || {
storage = genesis_config.genesis_map();
let block = genesis::construct_genesis_block(&storage);
storage.extend(additional_storage_with_genesis(&block));
(primitives::block::Header::decode(&mut block.header.encode().as_ref()).expect("to_vec() always gives a valid serialisation; qed"), storage.into_iter().collect())
};
let mut config = service::Configuration::default();

let keystore_path = matches.value_of("keystore")
config.keystore_path = matches.value_of("keystore")
.map(|x| Path::new(x).to_owned())
.unwrap_or_else(default_keystore_path);

let _keystore = Keystore::open(keystore_path).map_err(::error::ErrorKind::Keystore)?;
let client = client::new_in_mem(executor, prepare_genesis)?;

let address = "127.0.0.1:9933".parse().unwrap();
let handler = rpc::rpc_handler(client);
let server = rpc::start_http(&address, handler)?;

let mut role = service::Role::FULL;
if let Some(_) = matches.subcommand_matches("collator") {
info!("Starting collator.");
server.wait();
return Ok(());
role = service::Role::COLLATOR;
}

if let Some(_) = matches.subcommand_matches("validator") {
else if let Some(_) = matches.subcommand_matches("validator") {
info!("Starting validator.");
server.wait();
return Ok(());
role = service::Role::VALIDATOR;
}

config.roles = role;

let service = service::Service::new(config)?;

let address = "127.0.0.1:9933".parse().unwrap();
let handler = rpc::rpc_handler(service.client());
let server = rpc::start_http(&address, handler)?;

server.wait();
println!("No command given.\n");
let _ = clap::App::from_yaml(yaml).print_long_help();

Expand Down
5 changes: 5 additions & 0 deletions polkadot/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ polkadot-transaction-pool = { path = "../transaction-pool" }
substrate-bft = { path = "../../substrate/bft" }
substrate-codec = { path = "../../substrate/codec" }
substrate-primitives = { path = "../../substrate/primitives" }
substrate-network = { path = "../../substrate/network" }

tokio-core = "0.1.12"
substrate-keyring = { path = "../../substrate/keyring" }
substrate-client = { path = "../../substrate/client" }
10 changes: 8 additions & 2 deletions polkadot/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ extern crate polkadot_transaction_pool as transaction_pool;
extern crate substrate_bft as bft;
extern crate substrate_codec as codec;
extern crate substrate_primitives as primitives;
extern crate substrate_network;

extern crate tokio_core;
extern crate substrate_keyring;
extern crate substrate_client as client;

#[macro_use]
extern crate error_chain;

#[macro_use]
extern crate log;

Expand All @@ -67,8 +71,10 @@ use futures::future;
use parking_lot::Mutex;

pub use self::error::{ErrorKind, Error};
pub use service::Service;

mod error;
mod service;

// block size limit.
const MAX_TRANSACTIONS_SIZE: usize = 4 * 1024 * 1024;
Expand All @@ -83,7 +89,7 @@ pub trait TableRouter {
type FetchExtrinsic: IntoFuture<Item=Extrinsic,Error=Self::Error>;

/// Note local candidate data.
fn local_candidate_data(&self, block_data: BlockData, extrinsic: Extrinsic);
fn local_candidate_data(&self, hash: Hash, block_data: BlockData, extrinsic: Extrinsic);

/// Fetch block data for a specific candidate.
fn fetch_block_data(&self, candidate: &CandidateReceipt) -> Self::FetchCandidate;
Expand Down
Loading