diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index a3cb4fa245..afd9f09db0 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -39,8 +39,7 @@ use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use std::sync::Arc; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; // Our native executor instance. native_executor_instance!( @@ -65,12 +64,7 @@ pub fn new_partial( sp_consensus::DefaultImportQueue, sc_transaction_pool::FullPool, ( - sc_consensus_aura::AuraBlockImport< - Block, - FullClient, - sc_finality_grandpa::GrandpaBlockImport, - AuraPair, - >, + sc_finality_grandpa::GrandpaBlockImport, sc_finality_grandpa::LinkHalf, Option, ), @@ -80,6 +74,7 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } + let telemetry = config .telemetry_endpoints .clone() @@ -119,14 +114,11 @@ pub fn new_partial( telemetry.as_ref().map(|x| x.handle()), )?; - let aura_block_import = - sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: aura_block_import.clone(), - justification_import: Some(Box::new(grandpa_block_import)), + block_import: grandpa_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import.clone())), client: client.clone(), create_inherent_data_providers: move |_, ()| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -153,7 +145,7 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - other: (aura_block_import, grandpa_link, telemetry), + other: (grandpa_block_import, grandpa_link, telemetry), }) } @@ -194,16 +186,15 @@ pub fn new_full(mut config: Configuration) -> Result .extra_sets .push(sc_finality_grandpa::grandpa_peers_set_config()); - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: None, - block_announce_validator_builder: None, - })?; + let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + })?; if config.offchain_worker.enabled { sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); @@ -266,7 +257,6 @@ pub fn new_full(mut config: Configuration) -> Result on_demand: None, remote_blockchain: None, backend, - network_status_sinks, system_rpc_tx, config, telemetry: telemetry.as_mut(), @@ -286,7 +276,7 @@ pub fn new_full(mut config: Configuration) -> Result let slot_duration = sc_consensus_aura::slot_duration(&*client)?; let raw_slot_duration = slot_duration.slot_duration(); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { + let aura = sc_consensus_aura::start_aura::(StartAuraParams { slot_duration, client, select_chain, @@ -307,6 +297,7 @@ pub fn new_full(mut config: Configuration) -> Result 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), telemetry: telemetry.as_ref().map(|x| x.handle()), })?; @@ -331,7 +322,7 @@ pub fn new_full(mut config: Configuration) -> Result name: Some(name), observer_enabled: false, keystore, - is_authority: role.is_authority(), + local_role: role, telemetry: telemetry.as_ref().map(|x| x.handle()), }; @@ -402,19 +393,17 @@ pub fn new_light(mut config: Configuration) -> Result on_demand.clone(), )); - let (grandpa_block_import, _) = sc_finality_grandpa::block_import( + let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( client.clone(), &(client.clone() as Arc<_>), select_chain, telemetry.as_ref().map(|x| x.handle()), )?; - let aura_block_import = - sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: aura_block_import, + block_import: grandpa_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), create_inherent_data_providers: move |_, ()| async move { @@ -434,21 +423,40 @@ pub fn new_light(mut config: Configuration) -> Result telemetry: telemetry.as_ref().map(|x| x.handle()), })?; - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: Some(on_demand.clone()), - block_announce_validator_builder: None, - })?; + let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: Some(on_demand.clone()), + block_announce_validator_builder: None, + })?; if config.offchain_worker.enabled { sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } + let enable_grandpa = !config.disable_grandpa; + if enable_grandpa { + let name = config.network.node_name.clone(); + + let config = sc_finality_grandpa::Config { + gossip_duration: std::time::Duration::from_millis(333), + justification_period: 512, + name: Some(name), + observer_enabled: false, + keystore: None, + local_role: config.role.clone(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + }; + + task_manager.spawn_handle().spawn_blocking( + "grandpa-observer", + sc_finality_grandpa::run_grandpa_observer(config, grandpa_link, network.clone())?, + ); + } + sc_service::spawn_tasks(sc_service::SpawnTasksParams { remote_blockchain: Some(backend.remote_blockchain()), transaction_pool, @@ -460,12 +468,10 @@ pub fn new_light(mut config: Configuration) -> Result keystore: keystore_container.sync_keystore(), backend, network, - network_status_sinks, system_rpc_tx, telemetry: telemetry.as_mut(), })?; network_starter.start_network(); - Ok(task_manager) } diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 8553045419..d793c74a27 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -250,6 +250,7 @@ parameter_types! { // For weight estimation, we assume that the most locks on an individual account will be 50. // This number may need to be adjusted in the future if this assumption no longer holds true. pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -263,6 +264,8 @@ impl pallet_balances::Config for Runtime { // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; } parameter_types! { diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index a0d3d311a0..cefda5dd9a 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -28,6 +28,8 @@ // ===================================================================================== // ===================================================================================== +//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. + use rialto_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; @@ -39,8 +41,7 @@ use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use std::sync::Arc; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; // Our native executor instance. native_executor_instance!( @@ -65,12 +66,7 @@ pub fn new_partial( sp_consensus::DefaultImportQueue, sc_transaction_pool::FullPool, ( - sc_consensus_aura::AuraBlockImport< - Block, - FullClient, - sc_finality_grandpa::GrandpaBlockImport, - AuraPair, - >, + sc_finality_grandpa::GrandpaBlockImport, sc_finality_grandpa::LinkHalf, Option, ), @@ -120,14 +116,11 @@ pub fn new_partial( telemetry.as_ref().map(|x| x.handle()), )?; - let aura_block_import = - sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: aura_block_import.clone(), - justification_import: Some(Box::new(grandpa_block_import)), + block_import: grandpa_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import.clone())), client: client.clone(), create_inherent_data_providers: move |_, ()| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -154,7 +147,7 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - other: (aura_block_import, grandpa_link, telemetry), + other: (grandpa_block_import, grandpa_link, telemetry), }) } @@ -195,16 +188,15 @@ pub fn new_full(mut config: Configuration) -> Result .extra_sets .push(sc_finality_grandpa::grandpa_peers_set_config()); - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: None, - block_announce_validator_builder: None, - })?; + let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + })?; if config.offchain_worker.enabled { sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); @@ -268,7 +260,6 @@ pub fn new_full(mut config: Configuration) -> Result on_demand: None, remote_blockchain: None, backend, - network_status_sinks, system_rpc_tx, config, telemetry: telemetry.as_mut(), @@ -287,7 +278,8 @@ pub fn new_full(mut config: Configuration) -> Result let slot_duration = sc_consensus_aura::slot_duration(&*client)?; let raw_slot_duration = slot_duration.slot_duration(); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { + + let aura = sc_consensus_aura::start_aura::(StartAuraParams { slot_duration, client, select_chain, @@ -308,6 +300,7 @@ pub fn new_full(mut config: Configuration) -> Result 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), telemetry: telemetry.as_ref().map(|x| x.handle()), })?; @@ -332,7 +325,7 @@ pub fn new_full(mut config: Configuration) -> Result name: Some(name), observer_enabled: false, keystore, - is_authority: role.is_authority(), + local_role: role, telemetry: telemetry.as_ref().map(|x| x.handle()), }; @@ -403,19 +396,17 @@ pub fn new_light(mut config: Configuration) -> Result on_demand.clone(), )); - let (grandpa_block_import, _) = sc_finality_grandpa::block_import( + let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( client.clone(), &(client.clone() as Arc<_>), select_chain, telemetry.as_ref().map(|x| x.handle()), )?; - let aura_block_import = - sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: aura_block_import, + block_import: grandpa_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), create_inherent_data_providers: move |_, ()| async move { @@ -435,21 +426,40 @@ pub fn new_light(mut config: Configuration) -> Result telemetry: telemetry.as_ref().map(|x| x.handle()), })?; - let (network, network_status_sinks, system_rpc_tx, network_starter) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - on_demand: Some(on_demand.clone()), - block_announce_validator_builder: None, - })?; + let (network, system_rpc_tx, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: Some(on_demand.clone()), + block_announce_validator_builder: None, + })?; if config.offchain_worker.enabled { sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } + let enable_grandpa = !config.disable_grandpa; + if enable_grandpa { + let name = config.network.node_name.clone(); + + let config = sc_finality_grandpa::Config { + gossip_duration: std::time::Duration::from_millis(333), + justification_period: 512, + name: Some(name), + observer_enabled: false, + keystore: None, + local_role: config.role.clone(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + }; + + task_manager.spawn_handle().spawn_blocking( + "grandpa-observer", + sc_finality_grandpa::run_grandpa_observer(config, grandpa_link, network.clone())?, + ); + } + sc_service::spawn_tasks(sc_service::SpawnTasksParams { remote_blockchain: Some(backend.remote_blockchain()), transaction_pool, @@ -461,12 +471,10 @@ pub fn new_light(mut config: Configuration) -> Result keystore: keystore_container.sync_keystore(), backend, network, - network_status_sinks, system_rpc_tx, telemetry: telemetry.as_mut(), })?; network_starter.start_network(); - Ok(task_manager) } diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index e67a1c64cd..6c2a1f7418 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -357,6 +357,7 @@ parameter_types! { // For weight estimation, we assume that the most locks on an individual account will be 50. // This number may need to be adjusted in the future if this assumption no longer holds true. pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -370,6 +371,8 @@ impl pallet_balances::Config for Runtime { // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; } parameter_types! { diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index e640fa7805..460c001842 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -115,6 +115,8 @@ impl pallet_balances::Config for TestRuntime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type WeightInfo = (); + type MaxReserves = (); + type ReserveIdentifier = (); } parameter_types! { diff --git a/bridges/primitives/chain-millau/Cargo.toml b/bridges/primitives/chain-millau/Cargo.toml index 67db08c208..f4198e35c3 100644 --- a/bridges/primitives/chain-millau/Cargo.toml +++ b/bridges/primitives/chain-millau/Cargo.toml @@ -23,6 +23,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } +max-encoded-len = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false, features = ["derive"] } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } @@ -41,6 +42,7 @@ std = [ "hash256-std-hasher/std", "impl-codec/std", "impl-serde", + "max-encoded-len/std", "parity-util-mem/std", "serde", "sp-api/std", diff --git a/bridges/primitives/chain-millau/src/millau_hash.rs b/bridges/primitives/chain-millau/src/millau_hash.rs index 936791217a..219ceb68a8 100644 --- a/bridges/primitives/chain-millau/src/millau_hash.rs +++ b/bridges/primitives/chain-millau/src/millau_hash.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +use frame_support::traits::MaxEncodedLen; use parity_util_mem::MallocSizeOf; use sp_runtime::traits::CheckEqual; @@ -22,7 +23,7 @@ use sp_runtime::traits::CheckEqual; fixed_hash::construct_fixed_hash! { /// Hash type used in Millau chain. - #[derive(MallocSizeOf)] + #[derive(MallocSizeOf, MaxEncodedLen)] pub struct MillauHash(64); }