4

I have tested the Zombienet example network definition and feature files with default images. How can I test my custom parachain?

I have an existing docker-compose yaml file

version: "3.2"

services:
  collator:
    container_name: collator
    image: pnetwork/collator
    ports:
      - "30343:30343"
      - "40333:40333"
      - "6969:6969"
      - "8844:8844"
      - "9977:9977"
    command: bash -c "apt-get install -y wget; nohup ./target/release/parachain-collator --alice --collator --force-authoring --chain rococo-local --unsafe-ws-external --parachain-id 2000 --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe --base-path /tmp/parachain/alice --port 40333 --ws-port 8844 --rpc-port 6969 --rpc-cors all -- --execution wasm --chain res/dev/rococo-custom-2-raw.json --port 30343 --ws-port 9977 > collator.out 2>&1; tail -f /dev/null"
    depends_on:
      - charlie-relay
  alice-relay:
    container_name: alice-relay
    image: pnetwork/relay
    ports:
      - "30333:30333"
      - "9944:9944"
    command: bash -c "apt-get install -y wget; nohup ./target/release/polkadot --alice --validator --base-path /tmp/relay/alice --chain rococo-custom-2-raw.json --port 30333 --ws-port 9944 --unsafe-ws-external --rpc-cors all --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe > alice.out 2>&1; tail -f /dev/null"

  bob-relay:
    container_name: bob-relay
    image: pnetwork/relay
    ports:
      - "30334:30334"
      - "9945:9945"
    command: bash -c "apt-get install -y wget; nohup ./target/release/polkadot --bob --validator --base-path /tmp/relay/bob --chain rococo-custom-2-raw.json --port 30334 --ws-port 9945 --unsafe-ws-external --rpc-cors all --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe > bob.out 2>&1; tail -f /dev/null"

  charlie-relay:
    container_name: charlie-relay
    image: pnetwork/relay
    ports:
      - "30335:30335"
      - "9946:9946"
    command: bash -c "apt-get install -y wget; nohup ./target/release/polkadot --charlie --validator --base-path /tmp/relay/charlie --chain rococo-custom-2-raw.json --port 30335 --ws-port 9946 --unsafe-ws-external --rpc-cors all --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe > charlie.out 2>&1; tail -f /dev/null"

  frontend:
    container_name: frontend
    image: jacogr/polkadot-js-apps:latest
    ports:
      - "80:80"
    depends_on:
      - collator

From the example 0001-small-network.toml file, I keep default_command and default_args the same, but override them in each relay chain node via commandWithArgs

Then I copied alice relay chain node command from above and pasted them into my 0001-small-network.toml as

  [[relaychain.nodes]]
  name = "alice"
  validator = true
  commandWithArgs = 'bash -c... "..." '

But how about alice node's ports from the docker-compose yaml file? the copied command has ports in it...

About parachain collator, I copied its command from the docker-compose yaml file. but how about the ports again? My parachain command has port values in it, too...

[relaychain]
default_image = "docker.io/parity/polkadot:v0.9.18"
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]

chain = "rococo-local"

  [[relaychain.nodes]]
  name = "alice"
  validator = true
  commandWithArgs = 'bash -c "apt-get install -y wget; nohup ./target/release/polkadot --alice --validator --base-path /tmp/relay/alice --chain rococo-custom-2-raw.json --port 30333 --ws-port 9944 --unsafe-ws-external --rpc-cors all --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe > alice.out 2>&1; tail -f /dev/null"'

  [[relaychain.nodes]]
  name = "bob"
  validator = true
  commandWithArgs = 'bash -c "apt-get install -y wget; nohup ./target/release/polkadot --bob --validator --base-path /tmp/relay/bob --chain rococo-custom-2-raw.json --port 30334 --ws-port 9945 --unsafe-ws-external --rpc-cors all --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe > bob.out 2>&1; tail -f /dev/null"'

[[parachains]]
id = 100

  [parachains.collator]
  name = "collator01"
  image = "..."
  command = 'bash -c "apt-get install -y wget; nohup ./target/release/parachain-collator --alice --collator --force-authoring --chain rococo-local --unsafe-ws-external --parachain-id 2000 --rpc-external --allow-private-ipv4 --discover-local --rpc-methods Unsafe --base-path /tmp/parachain/alice --port 40333 --ws-port 8844 --rpc-port 6969 --rpc-cors all -- --execution wasm --chain res/dev/rococo-custom-2-raw.json --port 30343 --ws-port 9977 > collator.out 2>&1; tail -f /dev/null"'

[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"

Is that the correct way to do it? Thank you

2 Answers 2

5

There are a few things that jumped at me looking at those configurations:

  • apt-get install -y wget; should be done as part of the container setup, if you need this, derive another container from docker.io/parity/polkadot:v0.9.18

  • nohup is not necessary and not useful in this context. One usually wants all the logs.

  • bash -c is not really needed for a single command

  • redirecting output to files in the container is not recommended, it's best to use dedicated logging infra for kubernetes


Generally one should not provide the port arguments unless explicitly needed and let zombienet figure those out as much as possible. Zombienet will add cli flags, and expectes the command specified to understand substrate cli flags, so either a substrate based chain, polkadot, or in the case of liveness/sec tests malus based nemesis nodes.

3
  • 1
    As @drahnr mention ZombieNet will add some cli flags needed to work (like ports) but also will make some customization in the chain-spec (e.g. set the validators keys). Can your chain-spec (rococo-custom-2-raw.json) be generated in plain format by the collator? If not you can use the chain_spec_path to use the pre-generated one but you will need more configurations in the nodes. Thanks!
    – pepoviola
    Commented May 10, 2022 at 13:39
  • Thank you so much!
    – Russo
    Commented May 12, 2022 at 4:39
  • To give a bit more context: docker-compose as toy deployment tool and serves a different purpose than what a more tailored integration testing tool does. The integration tool makes some assumptions about the binaries deployed. It's not meant as a replacement or general purpose tool. It's sole purpose is to simplify the deployments of ad-hoc test networks and have per node assertion integrations.
    – drahnr
    Commented May 12, 2022 at 8:59
0

You need to keep the default command in polkadot relaychain, but add your collator command, which is target/release/parachain-collator if your parachain is based on substrate-parachain-template. Notice there is no DOT "." before the command!

[relaychain]
default_image = "docker.io/parity/polkadot:v0.9.18"
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]

chain = "rococo-local"

  [[relaychain.nodes]]
  name = "alice"
  validator = true

  [[relaychain.nodes]]
  name = "bob"
  validator = true

[[parachains]]
id = 2000

  [parachains.collator]
  name = "collator01"
  image = "gcr.io/p-network/collator:latest"
  command = "target/release/parachain-collator"
  
[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.