diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index c71eb8bfe3..076e282bae 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -39,6 +39,7 @@ sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", bra sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs index df790c7580..f9e9502da7 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -122,7 +122,7 @@ impl Alternative { get_account_id_from_seed::("Ferdie//stash"), get_account_id_from_seed::("George//stash"), get_account_id_from_seed::("Harry//stash"), - pallet_bridge_messages::Module::< + pallet_bridge_messages::Pallet::< millau_runtime::Runtime, pallet_bridge_messages::DefaultInstance, >::relayer_fund_account_id(), @@ -154,33 +154,33 @@ fn testnet_genesis( _enable_println: bool, ) -> GenesisConfig { GenesisConfig { - frame_system: Some(SystemConfig { + frame_system: SystemConfig { code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), - }), - pallet_balances: Some(BalancesConfig { + }, + pallet_balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), - }), - pallet_aura: Some(AuraConfig { + }, + pallet_aura: AuraConfig { authorities: Vec::new(), - }), - pallet_grandpa: Some(GrandpaConfig { + }, + pallet_grandpa: GrandpaConfig { authorities: Vec::new(), - }), - pallet_sudo: Some(SudoConfig { key: root_key }), - pallet_session: Some(SessionConfig { + }, + pallet_sudo: SudoConfig { key: root_key }, + pallet_session: SessionConfig { keys: initial_authorities .iter() .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone()))) .collect::>(), - }), - pallet_bridge_grandpa_Instance1: Some(BridgeWestendGrandpaConfig { + }, + pallet_bridge_grandpa_Instance1: BridgeWestendGrandpaConfig { // for our deployments to avoid multiple same-nonces transactions: // //Alice is already used to initialize Rialto<->Millau bridge // => let's use //George to initialize Westend->Millau bridge owner: Some(get_account_id_from_seed::("George")), ..Default::default() - }), + }, } } diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index 25cc4c7fb2..b3834ff68a 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -30,11 +30,13 @@ use millau_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; +use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_inherents::InherentDataProviders; use std::sync::Arc; @@ -70,6 +72,7 @@ pub fn new_partial( AuraPair, >, sc_finality_grandpa::LinkHalf, + Option, ), >, ServiceError, @@ -77,12 +80,30 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + let inherent_data_providers = InherentDataProviders::new(); - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::(&config)?; + 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::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; let client = Arc::new(client); + let telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); + let select_chain = sc_consensus::LongestChain::new(backend.clone()); let transaction_pool = sc_transaction_pool::BasicPool::new_full( @@ -93,22 +114,28 @@ pub fn new_partial( client.clone(), ); - let (grandpa_block_import, grandpa_link) = - sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?; + let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( + client.clone(), + &(client.clone() as Arc<_>), + select_chain.clone(), + telemetry.as_ref().map(|x| x.handle()), + )?; let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import.clone(), - Some(Box::new(grandpa_block_import)), - client.clone(), - inherent_data_providers.clone(), - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - )?; + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + block_import: aura_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import)), + client: client.clone(), + inherent_data_providers: inherent_data_providers.clone(), + spawner: &task_manager.spawn_essential_handle(), + can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + registry: config.prometheus_registry(), + check_for_equivocation: Default::default(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + })?; Ok(sc_service::PartialComponents { client, @@ -119,7 +146,7 @@ pub fn new_partial( select_chain, transaction_pool, inherent_data_providers, - other: (aura_block_import, grandpa_link), + other: (aura_block_import, grandpa_link, telemetry), }) } @@ -141,7 +168,7 @@ pub fn new_full(mut config: Configuration) -> Result select_chain, transaction_pool, inherent_data_providers, - other: (block_import, grandpa_link), + other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; if let Some(url) = &config.keystore_remote { @@ -173,13 +200,7 @@ pub fn new_full(mut config: Configuration) -> Result })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); + sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } let role = config.role.clone(); @@ -265,7 +286,7 @@ pub fn new_full(mut config: Configuration) -> Result }) }; - let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(sc_service::SpawnTasksParams { + let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { network: network.clone(), client: client.clone(), keystore: keystore_container.sync_keystore(), @@ -278,32 +299,35 @@ pub fn new_full(mut config: Configuration) -> Result network_status_sinks, system_rpc_tx, config, - telemetry_span: None, + telemetry: telemetry.as_mut(), })?; if role.is_authority() { - let proposer = sc_basic_authorship::ProposerFactory::new( + let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), transaction_pool, prometheus_registry.as_ref(), + telemetry.as_ref().map(|x| x.handle()), ); let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - client.clone(), + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + client: client.clone(), select_chain, block_import, - proposer, - network.clone(), + proposer_factory, inherent_data_providers, force_authoring, backoff_authoring_blocks, - keystore_container.sync_keystore(), + keystore: keystore_container.sync_keystore(), can_author_with, - )?; + sync_oracle: network.clone(), + block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), + telemetry: telemetry.as_ref().map(|x| x.handle()), + })?; // the AURA authoring task is considered essential, i.e. if it // fails we take down the service with it. @@ -326,6 +350,7 @@ pub fn new_full(mut config: Configuration) -> Result observer_enabled: false, keystore, is_authority: role.is_authority(), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; if enable_grandpa { @@ -339,10 +364,10 @@ pub fn new_full(mut config: Configuration) -> Result config: grandpa_config, link: grandpa_link, network, - telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()), voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state: SharedVoterState::empty(), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; // the GRANDPA voter task is considered infallible, i.e. @@ -358,8 +383,27 @@ pub fn new_full(mut config: Configuration) -> Result /// Builds a new service for a light client. pub fn new_light(mut config: Configuration) -> Result { + 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, mut task_manager, on_demand) = - sc_service::new_light_parts::(&config)?; + sc_service::new_light_parts::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; + + let mut telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); config .network @@ -376,22 +420,28 @@ pub fn new_light(mut config: Configuration) -> Result on_demand.clone(), )); - let (grandpa_block_import, _) = - sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?; + let (grandpa_block_import, _) = 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 import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import, - Some(Box::new(grandpa_block_import)), - client.clone(), - InherentDataProviders::new(), - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - sp_consensus::NeverCanAuthor, - )?; + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + block_import: aura_block_import, + justification_import: Some(Box::new(grandpa_block_import)), + client: client.clone(), + inherent_data_providers: InherentDataProviders::new(), + spawner: &task_manager.spawn_essential_handle(), + can_author_with: sp_consensus::NeverCanAuthor, + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + registry: config.prometheus_registry(), + check_for_equivocation: Default::default(), + 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 { @@ -405,13 +455,7 @@ pub fn new_light(mut config: Configuration) -> Result })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); + sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } sc_service::spawn_tasks(sc_service::SpawnTasksParams { @@ -427,7 +471,7 @@ pub fn new_light(mut config: Configuration) -> Result network, network_status_sinks, system_rpc_tx, - telemetry_span: None, + telemetry: telemetry.as_mut(), })?; network_starter.start_network(); diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index b627cce404..437c9ff36f 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -201,6 +201,8 @@ impl frame_system::Config for Runtime { type DbWeight = DbWeight; /// The designated SS58 prefix of this chain. type SS58Prefix = SS58Prefix; + /// The set code logic, just the default since we're not a parachain. + type OnSetCode = (); } impl pallet_aura::Config for Runtime { @@ -292,7 +294,7 @@ impl pallet_session::Config for Runtime { type ValidatorIdOf = (); type ShouldEndSession = pallet_session::PeriodicSessions; type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = pallet_shift_session_manager::Module; + type SessionManager = pallet_shift_session_manager::Pallet; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; type DisabledValidatorsThreshold = (); @@ -363,7 +365,7 @@ impl pallet_bridge_messages::Config for Runtime { type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier; type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, - pallet_balances::Module, + pallet_balances::Pallet, GetDeliveryConfirmationTransactionFee, RootAccountForPayments, >; @@ -378,20 +380,20 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { - BridgeRialtoMessages: pallet_bridge_messages::{Module, Call, Storage, Event}, - BridgeDispatch: pallet_bridge_dispatch::{Module, Event}, - BridgeRialtoGrandpa: pallet_bridge_grandpa::{Module, Call, Storage}, - BridgeWestendGrandpa: pallet_bridge_grandpa::::{Module, Call, Config, Storage}, - System: frame_system::{Module, Call, Config, Storage, Event}, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Aura: pallet_aura::{Module, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, - Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - ShiftSessionManager: pallet_shift_session_manager::{Module}, + BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event}, + BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event}, + BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage}, + BridgeWestendGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Config, Storage}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Aura: pallet_aura::{Pallet, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, + Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + ShiftSessionManager: pallet_shift_session_manager::{Pallet}, } ); @@ -423,7 +425,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = - frame_executive::Executive, Runtime, AllModules>; + frame_executive::Executive, Runtime, AllPallets>; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -467,7 +469,7 @@ impl_runtime_apis! { } fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed().0.into() + RandomnessCollectiveFlip::random_seed().0 } } @@ -493,8 +495,8 @@ impl_runtime_apis! { } impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> u64 { - Aura::slot_duration() + fn slot_duration() -> sp_consensus_aura::SlotDuration { + sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) } fn authorities() -> Vec { diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index 14b2c3b84c..732cf1a4b1 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -122,7 +122,7 @@ impl Alternative { get_account_id_from_seed::("Ferdie//stash"), get_account_id_from_seed::("George//stash"), get_account_id_from_seed::("Harry//stash"), - pallet_bridge_messages::Module::< + pallet_bridge_messages::Pallet::< rialto_runtime::Runtime, pallet_bridge_messages::DefaultInstance, >::relayer_fund_account_id(), @@ -154,28 +154,28 @@ fn testnet_genesis( _enable_println: bool, ) -> GenesisConfig { GenesisConfig { - frame_system: Some(SystemConfig { + frame_system: SystemConfig { code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), - }), - pallet_balances: Some(BalancesConfig { + }, + pallet_balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), - }), - pallet_aura: Some(AuraConfig { + }, + pallet_aura: AuraConfig { authorities: Vec::new(), - }), - pallet_bridge_eth_poa_Instance1: Some(load_rialto_poa_bridge_config()), - pallet_bridge_eth_poa_Instance2: Some(load_kovan_bridge_config()), - pallet_grandpa: Some(GrandpaConfig { + }, + pallet_bridge_eth_poa_Instance1: load_rialto_poa_bridge_config(), + pallet_bridge_eth_poa_Instance2: load_kovan_bridge_config(), + pallet_grandpa: GrandpaConfig { authorities: Vec::new(), - }), - pallet_sudo: Some(SudoConfig { key: root_key }), - pallet_session: Some(SessionConfig { + }, + pallet_sudo: SudoConfig { key: root_key }, + pallet_session: SessionConfig { keys: initial_authorities .iter() .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone()))) .collect::>(), - }), + }, } } diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index 4f35a8fddf..380b0cc817 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -30,11 +30,13 @@ use rialto_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; +use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_inherents::InherentDataProviders; use std::sync::Arc; @@ -70,6 +72,7 @@ pub fn new_partial( AuraPair, >, sc_finality_grandpa::LinkHalf, + Option, ), >, ServiceError, @@ -77,12 +80,30 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = sp_inherents::InherentDataProviders::new(); + let inherent_data_providers = InherentDataProviders::new(); - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::(&config)?; + 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::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; let client = Arc::new(client); + let telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); + let select_chain = sc_consensus::LongestChain::new(backend.clone()); let transaction_pool = sc_transaction_pool::BasicPool::new_full( @@ -93,22 +114,28 @@ pub fn new_partial( client.clone(), ); - let (grandpa_block_import, grandpa_link) = - sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain.clone())?; + let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import( + client.clone(), + &(client.clone() as Arc<_>), + select_chain.clone(), + telemetry.as_ref().map(|x| x.handle()), + )?; let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import.clone(), - Some(Box::new(grandpa_block_import)), - client.clone(), - inherent_data_providers.clone(), - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - )?; + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + block_import: aura_block_import.clone(), + justification_import: Some(Box::new(grandpa_block_import)), + client: client.clone(), + inherent_data_providers: inherent_data_providers.clone(), + spawner: &task_manager.spawn_essential_handle(), + can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + registry: config.prometheus_registry(), + check_for_equivocation: Default::default(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + })?; Ok(sc_service::PartialComponents { client, @@ -119,7 +146,7 @@ pub fn new_partial( select_chain, transaction_pool, inherent_data_providers, - other: (aura_block_import, grandpa_link), + other: (aura_block_import, grandpa_link, telemetry), }) } @@ -141,7 +168,7 @@ pub fn new_full(mut config: Configuration) -> Result select_chain, transaction_pool, inherent_data_providers, - other: (block_import, grandpa_link), + other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; if let Some(url) = &config.keystore_remote { @@ -173,13 +200,7 @@ pub fn new_full(mut config: Configuration) -> Result })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); + sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } let role = config.role.clone(); @@ -266,7 +287,7 @@ pub fn new_full(mut config: Configuration) -> Result }) }; - let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(sc_service::SpawnTasksParams { + let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { network: network.clone(), client: client.clone(), keystore: keystore_container.sync_keystore(), @@ -279,32 +300,35 @@ pub fn new_full(mut config: Configuration) -> Result network_status_sinks, system_rpc_tx, config, - telemetry_span: None, + telemetry: telemetry.as_mut(), })?; if role.is_authority() { - let proposer = sc_basic_authorship::ProposerFactory::new( + let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), transaction_pool, prometheus_registry.as_ref(), + telemetry.as_ref().map(|x| x.handle()), ); let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - client.clone(), + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + client: client.clone(), select_chain, block_import, - proposer, - network.clone(), + proposer_factory, inherent_data_providers, force_authoring, backoff_authoring_blocks, - keystore_container.sync_keystore(), + keystore: keystore_container.sync_keystore(), can_author_with, - )?; + sync_oracle: network.clone(), + block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), + telemetry: telemetry.as_ref().map(|x| x.handle()), + })?; // the AURA authoring task is considered essential, i.e. if it // fails we take down the service with it. @@ -327,6 +351,7 @@ pub fn new_full(mut config: Configuration) -> Result observer_enabled: false, keystore, is_authority: role.is_authority(), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; if enable_grandpa { @@ -340,10 +365,10 @@ pub fn new_full(mut config: Configuration) -> Result config: grandpa_config, link: grandpa_link, network, - telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()), voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state: SharedVoterState::empty(), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; // the GRANDPA voter task is considered infallible, i.e. @@ -359,8 +384,27 @@ pub fn new_full(mut config: Configuration) -> Result /// Builds a new service for a light client. pub fn new_light(mut config: Configuration) -> Result { + 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, mut task_manager, on_demand) = - sc_service::new_light_parts::(&config)?; + sc_service::new_light_parts::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; + + let mut telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); config .network @@ -377,22 +421,28 @@ pub fn new_light(mut config: Configuration) -> Result on_demand.clone(), )); - let (grandpa_block_import, _) = - sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?; + let (grandpa_block_import, _) = 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 import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( - sc_consensus_aura::slot_duration(&*client)?, - aura_block_import, - Some(Box::new(grandpa_block_import)), - client.clone(), - InherentDataProviders::new(), - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - sp_consensus::NeverCanAuthor, - )?; + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + block_import: aura_block_import, + justification_import: Some(Box::new(grandpa_block_import)), + client: client.clone(), + inherent_data_providers: InherentDataProviders::new(), + spawner: &task_manager.spawn_essential_handle(), + can_author_with: sp_consensus::NeverCanAuthor, + slot_duration: sc_consensus_aura::slot_duration(&*client)?, + registry: config.prometheus_registry(), + check_for_equivocation: Default::default(), + 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 { @@ -406,13 +456,7 @@ pub fn new_light(mut config: Configuration) -> Result })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - backend.clone(), - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); + sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone()); } sc_service::spawn_tasks(sc_service::SpawnTasksParams { @@ -428,7 +472,7 @@ pub fn new_light(mut config: Configuration) -> Result network, network_status_sinks, system_rpc_tx, - telemetry_span: None, + telemetry: telemetry.as_mut(), })?; network_starter.start_network(); diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 5fd10b12de..4db3101810 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -208,6 +208,8 @@ impl frame_system::Config for Runtime { type DbWeight = DbWeight; /// The designated SS58 prefix of this chain. type SS58Prefix = SS58Prefix; + /// The set code logic, just the default since we're not a parachain. + type OnSetCode = (); } impl pallet_aura::Config for Runtime { @@ -277,7 +279,7 @@ impl bp_currency_exchange::DepositInto for DepositInto { fn deposit_into(recipient: Self::Recipient, amount: Self::Amount) -> bp_currency_exchange::Result<()> { // let balances module make all checks for us (it won't allow depositing lower than existential // deposit, balance overflow, ...) - let deposited = as Currency>::deposit_creating(&recipient, amount); + let deposited = as Currency>::deposit_creating(&recipient, amount); // I'm dropping deposited here explicitly to illustrate the fact that it'll update `TotalIssuance` // on drop @@ -398,7 +400,7 @@ impl pallet_session::Config for Runtime { type ValidatorIdOf = (); type ShouldEndSession = pallet_session::PeriodicSessions; type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = pallet_shift_session_manager::Module; + type SessionManager = pallet_shift_session_manager::Pallet; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; type DisabledValidatorsThreshold = (); @@ -456,7 +458,7 @@ impl pallet_bridge_messages::Config for Runtime { type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, - pallet_balances::Module, + pallet_balances::Pallet, GetDeliveryConfirmationTransactionFee, RootAccountForPayments, >; @@ -471,23 +473,23 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { - BridgeRialtoPoA: pallet_bridge_eth_poa::::{Module, Call, Config, Storage, ValidateUnsigned}, - BridgeKovan: pallet_bridge_eth_poa::::{Module, Call, Config, Storage, ValidateUnsigned}, - BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::::{Module, Call}, - BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::::{Module, Call}, - BridgeMillauGrandpa: pallet_bridge_grandpa::{Module, Call, Storage}, - BridgeDispatch: pallet_bridge_dispatch::{Module, Event}, - BridgeMillauMessages: pallet_bridge_messages::{Module, Call, Storage, Event}, - System: frame_system::{Module, Call, Config, Storage, Event}, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Aura: pallet_aura::{Module, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, - Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - ShiftSessionManager: pallet_shift_session_manager::{Module}, + BridgeRialtoPoA: pallet_bridge_eth_poa::::{Pallet, Call, Config, Storage, ValidateUnsigned}, + BridgeKovan: pallet_bridge_eth_poa::::{Pallet, Call, Config, Storage, ValidateUnsigned}, + BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::::{Pallet, Call}, + BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::::{Pallet, Call}, + BridgeMillauGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage}, + BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event}, + BridgeMillauMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Aura: pallet_aura::{Pallet, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, + Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + ShiftSessionManager: pallet_shift_session_manager::{Pallet}, } ); @@ -519,7 +521,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = - frame_executive::Executive, Runtime, AllModules>; + frame_executive::Executive, Runtime, AllPallets>; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -563,7 +565,7 @@ impl_runtime_apis! { } fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed().0.into() + RandomnessCollectiveFlip::random_seed().0 } } @@ -652,8 +654,8 @@ impl_runtime_apis! { } impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> u64 { - Aura::slot_duration() + fn slot_duration() -> sp_consensus_aura::SlotDuration { + sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) } fn authorities() -> Vec { @@ -789,7 +791,7 @@ impl_runtime_apis! { let params = (&config, &whitelist); use pallet_bridge_currency_exchange::benchmarking::{ - Module as BridgeCurrencyExchangeBench, + Pallet as BridgeCurrencyExchangeBench, Config as BridgeCurrencyExchangeConfig, ProofParams as BridgeCurrencyExchangeProofParams, }; @@ -831,7 +833,7 @@ impl_runtime_apis! { use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge}; use bridge_runtime_common::messages; use pallet_bridge_messages::benchmarking::{ - Module as MessagesBench, + Pallet as MessagesBench, Config as MessagesConfig, MessageDeliveryProofParams, MessageParams, @@ -849,11 +851,11 @@ impl_runtime_apis! { } fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee { - pallet_balances::Module::::free_balance(account) + pallet_balances::Pallet::::free_balance(account) } fn endow_account(account: &Self::AccountId) { - pallet_balances::Module::::make_free_balance_be( + pallet_balances::Pallet::::make_free_balance_be( account, Balance::MAX / 100, ); @@ -1033,7 +1035,7 @@ mod tests { ext.execute_with(|| { // initially issuance is zero assert_eq!( - as Currency>::total_issuance(), + as Currency>::total_issuance(), 0, ); @@ -1041,14 +1043,14 @@ mod tests { let account: AccountId = [1u8; 32].into(); let initial_amount = ExistentialDeposit::get(); let deposited = - as Currency>::deposit_creating(&account, initial_amount); + as Currency>::deposit_creating(&account, initial_amount); drop(deposited); assert_eq!( - as Currency>::total_issuance(), + as Currency>::total_issuance(), initial_amount, ); assert_eq!( - as Currency>::free_balance(&account), + as Currency>::free_balance(&account), initial_amount, ); @@ -1057,7 +1059,7 @@ mod tests { // check that total issuance has changed by `run_deposit_into_test` assert_eq!( - as Currency>::total_issuance(), + as Currency>::total_issuance(), initial_amount + total_issuance_change, ); }); @@ -1101,7 +1103,7 @@ mod tests { fn deposit_into_existing_account_works() { run_deposit_into_test(|existing_account| { let initial_amount = - as Currency>::free_balance(&existing_account); + as Currency>::free_balance(&existing_account); let additional_amount = 10_000; >::DepositInto::deposit_into( existing_account.clone(), @@ -1109,7 +1111,7 @@ mod tests { ) .unwrap(); assert_eq!( - as Currency>::free_balance(&existing_account), + as Currency>::free_balance(&existing_account), initial_amount + additional_amount, ); additional_amount @@ -1128,7 +1130,7 @@ mod tests { ) .unwrap(); assert_eq!( - as Currency>::free_balance(&new_account), + as Currency>::free_balance(&new_account), initial_amount + additional_amount, ); additional_amount diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 2497f07131..8e83c0f94a 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -365,7 +365,7 @@ pub mod source { storage_proof, lane, } = proof; - pallet_bridge_grandpa::Module::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(storage_proof), |storage| { @@ -468,7 +468,7 @@ pub mod target { ThisRuntime: pallet_bridge_dispatch::Config, >::Event: From>, - pallet_bridge_dispatch::Module: + pallet_bridge_dispatch::Pallet: bp_message_dispatch::MessageDispatch<(LaneId, MessageNonce), Message = FromBridgedChainMessagePayload>, { type DispatchPayload = FromBridgedChainMessagePayload; @@ -481,7 +481,7 @@ pub mod target { fn dispatch(message: DispatchMessage>>) { let message_id = (message.key.lane_id, message.key.nonce); - pallet_bridge_dispatch::Module::::dispatch( + pallet_bridge_dispatch::Pallet::::dispatch( B::INSTANCE, message_id, message.data.payload.map_err(drop), @@ -517,7 +517,7 @@ pub mod target { proof, messages_count, |bridged_header_hash, bridged_storage_proof| { - pallet_bridge_grandpa::Module::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(bridged_storage_proof), |storage_adapter| storage_adapter, diff --git a/bridges/modules/currency-exchange/src/benchmarking.rs b/bridges/modules/currency-exchange/src/benchmarking.rs index 204398e12d..574ae93f6e 100644 --- a/bridges/modules/currency-exchange/src/benchmarking.rs +++ b/bridges/modules/currency-exchange/src/benchmarking.rs @@ -19,7 +19,7 @@ //! before invoking module calls. use super::{ - Call, Config as CurrencyExchangeConfig, InclusionProofVerifier, Instance, Module as CurrencyExchangeModule, + Call, Config as CurrencyExchangeConfig, InclusionProofVerifier, Instance, Pallet as CurrencyExchangePallet, }; use sp_std::prelude::*; @@ -30,8 +30,8 @@ const SEED: u32 = 0; const WORST_TX_SIZE_FACTOR: u32 = 1000; const WORST_PROOF_SIZE_FACTOR: u32 = 1000; -/// Module we're benchmarking here. -pub struct Module, I: Instance>(CurrencyExchangeModule); +/// Pallet we're benchmarking here. +pub struct Pallet, I: Instance>(CurrencyExchangePallet); /// Proof benchmarking parameters. pub struct ProofParams { diff --git a/bridges/modules/currency-exchange/src/lib.rs b/bridges/modules/currency-exchange/src/lib.rs index 569a01e03e..542082f85a 100644 --- a/bridges/modules/currency-exchange/src/lib.rs +++ b/bridges/modules/currency-exchange/src/lib.rs @@ -61,7 +61,7 @@ pub trait Config: frame_system::Config { } decl_error! { - pub enum Error for Module, I: Instance> { + pub enum Error for Pallet, I: Instance> { /// Invalid peer blockchain transaction provided. InvalidTransaction, /// Peer transaction has invalid amount. @@ -125,13 +125,13 @@ decl_module! { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as Bridge { + trait Store for Pallet, I: Instance = DefaultInstance> as Bridge { /// All transfers that have already been claimed. Transfers: map hasher(blake2_128_concat) ::Id => (); } } -impl, I: Instance> Module { +impl, I: Instance> Pallet { /// Returns true if currency exchange module is able to import given transaction proof in /// its current state. pub fn filter_transaction_proof( @@ -326,8 +326,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Exchange: pallet_bridge_currency_exchange::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Exchange: pallet_bridge_currency_exchange::{Pallet}, } } @@ -361,6 +361,7 @@ mod tests { type BlockLength = (); type DbWeight = (); type SS58Prefix = (); + type OnSetCode = (); } impl Config for TestRuntime { diff --git a/bridges/modules/dispatch/src/lib.rs b/bridges/modules/dispatch/src/lib.rs index d383e88469..76706d4d1e 100644 --- a/bridges/modules/dispatch/src/lib.rs +++ b/bridges/modules/dispatch/src/lib.rs @@ -153,7 +153,7 @@ pub trait Config: frame_system::Config { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as Dispatch {} + trait Store for Pallet, I: Instance = DefaultInstance> as Dispatch {} } decl_event!( @@ -189,7 +189,7 @@ decl_module! { } } -impl, I: Instance> MessageDispatch for Module { +impl, I: Instance> MessageDispatch for Pallet { type Message = MessagePayload; @@ -455,8 +455,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Dispatch: call_dispatch::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Dispatch: call_dispatch::{Pallet, Call, Event}, } } @@ -490,6 +490,7 @@ mod tests { type BlockLength = (); type DbWeight = (); type SS58Prefix = (); + type OnSetCode = (); } impl Config for TestRuntime { @@ -534,7 +535,7 @@ mod tests { fn prepare_message( origin: CallOrigin, call: Call, - ) -> as MessageDispatch<::MessageId>>::Message { + ) -> as MessageDispatch<::MessageId>>::Message { MessagePayload { spec_version: TEST_SPEC_VERSION, weight: TEST_WEIGHT, @@ -545,20 +546,20 @@ mod tests { fn prepare_root_message( call: Call, - ) -> as MessageDispatch<::MessageId>>::Message { + ) -> as MessageDispatch<::MessageId>>::Message { prepare_message(CallOrigin::SourceRoot, call) } fn prepare_target_message( call: Call, - ) -> as MessageDispatch<::MessageId>>::Message { + ) -> as MessageDispatch<::MessageId>>::Message { let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1)); prepare_message(origin, call) } fn prepare_source_message( call: Call, - ) -> as MessageDispatch<::MessageId>>::Message { + ) -> as MessageDispatch<::MessageId>>::Message { let origin = CallOrigin::SourceAccount(1); prepare_message(origin, call) } diff --git a/bridges/modules/ethereum/src/lib.rs b/bridges/modules/ethereum/src/lib.rs index c29c7844a1..aeb7d69f76 100644 --- a/bridges/modules/ethereum/src/lib.rs +++ b/bridges/modules/ethereum/src/lib.rs @@ -313,7 +313,7 @@ pub trait PruningStrategy: Default { /// Every value that is returned from this function, must be greater or equal to the /// previous value. Otherwise it will be ignored (we can't revert pruning). /// - /// Module may prune both finalized and unfinalized blocks. But it can't give any + /// Pallet may prune both finalized and unfinalized blocks. But it can't give any /// guarantees on when it will happen. Example: if some unfinalized block at height N /// has scheduled validators set change, then the module won't prune any blocks with /// number >= N even if strategy allows that. @@ -457,7 +457,7 @@ decl_module! { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as Bridge { + trait Store for Pallet, I: Instance = DefaultInstance> as Bridge { /// Best known block. BestBlock: (HeaderId, U256); /// Best finalized block. @@ -505,7 +505,7 @@ decl_storage! { } } -impl, I: Instance> Module { +impl, I: Instance> Pallet { /// Returns number and hash of the best block known to the bridge module. /// The caller should only submit `import_header` transaction that makes /// (or leads to making) other header the best one. @@ -542,7 +542,7 @@ impl, I: Instance> Module { } } -impl, I: Instance> frame_support::unsigned::ValidateUnsigned for Module { +impl, I: Instance> frame_support::unsigned::ValidateUnsigned for Pallet { type Call = Call; fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { diff --git a/bridges/modules/ethereum/src/mock.rs b/bridges/modules/ethereum/src/mock.rs index 8c305dedf7..35c093f363 100644 --- a/bridges/modules/ethereum/src/mock.rs +++ b/bridges/modules/ethereum/src/mock.rs @@ -44,8 +44,8 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Ethereum: pallet_ethereum::{Module, Call}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Ethereum: pallet_ethereum::{Pallet, Call}, } } @@ -79,6 +79,7 @@ impl frame_system::Config for TestRuntime { type BlockLength = (); type DbWeight = (); type SS58Prefix = (); + type OnSetCode = (); } parameter_types! { diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 9f7ca8231c..58f58d6aa6 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -53,7 +53,7 @@ use sp_runtime::RuntimeDebug; #[cfg(test)] mod mock; -/// Module containing weights for this pallet. +/// Pallet containing weights for this pallet. pub mod weights; #[cfg(feature = "runtime-benchmarks")] @@ -191,19 +191,19 @@ pub mod pallet { Ok(().into()) } - /// Change `ModuleOwner`. + /// Change `PalletOwner`. /// - /// May only be called either by root, or by `ModuleOwner`. + /// May only be called either by root, or by `PalletOwner`. #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResultWithPostInfo { ensure_owner_or_root::(origin)?; match new_owner { Some(new_owner) => { - ModuleOwner::::put(&new_owner); + PalletOwner::::put(&new_owner); log::info!(target: "runtime::bridge-grandpa", "Setting pallet Owner to: {:?}", new_owner); } None => { - ModuleOwner::::kill(); + PalletOwner::::kill(); log::info!(target: "runtime::bridge-grandpa", "Removed Owner of pallet."); } } @@ -213,7 +213,7 @@ pub mod pallet { /// Halt or resume all pallet operations. /// - /// May only be called either by root, or by `ModuleOwner`. + /// May only be called either by root, or by `PalletOwner`. #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_operational(origin: OriginFor, operational: bool) -> DispatchResultWithPostInfo { ensure_owner_or_root::(origin)?; @@ -265,7 +265,7 @@ pub mod pallet { /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt /// flag directly or call the `halt_operations`). #[pallet::storage] - pub(super) type ModuleOwner, I: 'static = ()> = StorageValue<_, T::AccountId, OptionQuery>; + pub(super) type PalletOwner, I: 'static = ()> = StorageValue<_, T::AccountId, OptionQuery>; /// If true, all pallet transactions are failed immediately. #[pallet::storage] @@ -293,7 +293,7 @@ pub mod pallet { impl, I: 'static> GenesisBuild for GenesisConfig { fn build(&self) { if let Some(ref owner) = self.owner { - >::put(owner); + >::put(owner); } if let Some(init_data) = self.init_data.clone() { @@ -426,11 +426,11 @@ pub mod pallet { >::put(is_halted); } - /// Ensure that the origin is either root, or `ModuleOwner`. + /// Ensure that the origin is either root, or `PalletOwner`. fn ensure_owner_or_root, I: 'static>(origin: T::Origin) -> Result<(), BadOrigin> { match origin.into() { Ok(RawOrigin::Root) => Ok(()), - Ok(RawOrigin::Signed(ref signer)) if Some(signer) == >::get().as_ref() => Ok(()), + Ok(RawOrigin::Signed(ref signer)) if Some(signer) == >::get().as_ref() => Ok(()), _ => Err(BadOrigin), } } @@ -574,22 +574,22 @@ mod tests { is_halted: false, }; - Module::::initialize(origin, init_data.clone()).map(|_| init_data) + Pallet::::initialize(origin, init_data.clone()).map(|_| init_data) } fn submit_finality_proof(header: u8) -> frame_support::dispatch::DispatchResultWithPostInfo { let header = test_header(header.into()); let justification = make_default_justification(&header); - Module::::submit_finality_proof(Origin::signed(1), header, justification) + Pallet::::submit_finality_proof(Origin::signed(1), header, justification) } fn next_block() { use frame_support::traits::OnInitialize; - let current_number = frame_system::Module::::block_number(); - frame_system::Module::::set_block_number(current_number + 1); - let _ = Module::::on_initialize(current_number); + let current_number = frame_system::Pallet::::block_number(); + frame_system::Pallet::::set_block_number(current_number + 1); + let _ = Pallet::::on_initialize(current_number); } fn change_log(delay: u64) -> Digest { @@ -625,7 +625,7 @@ mod tests { // Reset storage so we can initialize the pallet again BestFinalized::::kill(); - ModuleOwner::::put(2); + PalletOwner::::put(2); assert_ok!(init_with_origin(Origin::signed(2))); }) } @@ -637,7 +637,7 @@ mod tests { BestFinalized::::get(), BridgedBlockHash::::default() ); - assert_eq!(Module::::best_finalized(), test_header(0)); + assert_eq!(Pallet::::best_finalized(), test_header(0)); let init_data = init_with_origin(Origin::root()).unwrap(); @@ -665,56 +665,56 @@ mod tests { #[test] fn pallet_owner_may_change_owner() { run_test(|| { - ModuleOwner::::put(2); + PalletOwner::::put(2); - assert_ok!(Module::::set_owner(Origin::root(), Some(1))); + assert_ok!(Pallet::::set_owner(Origin::root(), Some(1))); assert_noop!( - Module::::set_operational(Origin::signed(2), false), + Pallet::::set_operational(Origin::signed(2), false), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::root(), false)); + assert_ok!(Pallet::::set_operational(Origin::root(), false)); - assert_ok!(Module::::set_owner(Origin::signed(1), None)); + assert_ok!(Pallet::::set_owner(Origin::signed(1), None)); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); assert_noop!( - Module::::set_operational(Origin::signed(2), true), + Pallet::::set_operational(Origin::signed(2), true), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::root(), true)); + assert_ok!(Pallet::::set_operational(Origin::root(), true)); }); } #[test] fn pallet_may_be_halted_by_root() { run_test(|| { - assert_ok!(Module::::set_operational(Origin::root(), false)); - assert_ok!(Module::::set_operational(Origin::root(), true)); + assert_ok!(Pallet::::set_operational(Origin::root(), false)); + assert_ok!(Pallet::::set_operational(Origin::root(), true)); }); } #[test] fn pallet_may_be_halted_by_owner() { run_test(|| { - ModuleOwner::::put(2); + PalletOwner::::put(2); - assert_ok!(Module::::set_operational(Origin::signed(2), false)); - assert_ok!(Module::::set_operational(Origin::signed(2), true)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), false)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), true)); assert_noop!( - Module::::set_operational(Origin::signed(1), false), + Pallet::::set_operational(Origin::signed(1), false), DispatchError::BadOrigin, ); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::signed(2), false)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), false)); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); }); @@ -755,7 +755,7 @@ mod tests { let justification = make_justification_for_header(params); assert_err!( - Module::::submit_finality_proof(Origin::signed(1), header, justification,), + Pallet::::submit_finality_proof(Origin::signed(1), header, justification,), >::InvalidJustification ); }) @@ -771,7 +771,7 @@ mod tests { justification.round = 42; assert_err!( - Module::::submit_finality_proof(Origin::signed(1), header, justification,), + Pallet::::submit_finality_proof(Origin::signed(1), header, justification,), >::InvalidJustification ); }) @@ -790,13 +790,13 @@ mod tests { is_halted: false, }; - assert_ok!(Module::::initialize(Origin::root(), init_data)); + assert_ok!(Pallet::::initialize(Origin::root(), init_data)); let header = test_header(1); let justification = make_default_justification(&header); assert_err!( - Module::::submit_finality_proof(Origin::signed(1), header, justification,), + Pallet::::submit_finality_proof(Origin::signed(1), header, justification,), >::InvalidAuthoritySet ); }) @@ -830,7 +830,7 @@ mod tests { let justification = make_default_justification(&header); // Let's import our test header - assert_ok!(Module::::submit_finality_proof( + assert_ok!(Pallet::::submit_finality_proof( Origin::signed(1), header.clone(), justification @@ -863,7 +863,7 @@ mod tests { // Should not be allowed to import this header assert_err!( - Module::::submit_finality_proof(Origin::signed(1), header, justification), + Pallet::::submit_finality_proof(Origin::signed(1), header, justification), >::UnsupportedScheduledChange ); }) @@ -884,7 +884,7 @@ mod tests { // Should not be allowed to import this header assert_err!( - Module::::submit_finality_proof(Origin::signed(1), header, justification), + Pallet::::submit_finality_proof(Origin::signed(1), header, justification), >::UnsupportedScheduledChange ); }) @@ -894,7 +894,7 @@ mod tests { fn parse_finalized_storage_proof_rejects_proof_on_unknown_header() { run_test(|| { assert_noop!( - Module::::parse_finalized_storage_proof( + Pallet::::parse_finalized_storage_proof( Default::default(), sp_trie::StorageProof::new(vec![]), |_| (), @@ -917,7 +917,7 @@ mod tests { >::insert(hash, header); assert_ok!( - Module::::parse_finalized_storage_proof(hash, storage_proof, |_| (),), + Pallet::::parse_finalized_storage_proof(hash, storage_proof, |_| (),), (), ); }); @@ -942,7 +942,7 @@ mod tests { let mut invalid_justification = make_default_justification(&header); invalid_justification.round = 42; - Module::::submit_finality_proof(Origin::signed(1), header, invalid_justification) + Pallet::::submit_finality_proof(Origin::signed(1), header, invalid_justification) }; initialize_substrate_bridge(); diff --git a/bridges/modules/grandpa/src/mock.rs b/bridges/modules/grandpa/src/mock.rs index 9646ebc552..7d5901a679 100644 --- a/bridges/modules/grandpa/src/mock.rs +++ b/bridges/modules/grandpa/src/mock.rs @@ -41,8 +41,8 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Grandpa: grandpa::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Grandpa: grandpa::{Pallet}, } } @@ -76,6 +76,7 @@ impl frame_system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type SS58Prefix = (); + type OnSetCode = (); } parameter_types! { diff --git a/bridges/modules/messages/rpc/src/lib.rs b/bridges/modules/messages/rpc/src/lib.rs index 381725f06e..a53dcfeb02 100644 --- a/bridges/modules/messages/rpc/src/lib.rs +++ b/bridges/modules/messages/rpc/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Module that provides RPC methods specific to messages pallet. +//! Pallet that provides RPC methods specific to messages pallet. use crate::error::{Error, FutureResult}; diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs index f160168d0b..d1ecf77500 100644 --- a/bridges/modules/messages/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -33,8 +33,8 @@ pub const MESSAGE_FEE: u64 = 10_000_000_000; const SEED: u32 = 0; -/// Module we're benchmarking here. -pub struct Module, I: crate::Instance>(crate::Module); +/// Pallet we're benchmarking here. +pub struct Pallet, I: crate::Instance>(crate::Pallet); /// Proof size requirements. pub enum ProofSize { @@ -142,7 +142,7 @@ benchmarks_instance! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Module::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -179,7 +179,7 @@ benchmarks_instance! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Module::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -216,7 +216,7 @@ benchmarks_instance! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Module::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -261,7 +261,7 @@ benchmarks_instance! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); } @@ -292,7 +292,7 @@ benchmarks_instance! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 22, ); } @@ -327,11 +327,11 @@ benchmarks_instance! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); assert_eq!( - crate::Module::::inbound_latest_confirmed_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_confirmed_nonce(T::bench_lane_id()), 20, ); } @@ -361,7 +361,7 @@ benchmarks_instance! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); } @@ -393,7 +393,7 @@ benchmarks_instance! { }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); } @@ -404,7 +404,7 @@ benchmarks_instance! { // // This is base benchmark for all other confirmations delivery benchmarks. receive_delivery_proof_for_single_message { - let relayers_fund_id = crate::Module::::relayer_fund_account_id(); + let relayers_fund_id = crate::Pallet::::relayer_fund_account_id(); let relayer_id: T::AccountId = account("relayer", 0, SEED); let relayer_balance = T::account_balance(&relayer_id); T::endow_account(&relayers_fund_id); @@ -441,7 +441,7 @@ benchmarks_instance! { // as `weight(receive_delivery_proof_for_two_messages_by_single_relayer) // - weight(receive_delivery_proof_for_single_message)`. receive_delivery_proof_for_two_messages_by_single_relayer { - let relayers_fund_id = crate::Module::::relayer_fund_account_id(); + let relayers_fund_id = crate::Pallet::::relayer_fund_account_id(); let relayer_id: T::AccountId = account("relayer", 0, SEED); let relayer_balance = T::account_balance(&relayer_id); T::endow_account(&relayers_fund_id); @@ -476,7 +476,7 @@ benchmarks_instance! { // as `weight(receive_delivery_proof_for_two_messages_by_two_relayers) // - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`. receive_delivery_proof_for_two_messages_by_two_relayers { - let relayers_fund_id = crate::Module::::relayer_fund_account_id(); + let relayers_fund_id = crate::Pallet::::relayer_fund_account_id(); let relayer1_id: T::AccountId = account("relayer1", 1, SEED); let relayer1_balance = T::account_balance(&relayer1_id); let relayer2_id: T::AccountId = account("relayer2", 2, SEED); @@ -540,7 +540,7 @@ benchmarks_instance! { }: send_message(RawOrigin::Signed(sender), lane_id, payload, fee) verify { assert_eq!( - crate::Module::::outbound_latest_generated_nonce(T::bench_lane_id()), + crate::Pallet::::outbound_latest_generated_nonce(T::bench_lane_id()), T::MaxMessagesToPruneAtOnce::get() + 1, ); } @@ -579,7 +579,7 @@ benchmarks_instance! { ) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 20 + i as MessageNonce, ); } @@ -616,7 +616,7 @@ benchmarks_instance! { ) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); } @@ -653,7 +653,7 @@ benchmarks_instance! { ) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 21, ); } @@ -696,11 +696,11 @@ benchmarks_instance! { ) verify { assert_eq!( - crate::Module::::inbound_latest_received_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_received_nonce(T::bench_lane_id()), 20 + i as MessageNonce, ); assert_eq!( - crate::Module::::inbound_latest_confirmed_nonce(T::bench_lane_id()), + crate::Pallet::::inbound_latest_confirmed_nonce(T::bench_lane_id()), 20, ); } @@ -713,7 +713,7 @@ benchmarks_instance! { .try_into() .expect("Value of MaxUnrewardedRelayerEntriesAtInboundLane is too large"); - let relayers_fund_id = crate::Module::::relayer_fund_account_id(); + let relayers_fund_id = crate::Pallet::::relayer_fund_account_id(); let relayer_id: T::AccountId = account("relayer", 0, SEED); let relayer_balance = T::account_balance(&relayer_id); T::endow_account(&relayers_fund_id); @@ -749,7 +749,7 @@ benchmarks_instance! { .try_into() .expect("Value of MaxUnconfirmedMessagesAtInboundLane is too large "); - let relayers_fund_id = crate::Module::::relayer_fund_account_id(); + let relayers_fund_id = crate::Pallet::::relayer_fund_account_id(); let confirmation_relayer_id = account("relayer", 0, SEED); let relayers: BTreeMap = (1..=i) .map(|j| { diff --git a/bridges/modules/messages/src/instant_payments.rs b/bridges/modules/messages/src/instant_payments.rs index 24261cf5cf..524a3765d6 100644 --- a/bridges/modules/messages/src/instant_payments.rs +++ b/bridges/modules/messages/src/instant_payments.rs @@ -59,7 +59,7 @@ where fn initialize(relayer_fund_account: &T::AccountId) -> usize { assert!( - frame_system::Module::::account_exists(relayer_fund_account), + frame_system::Pallet::::account_exists(relayer_fund_account), "The relayer fund account ({:?}) must exist for the message lanes pallet to work correctly.", relayer_fund_account, ); @@ -189,7 +189,7 @@ mod tests { use crate::mock::{run_test, AccountId as TestAccountId, Balance as TestBalance, TestRuntime}; use bp_messages::source_chain::RelayerRewards; - type Balances = pallet_balances::Module; + type Balances = pallet_balances::Pallet; const RELAYER_1: TestAccountId = 1; const RELAYER_2: TestAccountId = 2; diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 9abd2f087f..9e2563498f 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -161,7 +161,7 @@ type MessagesDeliveryProofOf = <>::TargetHeaderChain as Tar >>::MessagesDeliveryProof; decl_error! { - pub enum Error for Module, I: Instance> { + pub enum Error for Pallet, I: Instance> { /// All pallet operations are halted. Halted, /// Message has been treated as invalid by chain verifier. @@ -188,14 +188,14 @@ decl_error! { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as BridgeMessages { + trait Store for Pallet, I: Instance = DefaultInstance> as BridgeMessages { /// Optional pallet owner. /// /// Pallet owner has a right to halt all pallet operations and then resume it. If it is /// `None`, then there are no direct ways to halt/resume pallet operations, but other /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt /// flag directly or call the `halt_operations`). - pub ModuleOwner get(fn module_owner): Option; + pub PalletOwner get(fn module_owner): Option; /// If true, all pallet transactions are failed immediately. pub IsHalted get(fn is_halted) config(): bool; /// Map of lane id => inbound lane data. @@ -210,7 +210,7 @@ decl_storage! { config(owner): Option; build(|config| { if let Some(ref owner) = config.owner { - >::put(owner); + >::put(owner); } }) } @@ -246,19 +246,19 @@ decl_module! { T::DbWeight::get().reads(reads as u64) } - /// Change `ModuleOwner`. + /// Change `PalletOwner`. /// - /// May only be called either by root, or by `ModuleOwner`. + /// May only be called either by root, or by `PalletOwner`. #[weight = (T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational)] pub fn set_owner(origin, new_owner: Option) { ensure_owner_or_root::(origin)?; match new_owner { Some(new_owner) => { - ModuleOwner::::put(&new_owner); + PalletOwner::::put(&new_owner); log::info!(target: "runtime::bridge-messages", "Setting pallet Owner to: {:?}", new_owner); }, None => { - ModuleOwner::::kill(); + PalletOwner::::kill(); log::info!(target: "runtime::bridge-messages", "Removed Owner of pallet."); }, } @@ -266,7 +266,7 @@ decl_module! { /// Halt or resume all pallet operations. /// - /// May only be called either by root, or by `ModuleOwner`. + /// May only be called either by root, or by `PalletOwner`. #[weight = (T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational)] pub fn set_operational(origin, operational: bool) { ensure_owner_or_root::(origin)?; @@ -281,7 +281,7 @@ decl_module! { /// Update pallet parameter. /// - /// May only be called either by root, or by `ModuleOwner`. + /// May only be called either by root, or by `PalletOwner`. /// /// The weight is: single read for permissions check + 2 writes for parameter value and event. #[weight = (T::DbWeight::get().reads_writes(1, 2), DispatchClass::Operational)] @@ -602,7 +602,7 @@ decl_module! { } } -impl, I: Instance> Module { +impl, I: Instance> Pallet { /// Get payload of given outbound message. pub fn outbound_message_payload(lane: LaneId, nonce: MessageNonce) -> Option { OutboundMessages::::get(MessageKey { lane_id: lane, nonce }).map(|message_data| message_data.payload) @@ -686,11 +686,11 @@ pub mod storage_keys { } } -/// Ensure that the origin is either root, or `ModuleOwner`. +/// Ensure that the origin is either root, or `PalletOwner`. fn ensure_owner_or_root, I: Instance>(origin: T::Origin) -> Result<(), BadOrigin> { match origin.into() { Ok(RawOrigin::Root) => Ok(()), - Ok(RawOrigin::Signed(ref signer)) if Some(signer) == Module::::module_owner().as_ref() => Ok(()), + Ok(RawOrigin::Signed(ref signer)) if Some(signer) == Pallet::::module_owner().as_ref() => Ok(()), _ => Err(BadOrigin), } } @@ -854,7 +854,7 @@ mod tests { }; use bp_messages::UnrewardedRelayersState; use frame_support::{assert_noop, assert_ok}; - use frame_system::{EventRecord, Module as System, Phase}; + use frame_system::{EventRecord, Pallet as System, Phase}; use hex_literal::hex; use sp_runtime::DispatchError; @@ -866,7 +866,7 @@ mod tests { fn send_regular_message() { get_ready_for_events(); - assert_ok!(Module::::send_message( + assert_ok!(Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, @@ -891,7 +891,7 @@ mod tests { System::::set_block_number(1); System::::reset_events(); - assert_ok!(Module::::receive_messages_delivery_proof( + assert_ok!(Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -916,56 +916,56 @@ mod tests { #[test] fn pallet_owner_may_change_owner() { run_test(|| { - ModuleOwner::::put(2); + PalletOwner::::put(2); - assert_ok!(Module::::set_owner(Origin::root(), Some(1))); + assert_ok!(Pallet::::set_owner(Origin::root(), Some(1))); assert_noop!( - Module::::set_operational(Origin::signed(2), false), + Pallet::::set_operational(Origin::signed(2), false), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::root(), false)); + assert_ok!(Pallet::::set_operational(Origin::root(), false)); - assert_ok!(Module::::set_owner(Origin::signed(1), None)); + assert_ok!(Pallet::::set_owner(Origin::signed(1), None)); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); assert_noop!( - Module::::set_operational(Origin::signed(2), true), + Pallet::::set_operational(Origin::signed(2), true), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::root(), true)); + assert_ok!(Pallet::::set_operational(Origin::root(), true)); }); } #[test] fn pallet_may_be_halted_by_root() { run_test(|| { - assert_ok!(Module::::set_operational(Origin::root(), false)); - assert_ok!(Module::::set_operational(Origin::root(), true)); + assert_ok!(Pallet::::set_operational(Origin::root(), false)); + assert_ok!(Pallet::::set_operational(Origin::root(), true)); }); } #[test] fn pallet_may_be_halted_by_owner() { run_test(|| { - ModuleOwner::::put(2); + PalletOwner::::put(2); - assert_ok!(Module::::set_operational(Origin::signed(2), false)); - assert_ok!(Module::::set_operational(Origin::signed(2), true)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), false)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), true)); assert_noop!( - Module::::set_operational(Origin::signed(1), false), + Pallet::::set_operational(Origin::signed(1), false), DispatchError::BadOrigin, ); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); - assert_ok!(Module::::set_operational(Origin::signed(2), false)); + assert_ok!(Pallet::::set_operational(Origin::signed(2), false)); assert_noop!( - Module::::set_operational(Origin::signed(1), true), + Pallet::::set_operational(Origin::signed(1), true), DispatchError::BadOrigin, ); }); @@ -977,7 +977,7 @@ mod tests { get_ready_for_events(); let parameter = TestMessagesParameter::TokenConversionRate(10.into()); - assert_ok!(Module::::update_pallet_parameter( + assert_ok!(Pallet::::update_pallet_parameter( Origin::root(), parameter.clone(), )); @@ -997,11 +997,11 @@ mod tests { #[test] fn pallet_parameter_may_be_updated_by_owner() { run_test(|| { - ModuleOwner::::put(2); + PalletOwner::::put(2); get_ready_for_events(); let parameter = TestMessagesParameter::TokenConversionRate(10.into()); - assert_ok!(Module::::update_pallet_parameter( + assert_ok!(Pallet::::update_pallet_parameter( Origin::signed(2), parameter.clone(), )); @@ -1022,17 +1022,17 @@ mod tests { fn pallet_parameter_cant_be_updated_by_arbitrary_submitter() { run_test(|| { assert_noop!( - Module::::update_pallet_parameter( + Pallet::::update_pallet_parameter( Origin::signed(2), TestMessagesParameter::TokenConversionRate(10.into()), ), DispatchError::BadOrigin, ); - ModuleOwner::::put(2); + PalletOwner::::put(2); assert_noop!( - Module::::update_pallet_parameter( + Pallet::::update_pallet_parameter( Origin::signed(1), TestMessagesParameter::TokenConversionRate(10.into()), ), @@ -1075,7 +1075,7 @@ mod tests { IsHalted::::put(true); assert_noop!( - Module::::send_message( + Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, @@ -1085,7 +1085,7 @@ mod tests { ); assert_noop!( - Module::::receive_messages_proof( + Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![message(2, REGULAR_PAYLOAD)]).into(), @@ -1096,7 +1096,7 @@ mod tests { ); assert_noop!( - Module::::receive_messages_delivery_proof( + Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -1124,7 +1124,7 @@ mod tests { run_test(|| { // messages with this payload are rejected by target chain verifier assert_noop!( - Module::::send_message( + Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, PAYLOAD_REJECTED_BY_TARGET_CHAIN, @@ -1140,7 +1140,7 @@ mod tests { run_test(|| { // messages with zero fee are rejected by lane verifier assert_noop!( - Module::::send_message(Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, 0), + Pallet::::send_message(Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, 0), Error::::MessageRejectedByLaneVerifier, ); }); @@ -1151,7 +1151,7 @@ mod tests { run_test(|| { TestMessageDeliveryAndDispatchPayment::reject_payments(); assert_noop!( - Module::::send_message( + Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, @@ -1165,7 +1165,7 @@ mod tests { #[test] fn receive_messages_proof_works() { run_test(|| { - assert_ok!(Module::::receive_messages_proof( + assert_ok!(Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), @@ -1191,7 +1191,7 @@ mod tests { }, ); assert_eq!( - Module::::inbound_unrewarded_relayers_state(TEST_LANE_ID), + Pallet::::inbound_unrewarded_relayers_state(TEST_LANE_ID), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, @@ -1206,7 +1206,7 @@ mod tests { ..Default::default() }); - assert_ok!(Module::::receive_messages_proof( + assert_ok!(Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, message_proof, @@ -1224,7 +1224,7 @@ mod tests { }, ); assert_eq!( - Module::::inbound_unrewarded_relayers_state(TEST_LANE_ID), + Pallet::::inbound_unrewarded_relayers_state(TEST_LANE_ID), UnrewardedRelayersState { unrewarded_relayer_entries: 2, messages_in_oldest_entry: 1, @@ -1238,7 +1238,7 @@ mod tests { fn receive_messages_proof_rejects_invalid_dispatch_weight() { run_test(|| { assert_noop!( - Module::::receive_messages_proof( + Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), @@ -1254,7 +1254,7 @@ mod tests { fn receive_messages_proof_rejects_invalid_proof() { run_test(|| { assert_noop!( - Module::::receive_messages_proof( + Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Err(()).into(), @@ -1270,7 +1270,7 @@ mod tests { fn receive_messages_proof_rejects_proof_with_too_many_messages() { run_test(|| { assert_noop!( - Module::::receive_messages_proof( + Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), @@ -1298,13 +1298,13 @@ mod tests { #[test] fn receive_messages_delivery_proof_rewards_relayers() { run_test(|| { - assert_ok!(Module::::send_message( + assert_ok!(Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, 1000, )); - assert_ok!(Module::::send_message( + assert_ok!(Pallet::::send_message( Origin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD, @@ -1312,7 +1312,7 @@ mod tests { )); // this reports delivery of message 1 => reward is paid to TEST_RELAYER_A - assert_ok!(Module::::receive_messages_delivery_proof( + assert_ok!(Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -1337,7 +1337,7 @@ mod tests { )); // this reports delivery of both message 1 and message 2 => reward is paid only to TEST_RELAYER_B - assert_ok!(Module::::receive_messages_delivery_proof( + assert_ok!(Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -1369,7 +1369,7 @@ mod tests { fn receive_messages_delivery_proof_rejects_invalid_proof() { run_test(|| { assert_noop!( - Module::::receive_messages_delivery_proof( + Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Err(())), Default::default(), @@ -1384,7 +1384,7 @@ mod tests { run_test(|| { // when number of relayers entires is invalid assert_noop!( - Module::::receive_messages_delivery_proof( + Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -1406,7 +1406,7 @@ mod tests { // when number of messages is invalid assert_noop!( - Module::::receive_messages_delivery_proof( + Pallet::::receive_messages_delivery_proof( Origin::signed(1), TestMessagesDeliveryProof(Ok(( TEST_LANE_ID, @@ -1434,7 +1434,7 @@ mod tests { let mut invalid_message = message(1, REGULAR_PAYLOAD); invalid_message.data.payload = Vec::new(); - assert_ok!(Module::::receive_messages_proof( + assert_ok!(Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![invalid_message]).into(), @@ -1455,7 +1455,7 @@ mod tests { let mut invalid_message = message(2, REGULAR_PAYLOAD); invalid_message.data.payload = Vec::new(); - assert_ok!(Module::::receive_messages_proof( + assert_ok!(Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, Ok(vec![ @@ -1522,7 +1522,7 @@ mod tests { let message3 = message(2, TestPayload(0, Weight::MAX / 2)); assert_noop!( - Module::::receive_messages_proof( + Pallet::::receive_messages_proof( Origin::signed(1), TEST_RELAYER_A, // this may cause overflow if source chain storage is invalid @@ -1542,7 +1542,7 @@ mod tests { receive_messages_delivery_proof(); assert_noop!( - Module::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), + Pallet::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), Error::::MessageIsAlreadyDelivered, ); }); @@ -1552,7 +1552,7 @@ mod tests { fn increase_message_fee_fails_if_message_is_not_yet_sent() { run_test(|| { assert_noop!( - Module::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), + Pallet::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), Error::::MessageIsNotYetSent, ); }); @@ -1566,7 +1566,7 @@ mod tests { TestMessageDeliveryAndDispatchPayment::reject_payments(); assert_noop!( - Module::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), + Pallet::::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 100,), Error::::FailedToWithdrawMessageFee, ); }); @@ -1577,7 +1577,7 @@ mod tests { run_test(|| { send_regular_message(); - assert_ok!(Module::::increase_message_fee( + assert_ok!(Pallet::::increase_message_fee( Origin::signed(1), TEST_LANE_ID, 1, diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index 8cd764e441..e640fa7805 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -64,9 +64,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Event}, - Messages: pallet_bridge_messages::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Event}, + Messages: pallet_bridge_messages::{Pallet, Call, Event}, } } @@ -100,6 +100,7 @@ impl frame_system::Config for TestRuntime { type BlockLength = (); type DbWeight = (); type SS58Prefix = (); + type OnSetCode = (); } parameter_types! { @@ -112,7 +113,7 @@ impl pallet_balances::Config for TestRuntime { type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Module; + type AccountStore = frame_system::Pallet; type WeightInfo = (); } diff --git a/bridges/modules/shift-session-manager/src/lib.rs b/bridges/modules/shift-session-manager/src/lib.rs index 6df5cae377..0d867657af 100644 --- a/bridges/modules/shift-session-manager/src/lib.rs +++ b/bridges/modules/shift-session-manager/src/lib.rs @@ -31,13 +31,13 @@ decl_module! { } decl_storage! { - trait Store for Module as ShiftSessionManager { + trait Store for Pallet as ShiftSessionManager { /// Validators of first two sessions. InitialValidators: Option>; } } -impl pallet_session::SessionManager for Module { +impl pallet_session::SessionManager for Pallet { fn end_session(_: sp_staking::SessionIndex) {} fn start_session(_: sp_staking::SessionIndex) {} fn new_session(session_index: sp_staking::SessionIndex) -> Option> { @@ -52,7 +52,7 @@ impl pallet_session::SessionManager for Module { // then for every session we select (deterministically) 2/3 of these initial // validators to serve validators of new session let available_validators = InitialValidators::::get().unwrap_or_else(|| { - let validators = >::validators(); + let validators = >::validators(); InitialValidators::::put(validators.clone()); validators }); @@ -61,7 +61,7 @@ impl pallet_session::SessionManager for Module { } } -impl Module { +impl Pallet { /// Select validators for session. fn select_validators( session_index: sp_staking::SessionIndex, @@ -110,8 +110,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet}, } } @@ -145,6 +145,7 @@ mod tests { type BlockLength = (); type DbWeight = (); type SS58Prefix = (); + type OnSetCode = (); } parameter_types! { @@ -193,7 +194,7 @@ mod tests { BasicExternalities::execute_with_storage(&mut t, || { for (ref k, ..) in &keys { - frame_system::Module::::inc_providers(k); + frame_system::Pallet::::inc_providers(k); } }); @@ -209,19 +210,19 @@ mod tests { let all_accs = vec![1, 2, 3, 4, 5]; // at least 1 validator is selected - assert_eq!(Module::::select_validators(0, &[1]), vec![1],); + assert_eq!(Pallet::::select_validators(0, &[1]), vec![1],); // at session#0, shift is also 0 - assert_eq!(Module::::select_validators(0, &all_accs), vec![1, 2, 3],); + assert_eq!(Pallet::::select_validators(0, &all_accs), vec![1, 2, 3],); // at session#1, shift is also 1 - assert_eq!(Module::::select_validators(1, &all_accs), vec![2, 3, 4],); + assert_eq!(Pallet::::select_validators(1, &all_accs), vec![2, 3, 4],); // at session#3, we're wrapping - assert_eq!(Module::::select_validators(3, &all_accs), vec![4, 5, 1],); + assert_eq!(Pallet::::select_validators(3, &all_accs), vec![4, 5, 1],); // at session#5, we're starting from the beginning again - assert_eq!(Module::::select_validators(5, &all_accs), vec![1, 2, 3],); + assert_eq!(Pallet::::select_validators(5, &all_accs), vec![1, 2, 3],); }); } } diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index cb8f047cbd..22f09cb5b0 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -76,7 +76,7 @@ pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024; /// Weight of single regular message delivery transaction on Millau chain. /// -/// This value is a result of `pallet_bridge_messages::Module::receive_messages_proof_weight()` call +/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_proof_weight()` call /// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. /// The message must have dispatch weight set to zero. The result then must be rounded up to account /// possible future runtime upgrades. @@ -90,7 +90,7 @@ pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Millau chain. /// -/// This value is a result of `pallet_bridge_messages::Module::receive_messages_delivery_proof` weight formula computation +/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof` weight formula computation /// for the case when single message is confirmed. The result then must be rounded up to account possible future /// runtime upgrades. pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000; diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index feeeadf45a..c10f31bae3 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -67,7 +67,7 @@ pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128; /// Weight of single regular message delivery transaction on Rialto chain. /// -/// This value is a result of `pallet_bridge_messages::Module::receive_messages_proof_weight()` call +/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_proof_weight()` call /// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. /// The message must have dispatch weight set to zero. The result then must be rounded up to account /// possible future runtime upgrades. @@ -81,7 +81,7 @@ pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Rialto chain. /// -/// This value is a result of `pallet_bridge_messages::Module::receive_messages_delivery_proof` weight formula computation +/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof` weight formula computation /// for the case when single message is confirmed. The result then must be rounded up to account possible future /// runtime upgrades. pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000; diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 3d1ce94c04..a9c014238d 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -41,7 +41,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] pub enum Call { - MockModule, + MockPallet, } impl sp_runtime::traits::Dispatchable for Call { diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs index a2a354d9de..139b430324 100644 --- a/bridges/primitives/header-chain/src/justification.rs +++ b/bridges/primitives/header-chain/src/justification.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Module for checking GRANDPA Finality Proofs. +//! Pallet for checking GRANDPA Finality Proofs. //! //! Adapted copy of substrate/client/finality-grandpa/src/justification.rs. If origin //! will ever be moved to the sp_finality_grandpa, we should reuse that implementation. diff --git a/bridges/relays/bin-ethereum/src/ethereum_client.rs b/bridges/relays/bin-ethereum/src/ethereum_client.rs index b57b407d77..71a3f38859 100644 --- a/bridges/relays/bin-ethereum/src/ethereum_client.rs +++ b/bridges/relays/bin-ethereum/src/ethereum_client.rs @@ -29,7 +29,7 @@ use relay_ethereum_client::{ }; use relay_rialto_client::HeaderId as RialtoHeaderId; use relay_utils::{HeaderId, MaybeConnectionError}; -use sp_runtime::Justification; +use sp_runtime::EncodedJustification; use std::collections::HashSet; // to encode/decode contract calls @@ -68,7 +68,7 @@ pub trait EthereumHighLevelRpc { params: EthereumSigningParams, contract_address: Address, id: RialtoHeaderId, - justification: Justification, + justification: EncodedJustification, ) -> RpcResult; /// Submit ethereum transaction. @@ -194,7 +194,7 @@ impl EthereumHighLevelRpc for EthereumClient { params: EthereumSigningParams, contract_address: Address, id: RialtoHeaderId, - justification: Justification, + justification: EncodedJustification, ) -> RpcResult { let _ = self .submit_ethereum_transaction( diff --git a/bridges/relays/bin-ethereum/src/substrate_sync_loop.rs b/bridges/relays/bin-ethereum/src/substrate_sync_loop.rs index c0f44da3df..4e7e433d82 100644 --- a/bridges/relays/bin-ethereum/src/substrate_sync_loop.rs +++ b/bridges/relays/bin-ethereum/src/substrate_sync_loop.rs @@ -36,7 +36,7 @@ use relay_substrate_client::{ ConnectionParams as SubstrateConnectionParams, }; use relay_utils::{metrics::MetricsParams, relay_loop::Client as RelayClient}; -use sp_runtime::Justification; +use sp_runtime::EncodedJustification; use std::fmt::Debug; use std::{collections::HashSet, time::Duration}; @@ -84,7 +84,7 @@ impl HeadersSyncPipeline for SubstrateHeadersSyncPipeline { type Number = rialto_runtime::BlockNumber; type Header = RialtoSyncHeader; type Extra = (); - type Completion = Justification; + type Completion = EncodedJustification; fn estimate_size(source: &QueuedHeader) -> usize { source.header().encode().len() @@ -151,7 +151,11 @@ impl TargetClient for EthereumHeadersTarget { self.client.incomplete_substrate_headers(self.contract).await } - async fn complete_header(&self, id: RialtoHeaderId, completion: Justification) -> Result { + async fn complete_header( + &self, + id: RialtoHeaderId, + completion: EncodedJustification, + ) -> Result { self.client .complete_substrate_header(self.sign_params.clone(), self.contract, id, completion) .await diff --git a/bridges/relays/client-substrate/Cargo.toml b/bridges/relays/client-substrate/Cargo.toml index 83252358a7..48feac3834 100644 --- a/bridges/relays/client-substrate/Cargo.toml +++ b/bridges/relays/client-substrate/Cargo.toml @@ -32,6 +32,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "mast pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index 07e0a9e17c..6676873ee6 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -24,7 +24,7 @@ use sp_runtime::{ traits::{ AtLeast32Bit, Block as BlockT, Dispatchable, MaybeDisplay, MaybeSerialize, MaybeSerializeDeserialize, Member, }, - Justification, + EncodedJustification, }; use std::{fmt::Debug, time::Duration}; @@ -71,7 +71,7 @@ pub trait BlockWithJustification
{ /// Return block header. fn header(&self) -> Header; /// Return block justification, if known. - fn justification(&self) -> Option<&Justification>; + fn justification(&self) -> Option<&EncodedJustification>; } /// Substrate-based chain transactions signing scheme. @@ -97,7 +97,9 @@ impl BlockWithJustification for SignedBlock self.block.header().clone() } - fn justification(&self) -> Option<&Justification> { - self.justification.as_ref() + fn justification(&self) -> Option<&EncodedJustification> { + self.justifications + .as_ref() + .and_then(|j| j.get(sp_finality_grandpa::GRANDPA_ENGINE_ID)) } } diff --git a/bridges/relays/client-substrate/src/guard.rs b/bridges/relays/client-substrate/src/guard.rs index 3bd3df9098..68fef1c4c9 100644 --- a/bridges/relays/client-substrate/src/guard.rs +++ b/bridges/relays/client-substrate/src/guard.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Module provides a set of guard functions that are running in background threads +//! Pallet provides a set of guard functions that are running in background threads //! and are aborting process if some condition fails. use crate::{Chain, ChainWithBalances, Client}; diff --git a/bridges/relays/client-substrate/src/headers_source.rs b/bridges/relays/client-substrate/src/headers_source.rs index ad53a33a9f..3dfcb220de 100644 --- a/bridges/relays/client-substrate/src/headers_source.rs +++ b/bridges/relays/client-substrate/src/headers_source.rs @@ -26,7 +26,7 @@ use headers_relay::{ sync_types::{HeaderIdOf, HeadersSyncPipeline, QueuedHeader, SourceHeader}, }; use relay_utils::relay_loop::Client as RelayClient; -use sp_runtime::{traits::Header as HeaderT, Justification}; +use sp_runtime::{traits::Header as HeaderT, EncodedJustification}; use std::marker::PhantomData; /// Substrate node as headers source. @@ -69,7 +69,7 @@ where C: Chain, C::BlockNumber: relay_utils::BlockNumberBase, C::Header: Into, - P: HeadersSyncPipeline, + P: HeadersSyncPipeline, P::Header: SourceHeader, { async fn best_block_number(&self) -> Result { diff --git a/bridges/relays/headers/src/lib.rs b/bridges/relays/headers/src/lib.rs index 94cfd83f40..8946355921 100644 --- a/bridges/relays/headers/src/lib.rs +++ b/bridges/relays/headers/src/lib.rs @@ -16,7 +16,7 @@ //! Relaying source chain headers to target chain. This module provides entrypoint //! that starts reading new headers from source chain and submit these headers as -//! module/contract transactions to the target chain. Module/contract on the target +//! module/contract transactions to the target chain. Pallet/contract on the target //! chain is a light-client of the source chain. All other trustless bridge //! applications are built using this light-client, so running headers-relay is //! essential for running all other bridge applications.