Allow to specify multiple relay chain RPC urls for collator node (#1880)

* Allow specification of multiple urls for relay chain rpc nodes

* Add pooled RPC client basics

* Add list of clients to pooled client

* Improve

* Forward requests to dispatcher

* Switch clients on error

* Implement rotation logic

* Improve subscription handling

* Error handling cleanup

* Remove retry from rpc-client

* Improve naming

* Improve documentation

* Improve `ClientManager` abstraction

* Adjust zombienet test

* Add more comments

* fmt

* Apply reviewers comments

* Extract reconnection to extra method

* Add comment to reconnection method

* Clean up some dependencies

* Fix build

* fmt

* Provide alias for cli argument

* Apply review comments

* Rename P* to Relay*

* Improve zombienet test

* fmt

* Fix zombienet sleep

* Simplify zombienet test

* Reduce log clutter and fix starting position

* Do not distribute duplicated imported and finalized blocks

* fmt

* Apply code review suggestions

* Move building of relay chain interface to `cumulus-client-service`

* Refactoring to not push back into channel

* FMT
This commit is contained in:
Sebastian Kunert
2022-12-15 11:42:07 +01:00
committed by GitHub
parent e4c7978bfe
commit babf73bbc6
22 changed files with 720 additions and 428 deletions
+13 -9
View File
@@ -190,10 +190,14 @@ async fn build_relay_chain_interface(
collator_options: CollatorOptions,
task_manager: &mut TaskManager,
) -> RelayChainResult<Arc<dyn RelayChainInterface + 'static>> {
if let Some(relay_chain_url) = collator_options.relay_chain_rpc_url {
return build_minimal_relay_chain_node(relay_chain_config, task_manager, relay_chain_url)
.await
.map(|r| r.0)
if !collator_options.relay_chain_rpc_urls.is_empty() {
return build_minimal_relay_chain_node(
relay_chain_config,
task_manager,
collator_options.relay_chain_rpc_urls,
)
.await
.map(|r| r.0)
}
let relay_chain_full_node = polkadot_test_service::new_full(
@@ -429,7 +433,7 @@ pub struct TestNodeBuilder {
storage_update_func_parachain: Option<Box<dyn Fn()>>,
storage_update_func_relay_chain: Option<Box<dyn Fn()>>,
consensus: Consensus,
relay_chain_full_node_url: Option<Url>,
relay_chain_full_node_url: Vec<Url>,
}
impl TestNodeBuilder {
@@ -451,7 +455,7 @@ impl TestNodeBuilder {
storage_update_func_parachain: None,
storage_update_func_relay_chain: None,
consensus: Consensus::RelayChain,
relay_chain_full_node_url: None,
relay_chain_full_node_url: vec![],
}
}
@@ -545,7 +549,7 @@ impl TestNodeBuilder {
/// Connect to full node via RPC.
pub fn use_external_relay_chain_node_at_url(mut self, network_address: Url) -> Self {
self.relay_chain_full_node_url = Some(network_address);
self.relay_chain_full_node_url = vec![network_address];
self
}
@@ -554,7 +558,7 @@ impl TestNodeBuilder {
let mut localhost_url =
Url::parse("ws://localhost").expect("Should be able to parse localhost Url");
localhost_url.set_port(Some(port)).expect("Should be able to set port");
self.relay_chain_full_node_url = Some(localhost_url);
self.relay_chain_full_node_url = vec![localhost_url];
self
}
@@ -580,7 +584,7 @@ impl TestNodeBuilder {
);
let collator_options =
CollatorOptions { relay_chain_rpc_url: self.relay_chain_full_node_url };
CollatorOptions { relay_chain_rpc_urls: self.relay_chain_full_node_url };
relay_chain_config.network.node_name =
format!("{} (relay chain)", relay_chain_config.network.node_name);