Collator overseer builder unification (#3335)

resolve https://github.com/paritytech/polkadot-sdk/issues/3116

a follow-up on
https://github.com/paritytech/polkadot-sdk/pull/3061#pullrequestreview-1847530265:

- [x] reuse collator overseer builder for polkadot-node and collator
- [x] run zombienet test (0001-parachains-smoke-test.toml)
- [x] make wasm build errors more user-friendly for an easier problem
detection when using different toolchains in Rust

---------

Co-authored-by: ordian <write@reusable.software>
Co-authored-by: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com>
This commit is contained in:
maksimryndin
2024-02-28 05:05:54 +01:00
committed by GitHub
parent 95da658360
commit 7ec0b8741b
15 changed files with 162 additions and 278 deletions
+8 -5
View File
@@ -92,6 +92,7 @@ pub use chain_spec::{GenericChainSpec, RococoChainSpec, WestendChainSpec};
pub use consensus_common::{Proposal, SelectChain};
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use mmr_gadget::MmrGadget;
use polkadot_node_subsystem_types::DefaultSubsystemClient;
pub use polkadot_primitives::{Block, BlockId, BlockNumber, CollatorPair, Hash, Id as ParaId};
pub use sc_client_api::{Backend, CallExecutor};
pub use sc_consensus::{BlockImport, LongestChain};
@@ -1081,12 +1082,17 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
None
};
let runtime_client = Arc::new(DefaultSubsystemClient::new(
overseer_client.clone(),
OffchainTransactionPoolFactory::new(transaction_pool.clone()),
));
let overseer_handle = if let Some(authority_discovery_service) = authority_discovery_service {
let (overseer, overseer_handle) = overseer_gen
.generate::<service::SpawnTaskHandle, FullClient>(
.generate::<service::SpawnTaskHandle, DefaultSubsystemClient<FullClient>>(
overseer_connector,
OverseerGenArgs {
runtime_client: overseer_client.clone(),
runtime_client,
network_service: network.clone(),
sync_service: sync_service.clone(),
authority_discovery_service,
@@ -1099,9 +1105,6 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
overseer_message_channel_capacity_override,
req_protocol_names,
peerset_protocol_names,
offchain_transaction_pool_factory: OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
),
notification_services,
},
ext_overseer_args,
+20 -56
View File
@@ -14,10 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::{AuthorityDiscoveryApi, Block, Error, Hash, IsParachainNode, Registry};
use polkadot_node_subsystem_types::DefaultSubsystemClient;
use super::{Block, Error, Hash, IsParachainNode, Registry};
use polkadot_node_subsystem_types::{ChainApiBackend, RuntimeApiSubsystemClient};
use polkadot_overseer::{DummySubsystem, InitializedOverseerBuilder, SubsystemError};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_core::traits::SpawnNamed;
use polkadot_availability_distribution::IncomingRequestReceivers;
@@ -40,14 +39,10 @@ use polkadot_overseer::{
};
use parking_lot::Mutex;
use polkadot_primitives::runtime_api::ParachainHost;
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_client_api::AuxStore;
use sc_keystore::LocalKeystore;
use sc_network::{NetworkStateInfo, NotificationService};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus_babe::BabeApi;
use std::{collections::HashMap, sync::Arc};
pub use polkadot_approval_distribution::ApprovalDistribution as ApprovalDistributionSubsystem;
@@ -80,8 +75,6 @@ pub use polkadot_statement_distribution::StatementDistributionSubsystem;
/// Arguments passed for overseer construction.
pub struct OverseerGenArgs<'a, Spawner, RuntimeClient>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
Spawner: 'static + SpawnNamed + Clone + Unpin,
{
/// Runtime client generic, providing the `ProvieRuntimeApi` trait besides others.
@@ -89,7 +82,7 @@ where
/// Underlying network service implementation.
pub network_service: Arc<sc_network::NetworkService<Block, Hash>>,
/// Underlying syncing service implementation.
pub sync_service: Arc<sc_network_sync::SyncingService<Block>>,
pub sync_service: Arc<dyn consensus_common::SyncOracle + Send + Sync>,
/// Underlying authority discovery service.
pub authority_discovery_service: AuthorityDiscoveryService,
/// Collations request receiver for network protocol v1.
@@ -111,8 +104,6 @@ where
pub req_protocol_names: ReqProtocolNames,
/// `PeerSet` protocol names to protocols mapping.
pub peerset_protocol_names: PeerSetProtocolNames,
/// The offchain transaction pool factory.
pub offchain_transaction_pool_factory: OffchainTransactionPoolFactory<Block>,
/// Notification services for validation/collation protocols.
pub notification_services: HashMap<PeerSet, Box<dyn NotificationService>>,
}
@@ -160,7 +151,6 @@ pub fn validator_overseer_builder<Spawner, RuntimeClient>(
overseer_message_channel_capacity_override,
req_protocol_names,
peerset_protocol_names,
offchain_transaction_pool_factory,
notification_services,
}: OverseerGenArgs<Spawner, RuntimeClient>,
ExtendedOverseerGenArgs {
@@ -180,7 +170,7 @@ pub fn validator_overseer_builder<Spawner, RuntimeClient>(
) -> Result<
InitializedOverseerBuilder<
SpawnGlue<Spawner>,
Arc<DefaultSubsystemClient<RuntimeClient>>,
Arc<RuntimeClient>,
CandidateValidationSubsystem,
PvfCheckerSubsystem,
CandidateBackingSubsystem,
@@ -190,7 +180,7 @@ pub fn validator_overseer_builder<Spawner, RuntimeClient>(
BitfieldSigningSubsystem,
BitfieldDistributionSubsystem,
ProvisionerSubsystem,
RuntimeApiSubsystem<DefaultSubsystemClient<RuntimeClient>>,
RuntimeApiSubsystem<RuntimeClient>,
AvailabilityStoreSubsystem,
NetworkBridgeRxSubsystem<
Arc<sc_network::NetworkService<Block, Hash>>,
@@ -214,8 +204,7 @@ pub fn validator_overseer_builder<Spawner, RuntimeClient>(
Error,
>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
RuntimeClient: RuntimeApiSubsystemClient + ChainApiBackend + AuxStore + 'static,
Spawner: 'static + SpawnNamed + Clone + Unpin,
{
use polkadot_node_subsystem_util::metrics::Metrics;
@@ -227,11 +216,6 @@ where
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
let runtime_api_client = Arc::new(DefaultSubsystemClient::new(
runtime_client.clone(),
offchain_transaction_pool_factory,
));
let builder = Overseer::builder()
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
network_service.clone(),
@@ -298,7 +282,7 @@ where
})
.provisioner(ProvisionerSubsystem::new(Metrics::register(registry)?))
.runtime_api(RuntimeApiSubsystem::new(
runtime_api_client.clone(),
runtime_client.clone(),
Metrics::register(registry)?,
spawner.clone(),
))
@@ -339,7 +323,7 @@ where
.activation_external_listeners(Default::default())
.span_per_active_leaf(Default::default())
.active_leaves(Default::default())
.supports_parachains(runtime_api_client)
.supports_parachains(runtime_client)
.metrics(metrics)
.spawner(spawner);
@@ -367,13 +351,12 @@ pub fn collator_overseer_builder<Spawner, RuntimeClient>(
overseer_message_channel_capacity_override,
req_protocol_names,
peerset_protocol_names,
offchain_transaction_pool_factory,
notification_services,
}: OverseerGenArgs<Spawner, RuntimeClient>,
) -> Result<
InitializedOverseerBuilder<
SpawnGlue<Spawner>,
Arc<DefaultSubsystemClient<RuntimeClient>>,
Arc<RuntimeClient>,
DummySubsystem,
DummySubsystem,
DummySubsystem,
@@ -383,7 +366,7 @@ pub fn collator_overseer_builder<Spawner, RuntimeClient>(
DummySubsystem,
DummySubsystem,
DummySubsystem,
RuntimeApiSubsystem<DefaultSubsystemClient<RuntimeClient>>,
RuntimeApiSubsystem<RuntimeClient>,
DummySubsystem,
NetworkBridgeRxSubsystem<
Arc<sc_network::NetworkService<Block, Hash>>,
@@ -407,24 +390,17 @@ pub fn collator_overseer_builder<Spawner, RuntimeClient>(
Error,
>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
Spawner: 'static + SpawnNamed + Clone + Unpin,
RuntimeClient: RuntimeApiSubsystemClient + ChainApiBackend + AuxStore + 'static,
{
use polkadot_node_subsystem_util::metrics::Metrics;
let metrics = <OverseerMetrics as MetricsTrait>::register(registry)?;
let notification_sinks = Arc::new(Mutex::new(HashMap::new()));
let spawner = SpawnGlue(spawner);
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
let runtime_api_client = Arc::new(DefaultSubsystemClient::new(
runtime_client.clone(),
offchain_transaction_pool_factory,
));
let builder = Overseer::builder()
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
network_service.clone(),
@@ -475,7 +451,7 @@ where
})
.provisioner(DummySubsystem)
.runtime_api(RuntimeApiSubsystem::new(
runtime_api_client.clone(),
runtime_client.clone(),
Metrics::register(registry)?,
spawner.clone(),
))
@@ -490,8 +466,8 @@ where
.activation_external_listeners(Default::default())
.span_per_active_leaf(Default::default())
.active_leaves(Default::default())
.supports_parachains(runtime_api_client)
.metrics(metrics)
.supports_parachains(runtime_client)
.metrics(Metrics::register(registry)?)
.spawner(spawner);
let builder = if let Some(capacity) = overseer_message_channel_capacity_override {
@@ -510,13 +486,9 @@ pub trait OverseerGen {
connector: OverseerConnector,
args: OverseerGenArgs<Spawner, RuntimeClient>,
ext_args: Option<ExtendedOverseerGenArgs>,
) -> Result<
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
Error,
>
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
RuntimeClient: RuntimeApiSubsystemClient + ChainApiBackend + AuxStore + 'static,
Spawner: 'static + SpawnNamed + Clone + Unpin;
// It would be nice to make `create_subsystems` part of this trait,
@@ -533,13 +505,9 @@ impl OverseerGen for ValidatorOverseerGen {
connector: OverseerConnector,
args: OverseerGenArgs<Spawner, RuntimeClient>,
ext_args: Option<ExtendedOverseerGenArgs>,
) -> Result<
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
Error,
>
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
RuntimeClient: RuntimeApiSubsystemClient + ChainApiBackend + AuxStore + 'static,
Spawner: 'static + SpawnNamed + Clone + Unpin,
{
let ext_args = ext_args.ok_or(Error::Overseer(SubsystemError::Context(
@@ -561,13 +529,9 @@ impl OverseerGen for CollatorOverseerGen {
connector: OverseerConnector,
args: OverseerGenArgs<Spawner, RuntimeClient>,
_ext_args: Option<ExtendedOverseerGenArgs>,
) -> Result<
(Overseer<SpawnGlue<Spawner>, Arc<DefaultSubsystemClient<RuntimeClient>>>, OverseerHandle),
Error,
>
) -> Result<(Overseer<SpawnGlue<Spawner>, Arc<RuntimeClient>>, OverseerHandle), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
RuntimeClient: RuntimeApiSubsystemClient + ChainApiBackend + AuxStore + 'static,
Spawner: 'static + SpawnNamed + Clone + Unpin,
{
collator_overseer_builder(args)?