Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1,220 changes: 450 additions & 770 deletions Cargo.lock

Large diffs are not rendered by default.

65 changes: 32 additions & 33 deletions bin/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-node"
version = "0.3.0"
version = "0.4.0"
authors = ["Cardinal Cryptography"]
description = "Aleph node binary"
edition = "2018"
Expand All @@ -24,45 +24,44 @@ futures = "0.3"
hex-literal = "0.3.1"

codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-block-builder = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-cli = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-executor = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-service = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-telemetry = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-keystore = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-keystore = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-consensus = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-consensus = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-client-api = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-timestamp = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-block-builder = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-cli = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-core = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-executor = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-service = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-telemetry = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-keystore = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-keystore = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-inherents = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-consensus = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-client-api = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-timestamp = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}

aleph-runtime = { path = "../runtime"}
finality-aleph = { path = "../../finality-aleph"}
aleph-runtime = {path = "../runtime"}
finality-aleph = {path = "../../finality-aleph"}
aleph-primitives = { package = "primitives", path = "../../primitives"}

# These dependencies are used for the node template's RPCs
jsonrpc-core = "15.1.0"
sc-rpc = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-rpc-api = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
pallet-staking = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
sc-rpc = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sc-rpc-api = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}
pallet-staking = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate.git", rev = "8bbad73f5"}
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate.git", tag = "v3.0.0"}

[features]
default = []
26 changes: 13 additions & 13 deletions bin/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ fn testnet_genesis(
millisecs_per_block
);
GenesisConfig {
system: SystemConfig {
frame_system: Some(SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
balances: BalancesConfig {
}),
pallet_balances: Some(BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: authorities
.iter()
Expand All @@ -313,20 +313,20 @@ fn testnet_genesis(
.chain(rich_accounts.into_iter())
.map(|k| (k, 1 << 60))
.collect(),
},
aura: AuraConfig {
}),
pallet_aura: Some(AuraConfig {
authorities: vec![],
},
sudo: SudoConfig {
}),
pallet_sudo: Some(SudoConfig {
// Assign network admin rights.
key: root_key,
},
aleph: AlephConfig {
}),
pallet_aleph: Some(AlephConfig {
authorities: vec![],
session_period,
millisecs_per_block,
},
session: SessionConfig {
}),
pallet_session: Some(SessionConfig {
keys: authorities
.into_iter()
.map(|auth| {
Expand All @@ -340,7 +340,7 @@ fn testnet_genesis(
)
})
.collect(),
},
vesting: VestingConfig { vesting: vec![] },
}),
pallet_vesting: Some(VestingConfig { vesting: vec![] }),
}
}
2 changes: 1 addition & 1 deletion bin/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::sync::Arc;

use aleph_runtime::{opaque::Block, AccountId, Balance, Index};
pub use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_transaction_pool::TransactionPool;

/// Full client dependencies.
pub struct FullDeps<C, P> {
Expand Down
151 changes: 51 additions & 100 deletions bin/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ use finality_aleph::{
use futures::channel::mpsc;
use log::warn;
use sc_client_api::ExecutorProvider;
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_api::ProvideRuntimeApi;
use sp_consensus::SlotData;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::{
Expand Down Expand Up @@ -48,33 +45,13 @@ pub fn new_partial(
(
AlephBlockImport<Block, FullBackend, FullClient>,
mpsc::UnboundedReceiver<JustificationNotification<Block>>,
Option<Telemetry>,
Option<Metrics<<Block as BlockT>::Header>>,
),
>,
ServiceError,
> {
let telemetry = config
.telemetry_endpoints
.clone()
.filter(|x| !x.is_empty())
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
let worker = TelemetryWorker::new(16)?;
let telemetry = worker.handle().new_telemetry(endpoints);
Ok((worker, telemetry))
})
.transpose()?;

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;

let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
telemetry
});
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(config)?;

let client: Arc<TFullClient<_, _, _>> = Arc::new(client);

Expand All @@ -84,7 +61,7 @@ pub fn new_partial(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_essential_handle(),
task_manager.spawn_handle(),
client.clone(),
);

Expand All @@ -100,32 +77,23 @@ pub fn new_partial(
let aleph_block_import =
AlephBlockImport::new(client.clone() as Arc<_>, justification_tx, metrics.clone());

let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let inherent_data_providers = sp_inherents::InherentDataProviders::new();

let import_queue =
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
block_import: aleph_block_import.clone(),
justification_import: Some(Box::new(aleph_block_import.clone())),
client: client.clone(),
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
slot_duration,
);
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
aleph_block_import.clone(),
client.clone(),
);

Ok((timestamp, slot))
},
spawner: &task_manager.spawn_essential_handle(),
registry: config.prometheus_registry(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(
client.executor().clone(),
),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
})?;
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import,
Some(Box::new(aleph_block_import.clone())),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
)?;

Ok(sc_service::PartialComponents {
client,
Expand All @@ -135,7 +103,8 @@ pub fn new_partial(
keystore_container,
select_chain,
transaction_pool,
other: (aleph_block_import, justification_rx, telemetry, metrics),
inherent_data_providers,
other: (aleph_block_import, justification_rx, metrics),
})
}

Expand All @@ -153,15 +122,17 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore_container,
select_chain,
transaction_pool,
other: (block_import, justification_rx, mut telemetry, metrics),
inherent_data_providers,
other: (block_import, justification_rx, metrics),
..
} = new_partial(&config)?;

config
.network
.extra_sets
.push(finality_aleph::peers_set_config());

let (network, system_rpc_tx, network_starter) =
let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
Expand Down Expand Up @@ -207,64 +178,44 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
})
};

let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend,
system_rpc_tx,
config,
telemetry: telemetry.as_mut(),
})?;

let (_rpc_handlers, _telemetry_connection_notifier) =
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend,
network_status_sinks,
system_rpc_tx,
config,
})?;
if role.is_authority() {
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
let proposer = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry.as_ref(),
None,
);

let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let raw_slot_duration = slot_duration.slot_duration();

let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
StartAuraParams {
slot_duration,
client: client.clone(),
select_chain: select_chain.clone(),
block_import,
proposer_factory,
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
raw_slot_duration,
);

Ok((timestamp, slot))
},
force_authoring,
backoff_authoring_blocks,
keystore: keystore_container.sync_keystore(),
can_author_with,
sync_oracle: network.clone(),
justification_sync_link: network.clone(),
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
max_block_proposal_slot_portion: None,
telemetry: telemetry.as_ref().map(|x| x.handle()),
},
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
client.clone(),
select_chain.clone(),
block_import,
proposer,
network.clone(),
inherent_data_providers,
force_authoring,
backoff_authoring_blocks,
keystore_container.sync_keystore(),
can_author_with,
)?;

task_manager
Expand Down
Loading