Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 7612d61

Browse files
authored
Enable collation via RPC relay chain node (#1585)
* Add minimal overseer gen with dummy subsystems * Fix dependencies * no-compile: only client transaction pool missing * Remove unused imports * Continue to hack towards PoC * Continue * Make mini node compile * Compiling version with blockchainevents trait * Continue * Check in lockfile * Block with tokio * update patches * Update polkadot patches * Use polkadot-primitives v2 * Fix build problems * First working version * Adjust cargo.lock * Add integration test * Make integration test work * Allow startinc collator without relay-chain args * Make OverseerRuntimeClient async * Create separate integration test * Remove unused ChainSelection code * Remove unused parameters on new-mini * Connect collator node in test to relay chain nodes * Make BlockChainRPCClient obsolete * Clean up * Clean up * Reimplement blockchain-rpc-events * Revert "Allow startinc collator without relay-chain args" This reverts commit f22c70e. * Add `strict_record_validation` to AuthorityDiscovery * Move network to cumulus * Remove BlockchainRPCEvents * Remove `BlockIdTo` and `BlockchainEvents` * Make AuthorityDiscovery async * Use hash in OverseerRuntime * Adjust naming of runtime client trait * Implement more rpc-client methods * Improve error handling for `ApiError` * Extract authority-discovery creationand cleanup * RPC -> Rpc * Extract bitswap * Adjust to changes on master * Implement `hash` method * Introduce DummyChainSync, remove ProofProvider and BlockBackend * Remove `HeaderMetadata` from blockchain-rpc-client * Make ChainSync work * Implement NetworkHeaderBackend * Cleanup * Adjustments after master merge * Remove ImportQueue from network parameters * Remove cargo patches * Eliminate warnings * Revert to HeaderBackend * Add zombienet test * Implement `status()` method * Add more comments, improve readability * Remove patches from Cargo.toml * Remove integration test in favor of zombienet * Remove unused dependencies, rename minimal node crate * Adjust to latest master changes * fmt * Execute zombienet test on gitlab ci * Reuse network metrics * Chainsync metrics * fmt * Feed RPC node as boot node to the relay chain minimal node * fmt * Add bootnodes to zombienet collators * Allow specification of relay chain args * Apply review suggestions * Remove unnecessary casts * Enable PoV recovery for rpc full nodes * Revert unwanted changes * Make overseerHandle non-optional * Add availability-store subsystem * Add AuxStore and ChainApiSubsystem * Add availability distribution subsystem * Improve pov-recovery logging and add RPC nodes to tests * fmt * Make availability config const * lock * Enable debug logs for pov-recovery in zombienet * Add log filters to test binary * Allow wss * Address review comments * Apply reviewer comments * Adjust to master changes * Apply reviewer suggestions * Bump polkadot * Add builder method for minimal node * Bump substrate and polkadot * Clean up overseer building * Add bootnode to two in pov_recovery test * Fix missing quote in pov recovery zombienet test * Improve zombienet pov test * More debug logs for pov-recovery * Remove reserved nodes like on original test * Revert zombienet test to master
1 parent fde36ad commit 7612d61

File tree

33 files changed

+1944
-100
lines changed

33 files changed

+1944
-100
lines changed

.gitlab-ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,35 @@ zombienet-0005-migrate_solo_to_para:
635635
tags:
636636
- zombienet-polkadot-integration-test
637637

638+
0006-rpc_collator_builds_blocks:
639+
stage: integration-test
640+
image: "${ZOMBIENET_IMAGE}"
641+
<<: *zombienet-refs
642+
needs:
643+
- job: build-push-image-test-parachain
644+
variables:
645+
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
646+
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
647+
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
648+
before_script:
649+
- echo "Zombie-net Tests Config"
650+
- echo "${ZOMBIENET_IMAGE}"
651+
- echo "${RELAY_IMAGE}"
652+
- echo "${COL_IMAGE}"
653+
- echo "${GH_DIR}"
654+
- export DEBUG=zombie
655+
- export RELAY_IMAGE=${POLKADOT_IMAGE}
656+
- export COL_IMAGE=${COL_IMAGE}
657+
script:
658+
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
659+
--github-remote-dir="${GH_DIR}"
660+
--concurrency=1
661+
--test="0006-rpc_collator_builds_blocks.feature"
662+
allow_failure: true
663+
retry: 2
664+
tags:
665+
- zombienet-polkadot-integration-test
666+
638667
#### stage: .post
639668

640669
# This job cancels the whole pipeline if any of provided jobs fail.

Cargo.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"client/relay-chain-interface",
1111
"client/relay-chain-inprocess-interface",
1212
"client/relay-chain-rpc-interface",
13+
"client/relay-chain-minimal-node",
1314
"pallets/aura-ext",
1415
"pallets/collator-selection",
1516
"pallets/dmp-queue",

client/cli/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ impl sc_cli::CliConfiguration for ExportGenesisWasmCommand {
264264
fn validate_relay_chain_url(arg: &str) -> Result<Url, String> {
265265
let url = Url::parse(arg).map_err(|e| e.to_string())?;
266266

267-
if url.scheme() == "ws" {
267+
let scheme = url.scheme();
268+
if scheme == "ws" || scheme == "wss" {
268269
Ok(url)
269270
} else {
270271
Err(format!(
@@ -290,9 +291,8 @@ pub struct RunCmd {
290291
/// EXPERIMENTAL: Specify an URL to a relay chain full node to communicate with.
291292
#[clap(
292293
long,
293-
value_parser = validate_relay_chain_url,
294-
conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one", "two"] )
295-
]
294+
value_parser = validate_relay_chain_url
295+
)]
296296
pub relay_chain_rpc_url: Option<Url>,
297297
}
298298

client/network/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
174174
Ok(false)
175175
}
176176

177-
fn overseer_handle(&self) -> RelayChainResult<Option<Handle>> {
177+
fn overseer_handle(&self) -> RelayChainResult<Handle> {
178178
unimplemented!("Not needed for test")
179179
}
180180

client/pov-recovery/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ cumulus-relay-chain-interface = {path = "../relay-chain-interface"}
3131

3232
[dev-dependencies]
3333
tokio = { version = "1.21.1", features = ["macros"] }
34+
portpicker = "0.1.1"
3435

3536
# Cumulus
3637
cumulus-test-service = { path = "../../test/service" }

client/pov-recovery/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ where
181181
Ok(_) => return,
182182
Err(e) => {
183183
tracing::debug!(
184-
target: "cumulus-consensus",
184+
target: LOG_TARGET,
185185
error = ?e,
186186
block_hash = ?hash,
187187
"Failed to get block status",
@@ -190,6 +190,7 @@ where
190190
},
191191
}
192192

193+
tracing::debug!(target: LOG_TARGET, ?hash, "Adding pending candidate");
193194
if self
194195
.pending_candidates
195196
.insert(
@@ -233,6 +234,7 @@ where
233234
None => return,
234235
};
235236

237+
tracing::debug!(target: LOG_TARGET, ?block_hash, "Issuing recovery request");
236238
self.active_candidate_recovery
237239
.recover_candidate(block_hash, pending_candidate)
238240
.await;
@@ -301,7 +303,7 @@ where
301303
Ok(BlockStatus::Unknown) => {
302304
if self.active_candidate_recovery.is_being_recovered(&parent) {
303305
tracing::debug!(
304-
target: "cumulus-consensus",
306+
target: LOG_TARGET,
305307
?block_hash,
306308
parent_hash = ?parent,
307309
"Parent is still being recovered, waiting.",
@@ -311,7 +313,7 @@ where
311313
return
312314
} else {
313315
tracing::debug!(
314-
target: "cumulus-consensus",
316+
target: LOG_TARGET,
315317
?block_hash,
316318
parent_hash = ?parent,
317319
"Parent not found while trying to import recovered block.",
@@ -324,7 +326,7 @@ where
324326
},
325327
Err(error) => {
326328
tracing::debug!(
327-
target: "cumulus-consensus",
329+
target: LOG_TARGET,
328330
block_hash = ?parent,
329331
?error,
330332
"Error while checking block status",
@@ -346,6 +348,8 @@ where
346348
/// This will also recursivley drain `waiting_for_parent` and import them as well.
347349
async fn import_block(&mut self, block: Block) {
348350
let mut blocks = VecDeque::new();
351+
352+
tracing::debug!(target: LOG_TARGET, hash = ?block.hash(), "Importing block retrieved using pov_recovery");
349353
blocks.push_back(block);
350354

351355
let mut incoming_blocks = Vec::new();

client/pov-recovery/tests/pov_recovery.rs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use cumulus_primitives_core::ParaId;
1818
use cumulus_test_service::{initial_head_data, Keyring::*};
19+
use futures::join;
1920
use std::sync::Arc;
2021

2122
/// Tests the PoV recovery.
@@ -34,12 +35,13 @@ async fn pov_recovery() {
3435
let tokio_handle = tokio::runtime::Handle::current();
3536

3637
// Start alice
38+
let ws_port = portpicker::pick_unused_port().expect("No free ports");
3739
let alice = cumulus_test_service::run_relay_chain_validator_node(
3840
tokio_handle.clone(),
3941
Alice,
4042
|| {},
4143
Vec::new(),
42-
None,
44+
Some(ws_port),
4345
);
4446

4547
// Start bob
@@ -90,16 +92,49 @@ async fn pov_recovery() {
9092
.build()
9193
.await;
9294

93-
let eve = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, Eve)
95+
let eve = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Eve)
96+
.use_null_consensus()
97+
.connect_to_parachain_node(&charlie)
98+
.connect_to_relay_chain_nodes(vec![&alice, &bob])
99+
.wrap_announce_block(|_| {
100+
// Never announce any block
101+
Arc::new(|_, _| {})
102+
})
103+
.build()
104+
.await;
105+
106+
// Run ferdie as parachain RPC collator and one as parachain RPC full node
107+
//
108+
// They will need to recover the pov blocks through availability recovery.
109+
let ferdie = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Ferdie)
94110
.use_null_consensus()
95111
.connect_to_parachain_node(&charlie)
96112
.connect_to_relay_chain_nodes(vec![&alice, &bob])
113+
.use_external_relay_chain_node_at_port(ws_port)
97114
.wrap_announce_block(|_| {
98115
// Never announce any block
99116
Arc::new(|_, _| {})
100117
})
101118
.build()
102119
.await;
103120

104-
futures::future::join(dave.wait_for_blocks(7), eve.wait_for_blocks(7)).await;
121+
let one = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, One)
122+
.enable_collator()
123+
.use_null_consensus()
124+
.connect_to_parachain_node(&charlie)
125+
.connect_to_relay_chain_nodes(vec![&alice, &bob])
126+
.use_external_relay_chain_node_at_port(ws_port)
127+
.wrap_announce_block(|_| {
128+
// Never announce any block
129+
Arc::new(|_, _| {})
130+
})
131+
.build()
132+
.await;
133+
134+
join!(
135+
dave.wait_for_blocks(7),
136+
eve.wait_for_blocks(7),
137+
ferdie.wait_for_blocks(7),
138+
one.wait_for_blocks(7)
139+
);
105140
}

client/relay-chain-inprocess-interface/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master
3838
# Polkadot
3939
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
4040
polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }
41+
metered = { package = "prioritized-metered-channel", version = "0.2.0" }
42+
43+
# Cumulus
44+
cumulus-test-service = { path = "../../test/service" }

client/relay-chain-inprocess-interface/src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct RelayChainInProcessInterface<Client> {
5050
full_client: Arc<Client>,
5151
backend: Arc<FullBackend>,
5252
sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
53-
overseer_handle: Option<Handle>,
53+
overseer_handle: Handle,
5454
}
5555

5656
impl<Client> RelayChainInProcessInterface<Client> {
@@ -59,7 +59,7 @@ impl<Client> RelayChainInProcessInterface<Client> {
5959
full_client: Arc<Client>,
6060
backend: Arc<FullBackend>,
6161
sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
62-
overseer_handle: Option<Handle>,
62+
overseer_handle: Handle,
6363
) -> Self {
6464
Self { full_client, backend, sync_oracle, overseer_handle }
6565
}
@@ -171,7 +171,7 @@ where
171171
Ok(self.sync_oracle.is_major_syncing())
172172
}
173173

174-
fn overseer_handle(&self) -> RelayChainResult<Option<Handle>> {
174+
fn overseer_handle(&self) -> RelayChainResult<Handle> {
175175
Ok(self.overseer_handle.clone())
176176
}
177177

@@ -288,7 +288,7 @@ struct RelayChainInProcessInterfaceBuilder {
288288
polkadot_client: polkadot_client::Client,
289289
backend: Arc<FullBackend>,
290290
sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
291-
overseer_handle: Option<Handle>,
291+
overseer_handle: Handle,
292292
}
293293

294294
impl RelayChainInProcessInterfaceBuilder {
@@ -378,7 +378,9 @@ pub fn build_inprocess_relay_chain(
378378
polkadot_client: full_node.client.clone(),
379379
backend: full_node.backend.clone(),
380380
sync_oracle,
381-
overseer_handle: full_node.overseer_handle.clone(),
381+
overseer_handle: full_node.overseer_handle.clone().ok_or(RelayChainError::GenericError(
382+
"Overseer not running in full node.".to_string(),
383+
))?,
382384
};
383385

384386
task_manager.add_child(full_node.task_manager);
@@ -425,10 +427,12 @@ mod tests {
425427
let block = block_builder.build().expect("Finalizes the block").block;
426428
let dummy_network: Arc<dyn SyncOracle + Sync + Send> = Arc::new(DummyNetwork {});
427429

430+
let (tx, _rx) = metered::channel(30);
431+
let mock_handle = Handle::new(tx);
428432
(
429433
client.clone(),
430434
block,
431-
RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, None),
435+
RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle),
432436
)
433437
}
434438

0 commit comments

Comments
 (0)