Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 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
6 changes: 4 additions & 2 deletions bin/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub fn new_authority(

let (_rpc_handlers, network, network_starter) = setup(
config,
backend,
backend.clone(),
&keystore_container,
import_queue,
transaction_pool.clone(),
Expand Down Expand Up @@ -348,6 +348,7 @@ pub fn new_authority(
let aleph_config = AlephConfig {
network,
client,
backend,
select_chain,
session_period,
millisecs_per_block,
Expand Down Expand Up @@ -396,7 +397,7 @@ pub fn new_full(

let (_rpc_handlers, network, network_starter) = setup(
config,
backend,
backend.clone(),
&keystore_container,
import_queue,
transaction_pool,
Expand All @@ -423,6 +424,7 @@ pub fn new_full(
let aleph_config = AlephConfig {
network,
client,
backend,
select_chain,
session_period,
millisecs_per_block,
Expand Down
19 changes: 9 additions & 10 deletions finality-aleph/src/justification/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use futures::{channel::mpsc, Stream, StreamExt};
use futures_timer::Delay;
use log::{debug, error};
use sc_client_api::HeaderBackend;
use sc_client_api::backend::Backend;
use sp_api::BlockT;
use sp_runtime::traits::Header;
use tokio::time::timeout;
Expand All @@ -20,50 +20,49 @@ use crate::{
network, Metrics, STATUS_REPORT_INTERVAL,
};

pub struct JustificationHandler<B, V, RB, C, S, SI, F>
pub struct JustificationHandler<B, V, RB, S, SI, F, BE>
where
B: BlockT,
V: Verifier<B>,
RB: network::RequestBlocks<B> + 'static,
C: HeaderBackend<B> + Send + Sync + 'static,
S: JustificationRequestScheduler,
SI: SessionInfoProvider<B, V>,
F: BlockFinalizer<B>,
BE: Backend<B> + Send + Sync + 'static,
{
session_info_provider: SI,
block_requester: BlockRequester<B, RB, C, S, F, V>,
block_requester: BlockRequester<B, RB, S, F, V, BE>,
verifier_timeout: Duration,
notification_timeout: Duration,
}

impl<B, V, RB, C, S, SI, F> JustificationHandler<B, V, RB, C, S, SI, F>
impl<B, V, RB, S, SI, F, BE> JustificationHandler<B, V, RB, S, SI, F, BE>
where
B: BlockT,
V: Verifier<B>,
RB: network::RequestBlocks<B> + 'static,
C: HeaderBackend<B> + Send + Sync + 'static,
S: JustificationRequestScheduler,
SI: SessionInfoProvider<B, V>,
F: BlockFinalizer<B>,
BE: Backend<B> + Send + Sync + 'static,
{
pub fn new(
session_info_provider: SI,
block_requester: RB,
client: Arc<C>,
backend: Arc<BE>,
finalizer: F,
justification_request_scheduler: S,
metrics: Option<Metrics<<B::Header as Header>::Hash>>,
justification_handler_config: JustificationHandlerConfig<B>,
justification_handler_config: JustificationHandlerConfig,
) -> Self {
Self {
session_info_provider,
block_requester: BlockRequester::new(
block_requester,
client,
backend,
finalizer,
justification_request_scheduler,
metrics,
justification_handler_config.min_allowed_delay,
),
verifier_timeout: justification_handler_config.verifier_timeout,
notification_timeout: justification_handler_config.notification_timeout,
Expand Down
19 changes: 6 additions & 13 deletions finality-aleph/src/justification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,29 @@ pub struct JustificationNotification<Block: BlockT> {
}

#[derive(Clone)]
pub struct JustificationHandlerConfig<B: BlockT> {
pub struct JustificationHandlerConfig {
/// How long should we wait when the session verifier is not yet available.
verifier_timeout: Duration,
/// How long should we wait for any notification.
notification_timeout: Duration,
///Distance (in amount of blocks) between the best and the block we want to request justification
min_allowed_delay: NumberFor<B>,
}

impl<B: BlockT> Default for JustificationHandlerConfig<B> {
impl Default for JustificationHandlerConfig {
fn default() -> Self {
Self {
verifier_timeout: Duration::from_millis(500),
notification_timeout: Duration::from_millis(1000),
min_allowed_delay: 3u32.into(),
// request justifications slightly more frequently than they're created
notification_timeout: Duration::from_millis(800),
Comment thread
timorl marked this conversation as resolved.
}
}
}

#[cfg(test)]
impl<B: BlockT> JustificationHandlerConfig<B> {
pub fn new(
verifier_timeout: Duration,
notification_timeout: Duration,
min_allowed_delay: NumberFor<B>,
) -> Self {
impl JustificationHandlerConfig {
pub fn new(verifier_timeout: Duration, notification_timeout: Duration) -> Self {
Self {
verifier_timeout,
notification_timeout,
min_allowed_delay,
}
}
}
Loading