From f1cab419a3874724ea804469567803908593cf0d Mon Sep 17 00:00:00 2001
From: Andronik <write@reusable.software>
Date: Wed, 19 Oct 2022 12:02:29 +0200
Subject: [PATCH] pov-recovery: try connect to validators (#1711)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* zombienet/pov-recovery: do not setup reserved connection for collators

* connect eve to dave

* REVERTME: diener update --polkadot --branch ao-recovery-try-connect

* REVERTME: cargo update -p sp-io

* REVERTME: cargo update -p sp-io and hope for the best

* pass reserved flags for eve after --

* Revert "REVERTME: cargo update -p sp-io and hope for the best"

This reverts commit 0d66b70e5ccedc7a35bcf1b30a070e68cd6a8ccc.

* Revert "REVERTME: cargo update -p sp-io"

This reverts commit f8d16c375afd41b8e0c84b59fe62019b86ba95b9.

* REVERTME: cargo update -p sp-io

* Revert "REVERTME: cargo update -p sp-io"

This reverts commit d48e1e6aa2134591b285e284077a063356d44eed.

* REVERTME: cargo update -p sp-io

* REVERTME: cargo update -p sp-io

* try some logs and flags

* apply some suggestions from Sebastian

* let Charlie produce blocks

* Revert "REVERTME: cargo update -p sp-io"

This reverts commit 02838a656eadfcbd26520e6b60ee21ffd8b27afd.

* git checkout master Cargo.lock

* Revert "REVERTME: diener update --polkadot --branch ao-recovery-try-connect"

This reverts commit 8ae8d5347b787ce5e08d6fdb5e7f266299fd70dd.

* zombienet/pov-recovery: 4 validators

* REVERTME: diener update --polkadot --branch ao-recovery-try-connect && cargo update -p polkadot-primitives

* Revert "REVERTME: diener update --polkadot --branch ao-recovery-try-connect && cargo update -p polkadot-primitives"

This reverts commit 3cc918220de5bf8ca5368586e55556464d106afd.

* make sure it is not due to backing group connections

* clean up flags

* try no-mdns on collators, limit out-peers on validators

* try no-mdns on validators and bob

* fix bob flag

* try 7 validators (3 chunks needed for recovery)

* reserved-only on validators

* reserved-only on alice and charlie

* explicitly pass log targets

* rm default_args

* parachain=debug and cumulus-pov-recovery=debug

* try another idea

* try 13 validators (4 chunks required)

* bump block height to 20

* Register parachain after 20sec, increase block target to 20

* bump zombienet version

* remove debug

* bump zombienet

* update lockfile for {"polkadot", "substrate"}

Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
Co-authored-by: Javier Viola <javier@parity.io>
Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <info@kchr.de>
---
 cumulus/.gitlab-ci.yml                        |  2 +-
 .../zombienet_tests/0002-pov_recovery.feature | 25 ++++++----
 .../zombienet_tests/0002-pov_recovery.toml    | 47 +++++++++++--------
 cumulus/zombienet_tests/register-para.js      |  9 ++++
 4 files changed, 54 insertions(+), 29 deletions(-)
 create mode 100644 cumulus/zombienet_tests/register-para.js

diff --git a/cumulus/.gitlab-ci.yml b/cumulus/.gitlab-ci.yml
index 38bccdb91bf..dcb7de25f2e 100644
--- a/cumulus/.gitlab-ci.yml
+++ b/cumulus/.gitlab-ci.yml
@@ -29,7 +29,7 @@ variables:
   CI_IMAGE:                        "paritytech/ci-linux:production"
   DOCKER_OS:                       "debian:stretch"
   ARCH:                            "x86_64"
-  ZOMBIENET_IMAGE:                 "docker.io/paritytech/zombienet:v1.2.59"
+  ZOMBIENET_IMAGE:                 "docker.io/paritytech/zombienet:v1.2.80"
 
 .collect-artifacts:                &collect-artifacts
   artifacts:
diff --git a/cumulus/zombienet_tests/0002-pov_recovery.feature b/cumulus/zombienet_tests/0002-pov_recovery.feature
index fa9836e264b..0b4d0a81de8 100644
--- a/cumulus/zombienet_tests/0002-pov_recovery.feature
+++ b/cumulus/zombienet_tests/0002-pov_recovery.feature
@@ -3,11 +3,20 @@ Network: ./0002-pov_recovery.toml
 Creds: config
 
 
-alice: is up
-bob: is up
-charlie: is up
-dave: is up
-eve: is up
-alice: parachain 2000 is registered within 225 seconds
-dave: reports block height is at least 7 within 250 seconds
-eve: reports block height is at least 7 within 250 seconds
+validator-0: is up
+validator-1: is up
+validator-2: is up
+validator-3: is up
+alice: is up within 60 seconds
+bob: is up within 60 seconds
+charlie: is up within 60 seconds
+
+# wait 30 blocks and register parachain
+validator-3: reports block height is at least 30 within 250 seconds
+validator-0: js-script ./register-para.js with "2000" within 240 seconds
+validator-0: parachain 2000 is registered within 300 seconds
+
+# check block production
+bob: reports block height is at least 20 within 600 seconds
+alice: reports block height is at least 20 within 600 seconds
+charlie: reports block height is at least 20 within 600 seconds
diff --git a/cumulus/zombienet_tests/0002-pov_recovery.toml b/cumulus/zombienet_tests/0002-pov_recovery.toml
index fc62d94595a..a9117dd82c6 100644
--- a/cumulus/zombienet_tests/0002-pov_recovery.toml
+++ b/cumulus/zombienet_tests/0002-pov_recovery.toml
@@ -1,44 +1,51 @@
 [relaychain]
 default_image = "{{RELAY_IMAGE}}"
 default_command = "polkadot"
-default_args = [ "-lparachain=debug" ]
 
 chain = "rococo-local"
 
-  [[relaychain.nodes]]
-  name = "alice"
-  validator = true
+[relaychain.genesis.runtime.runtime_genesis_config.configuration.config]
+# set parameters such that collators only connect to 1 validator as a backing group
+max_validators_per_core = 1
+group_rotation_frequency = 100 # 10 mins
 
   [[relaychain.nodes]]
-  name = "bob"
-  validator = true
+  name = "ferdie" # bootnode fullnode
+  validator = false
+
+  [[relaychain.node_groups]]
+  name = "validator"
+  count = 13
+  args = ["-lparachain::availability=trace,sync=debug,parachain=debug", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
 
 [[parachains]]
 id = 2000
 cumulus_based = true
+register_para = false
+add_to_genesis = false
 
-  # run charlie as parachain collator
+  # run bob as a parachain collator who is the only one producing blocks
+  # alice and charlie will need to recover the pov blocks through availability recovery
   [[parachains.collators]]
-  name = "charlie"
-  validator = true
+  name = "bob"
+  validator = true # collator
   image = "{{COL_IMAGE}}"
   command = "test-parachain"
-  args = ["-lparachain=debug"]
+  args = ["--disable-block-announcements"]
 
-  # Run dave as parachain collator and eve as parachain full node
-  #
-  # They will need to recover the pov blocks through availability recovery.
+  # run alice as a parachain collator who does not produce blocks
+  # alice is a bootnode for bob and charlie
   [[parachains.collators]]
-  name = "dave"
-  validator = true
+  name = "alice"
+  validator = true # collator
   image = "{{COL_IMAGE}}"
   command = "test-parachain"
-  args = ["--reserved-only", "--reserved-nodes {{'charlie'|zombie('multiAddress')}}", "--use-null-consensus", "--disable-block-announcements"]
+  args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--use-null-consensus", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}",  "--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
 
-  # run eve as parachain full node that is only connected to dave
+  # run eve as a parachain full node
   [[parachains.collators]]
-  name = "eve"
-  validator = false
+  name = "charlie"
+  validator = false # full node
   image = "{{COL_IMAGE}}"
   command = "test-parachain"
-  args = ["--reserved-only", "--reserved-nodes {{'charlie'|zombie('multiAddress')}}", "--use-null-consensus", "--disable-block-announcements"]
+  args = ["-lparachain::availability=trace,sync=debug,parachain=debug,cumulus-pov-recovery=debug", "--disable-block-announcements", "--bootnodes {{'bob'|zombie('multiAddress')}}","--", "--reserved-only", "--reserved-nodes {{'ferdie'|zombie('multiAddress')}}"]
diff --git a/cumulus/zombienet_tests/register-para.js b/cumulus/zombienet_tests/register-para.js
new file mode 100644
index 00000000000..c080904aefe
--- /dev/null
+++ b/cumulus/zombienet_tests/register-para.js
@@ -0,0 +1,9 @@
+async function run(nodeName, networkInfo, args) {
+    const paraIdStr = args[0];
+    const para = networkInfo.paras[paraIdStr];
+    const relayNode = networkInfo.relay[0];
+
+    await zombie.registerParachain(parseInt(paraIdStr,10),para.wasmPath, para.statePath, relayNode.wsUri, "//Alice", true);
+}
+
+module.exports = { run }
-- 
GitLab