Skip to content

Commit

Permalink
fix aleph-node
Browse files Browse the repository at this point in the history
  • Loading branch information
mike1729 committed Nov 22, 2022
1 parent ad2904e commit f06d5f0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
18 changes: 6 additions & 12 deletions bin/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use finality_aleph::{
};
use futures::channel::mpsc;
use log::warn;
use sc_client_api::ExecutorProvider;
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_network::NetworkService;
use sc_service::{
Expand Down Expand Up @@ -128,7 +127,7 @@ pub fn new_partial(

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

let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(
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())),
Expand All @@ -142,13 +141,10 @@ pub fn new_partial(
slot_duration,
);

Ok((timestamp, slot))
Ok((slot, timestamp))
},
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()),
},
Expand Down Expand Up @@ -197,7 +193,7 @@ fn setup(
.extra_sets
.push(finality_aleph::peers_set_config(Protocol::Authentication));

let (network, system_rpc_tx, network_starter) =
let (network, system_rpc_tx, tx_handler_controller, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
Expand Down Expand Up @@ -233,6 +229,7 @@ fn setup(
rpc_builder,
backend,
system_rpc_tx,
tx_handler_controller,
config,
telemetry: telemetry.as_mut(),
})?;
Expand Down Expand Up @@ -304,11 +301,9 @@ pub fn new_authority(
);
proposer_factory.set_default_block_size_limit(MAX_BLOCK_SIZE as usize);

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

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

let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
StartAuraParams {
slot_duration,
client: client.clone(),
Expand All @@ -324,12 +319,11 @@ pub fn new_authority(
slot_duration,
);

Ok((timestamp, slot))
Ok((slot, timestamp))
},
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),
Expand Down
9 changes: 5 additions & 4 deletions finality-aleph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use futures::{
};
use sc_client_api::{backend::Backend, BlockchainEvents, Finalizer, LockImportRun, TransactionFor};
use sc_consensus::BlockImport;
use sc_network::{ExHashT, NetworkService};
use sc_network::NetworkService;
use sc_network_common::ExHashT;
use sc_service::SpawnTaskHandle;
use sp_api::{NumberFor, ProvideRuntimeApi};
use sp_blockchain::{HeaderBackend, HeaderMetadata};
Expand Down Expand Up @@ -70,10 +71,10 @@ enum Error {
}

/// Returns a NonDefaultSetConfig for the specified protocol.
pub fn peers_set_config(protocol: Protocol) -> sc_network::config::NonDefaultSetConfig {
pub fn peers_set_config(protocol: Protocol) -> sc_network_common::config::NonDefaultSetConfig {
let name = protocol_name(&protocol);

let mut config = sc_network::config::NonDefaultSetConfig::new(
let mut config = sc_network_common::config::NonDefaultSetConfig::new(
name,
// max_notification_size should be larger than the maximum possible honest message size (in bytes).
// Max size of alert is UNIT_SIZE * MAX_UNITS_IN_ALERT ~ 100 * 5000 = 50000 bytes
Expand All @@ -83,7 +84,7 @@ pub fn peers_set_config(protocol: Protocol) -> sc_network::config::NonDefaultSet
);

config.set_config = match protocol {
Protocol::Authentication => sc_network::config::SetConfig::default(),
Protocol::Authentication => sc_network_common::config::SetConfig::default(),
};
config
}
Expand Down
3 changes: 2 additions & 1 deletion finality-aleph/src/nodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use codec::Encode;
use log::warn;
pub use nonvalidator_node::run_nonvalidator_node;
use sc_client_api::Backend;
use sc_network::{ExHashT, NetworkService};
use sc_network::NetworkService;
use sc_network_common::ExHashT;
use sp_runtime::{
traits::{Block, Header, NumberFor},
RuntimeAppPublic,
Expand Down
2 changes: 1 addition & 1 deletion finality-aleph/src/nodes/nonvalidator_node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use log::{debug, error};
use sc_client_api::Backend;
use sc_network::ExHashT;
use sc_network_common::ExHashT;
use sp_consensus::SelectChain;
use sp_runtime::traits::Block;

Expand Down
2 changes: 1 addition & 1 deletion finality-aleph/src/nodes/validator_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bip39::{Language, Mnemonic, MnemonicType};
use futures::channel::oneshot;
use log::{debug, error};
use sc_client_api::Backend;
use sc_network::ExHashT;
use sc_network_common::ExHashT;
use sp_consensus::SelectChain;
use sp_runtime::traits::Block;

Expand Down
3 changes: 2 additions & 1 deletion finality-aleph/src/substrate_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ use futures::stream::{Stream, StreamExt};
use log::error;
use sc_consensus::JustificationSyncLink;
use sc_network::{
multiaddr::Protocol as MultiaddressProtocol, Event as SubstrateEvent, ExHashT, Multiaddr,
multiaddr::Protocol as MultiaddressProtocol, Event as SubstrateEvent, Multiaddr,
NetworkService, NetworkSyncForkRequest, PeerId,
};
use sc_network_common::{
protocol::ProtocolName,
service::{NetworkEventStream as _, NetworkNotification, NetworkPeers, NotificationSender},
ExHashT,
};
use sp_api::NumberFor;
use sp_consensus::SyncOracle;
Expand Down

0 comments on commit f06d5f0

Please sign in to comment.