Testing a Polkadot Parachain with Zombienet: Key steps and considerations
Tags: polkadotparachains
Published: 2024-01-11 06:41:37

<p>Regardless of what type of <a href="https://www.zeeve.io/appchains/polkadot-parachains/">Parachain </a>you are building, testing it rigorously and optimizing various aspects is integral before moving the parachain to the production environment. You may need to test the chain under certain conditions to see its operational capabilities. For example, how many transactions the Parachain can process (TPS), how much storage, RAM, and CPU it will consume, how well the nodes are connecting with each other, how’s the connectivity with the Relay chain, and a lot more. One of the best and most recommended ways of testing your Parachain is by using Zombienet– a CLI tool designed to easily spawn and test Polkadot/Substrate based networks.&nbsp;</p>
<p>This guide explains the step-by-step process of testing <a href="https://www.zeeve.io/appchains/polkadot-parachains/">Polkadot Parachain</a> with Zombienet. Basically, we will discuss two ways of doing it– by using Zombienet CLI and Zeeve’s Larch– Zeeve’s Zombienet automation tool and GUI for effortless creation of a local Parachain testing network.&nbsp;</p>
<p>But before we begin, let’s quickly explore Parachains and their unique features for those who have just started exploring Parachains. This will give a fair idea of what parachains could add to your application.&nbsp;</p>
<h2 id="h-why-are-parachains-popular-across-web3-projects">Why are Parachains popular across web3 projects?</h2>
<p><a href="https://www.zeeve.io/appchains/polkadot-parachains/">Parachains </a>are popular because of their heterogeneous, multi-chain model that allows development of general-purpose or application-specific chains customized to suit specific needs of web3 projects and dApps. Parachains inherits security and computational resources from the underlying Layer-0 Polkadot ecosystem. Also, all the Parachain are connected to the Relay chain while running in parallel, to maintain interoperability between all the Parachains. Following are the unique benefits of Parachains:</p>
<li>Enables creation of specialized L1 blockchains</li>
<li>Flexibility in customizing various aspects of the chain, for example- TPS.</li>
<li>Interoperability through native bridges.</li>
<li>Ease of scaling for higher TPS, without the need of sacrificing security and decentralization.</li>
<li>Does not requires users to pay platform fees as Parachains consume computational power from Polkadot.</li>
<li>Freedom to offer a custom fee structure designed as per the project’s specifications.</li>
<li>No need of bootstrapping their own validators or miners, Parachains leverage security from Polkadot.</li>
<li>Easy to upgrade, fix bugs, and incorporate new features as needed.</li>
<li>And, much more…</li>
<h2>Key considerations for&nbsp;testing Polkadot Parachains with Zombienet</h2>
<p>The following are the important things you need to consider before you test Parachain with Zombienet:</p>
<h3>Compatibility:&nbsp;</h3>
<p>Zombienet is currently compatible with Kubernetes, Podman, and native. However, the requirements for all three platforms are different. For example, Zombienet can work on any k8s cluster, but you must install <strong>kubectl </strong>to interact with cluster. As for Podman, Zombienet supports <strong>rootless </strong>as provider. The Native Zombienet provider allows nodes to run as local process in any environment.&nbsp;</p>
<h3>Features by providers:</h3>
<p>Each of the Kubernetes’ supported providers offers distinct features. For k8s, Zombinet use Prometheus operator for offloading the visibility/monitoring layer, allowing only the pods to be deployed. Whereas, with Podman,&nbsp; ZombieNet can deploy a couple of extra pods to add a layer of monitoring/visibility to the running network. Right now, native provider doesn't run any extra layer/process at the moment.</p>
<h3>Testing parameters:&nbsp;</h3>
<p>Zombienet spawns a network to perform test against metrics, logs, and built-in functions upholding the network. For example, it will check if all the nodes in your network is running, is the defined parachain registered, or can the parachain produce atleast 10 blocks within 100 seconds.</p>
<h3>Project types:&nbsp;</h3>
<p>Zombienet is suitable for a range of projects using it for as a testing framework or integration. For example in Parity, the projects are CAPI, Cumulus, Polkadot in the testing pipeline, Substrate, <a href="https://www.zeeve.io/appchains/substrate-chains/">Substrate </a>Connect. Speaking about <a href="https://www.zeeve.io/appchains/polkadot-parachains/">Polkadot</a>, the projects are Acurast, Astar, Gossamer, Oak/Turing/Neumann, Hydradx, InvArch, Mangata, Manta/Phala, Moonbeam, and more.</p>
<h2 id="h-testing-a-polkadot-parachain-with-zombienet-important-steps-to-follow">Testing a Polkadot Parachain with Zombienet: Important steps to follow</h2>
<p>Testing of a Parachain involves multiple steps, such as unit testing, benchmarking, runtime check, and debugging. With Zombienet test network, you can easily test a Parachain on several parameters to see if it functions as expected. Further, you can easily make changes to your Parachain setup (if required) because Zombienet creates a configurable local test network, which makes testing and optimization easy and simple.</p>
<figure class="wp-block-image size-large"><a href="https://app.zeeve.io/auth/signup?serviceURL=https://app.zeeve.io/parachains"><img src="https://www.zeeve.io/wp-content/uploads/2024/01/Launch-your-Parachain-in-few-clicks-with-Zeeves-Sandbox-1024x130.jpg" alt="" class="wp-image-56038"/></a></figure>
<p>For this guide, we will discuss two different ways of testing Parachain with Zombienet— the CLI method and low-code, automated process with Zeeve’s Larch.</p>
<p>However, as we know that Zombienet simulates a Parachain or Relay chain network once it is developed, considering all the configurations and parameters. Building a Parachain can be complex, engineering-intensive, and time consuming. Now, you can deploy your modular Parachain with ‘Wrench’— a no-code tool, optimized to launch custom Polkadot and Kusama Parachain devnet within few clicks. Learn more about Wrench <a href="https://www.zeeve.io/blog/zeeve-launched-wrench-a-tool-for-launching-polkadot-and-kusama-parachain-devnet-in-just-a-few-clicks/">here</a>.</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2495f4nb86j35vle9sby.png)
<p>Now, it’s time to discuss the step-by-step process of testing Polkadot with Zombienet CLI tool:</p>
<p><strong>Option 1:&nbsp; Creating test network with Zombienet CLI</strong></p>
<p><strong>The Objective:&nbsp;</strong></p>
<p>Creating a local testnet environment– Rococo with the following:</p>
<li>Two validators; Alice and Bob.</li>
<li>One Parachain.</li>
<li>One collator.&nbsp;</li>
<p><strong>Step:1 Getting the required binaries</strong></p>
<p>Zombienet CLI is compatible with binaries, Kubernetes, docker, and <a href="https://github.com/paritytech/zombienet#requirements-by-provider">more</a>. For this article, let’s setup Zombienet for using binaries.</p>
<p>For this, you first need to create a <strong><em>bin </em></strong>folder that will hold your binaries. Use the below command for this:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>mkdir bin&nbsp;</code></pre>
<p>The first binary you need is Polkadot, which will spin up the relay chain.&nbsp;</p>
<p>Use the following command to clone the Polkadot:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>git clone <strong>https</strong>://github.com/paritytech/polkadot</code></pre>
<p>cd to the repository and checkout the latest Polkadot’s release and compile it, use the below command for this:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>git checkout release-v0.9.32
cargo build -release</code></pre>
<p>That’s done! You have a Polkadot binary now.</p>
<p>Next, you need substrate-parachain-template binary that will spin up the Parachains:</p>
<p>Use the following command to clone substrate-parachain-template binary:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>git clone <strong>https</strong>://github.com/substrate-developer-hub/substrate-parachain-template</code></pre>
<p><em>cd </em>into the repo, check latest Polkadot release, and then compile:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>git checkout polkadot-v0.9.32
cargo build -release</code></pre>
<p>Now, you have a Parachain collator binary. Copy this binary to your bin folder, use the below command:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>cp ./target/release/parachain-template-node ../bin/parachain-template-node-v0.9.32</code></pre>
<p>&nbsp;Now that you have all the required binaries, let’s create a Zombienet network.&nbsp;</p>
<p><strong>Step:2 Setting up local test network with Zombienet</strong></p>
<p>A Zombienet network requires configuration. Hence, you need to create a configuration file– .toml file.</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>touch config.toml</code></pre>
<p>Basically, we are defining a local Rococo network with two validators and a Parachain. Both these validators will use default image, argos, and commands. Below is the example of .toml file:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>&#91;relaychain]
default_image = "docker.io/parity/polkadot:latest"
default_command = "polkadot"
default_args = &#91; "-lparachain=debug" ]

chain = "rococo-local"

&nbsp; &#91;&#91;relaychain.nodes]]
&nbsp; name = "alice"
&nbsp; validator = true

&nbsp; &#91;&#91;relaychain.nodes]]
&nbsp; name = "bob"
&nbsp; validator = true

&#91;&#91;parachains]]
id = 100

&nbsp; &#91;parachains.collator]
&nbsp; name = "collator01"
&nbsp; image = "docker.io/parity/polkadot-parachain:latest"
&nbsp; command = "polkadot-parachain"
&nbsp; args = &#91;"-lparachain=debug"]</code></pre>
<p>If you are using Kubernetes, spawn the network simply by using:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>./zombienet-linux -p kubernetes spawn examples/0001-small-network.toml</code></pre>
<p>Or simpler, because Kubernets is the default provider:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>./zombienet-linux spawn examples/0001-small-network.toml</code></pre>
<p>Now, you will see that zombienet starts creating the resources needed to launch the network. Therefore, a list of nodes will appear at the end, allowing you to connect to any of the nodes.&nbsp;</p>
<p><strong>Option 2:&nbsp; Creating test network with Zeeve’s Larch-&nbsp; Zombienet automation tool (the low-code way)</strong></p>
<p>Larch is a innovative GUI frontend designed to automate creation, management, and testing process of Zombienet network. Using Larch’s comprehensive dashboard, developers can quickly setup relay chains and parachains just in a few clicks, with no need of manually writing command lines or creating .toml or .yaml files.&nbsp;</p>

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/quc0zdc1btxkwbtfu9xn.png)
<p>Below is a step-by-step process of creating local test network with Zombienet. While these steps are curated for Linux OS,&nbsp; you can refer to <a href="https://www.zeeve.io/blog/zeeve-launched-wrench-a-tool-for-launching-polkadot-and-kusama-parachain-devnet-in-just-a-few-clicks/">Larch’s prerequisites</a> for using Mac.</p>
<p><strong>Step:1</strong> Get the Larch binary first. You can download it from release or build from scratch by yourself.</p>
<p><strong>Step:2</strong> Install Podman/Kubectl as per the instructions as it will allow orchestration of Zombinet network.</p>
<p><strong>Step:3</strong> Assign execute permission to Larch binary, use the below command:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>chmod 755 larch</code></pre>
<p>Run Larch binary using this command:</p>
<pre class="wp-block-code has-background" style="background-color:#f7f7f7;font-size:16px"><code>./larch</code></pre>
<p><strong>Step:4</strong> Navigate to http://localhost:9000 and click on ‘Network Template’ button given at the top.</p>
<p><strong>Step:5 </strong>Label this template as ‘sample template’ (or whatever you want). Here, you can choose Podman or Kubernetes based on your setup. Click ‘Next’ to continue.</p>
<p><strong>Step 6: </strong>&nbsp;Head to the <strong>Relaychain Configuration</strong> to populate the <strong>Nodes </strong>subsection. Add “alice” as name and then select the ‘Validator’ option. Press + button,&nbsp; to add a new node. Insert “bob” as name and choose&nbsp; ‘Validator’. Again, Press Next.</p>
<p><strong>Step 7: </strong>Move to the Parachain Configuration an tap on the ‘+‘ button. Set the Parachain ID to 100 (or a number of your choice). Name the collator as “collator01” and ‘polkadot-parachain’ as command. Click ‘Next’ to continue.</p>
<p><strong>Step 8</strong>: For this tutorial, we are skipping HRMP. Hence, click ‘Next’.</p>
<p><strong>Step 9:</strong> In the Test Configuration section, you can make required configurations in the pre-filled sections and store the template by clicking at ‘Save’.</p>
<p><strong>Step10</strong>: Go to the Templates page and select ‘Create’ to initiate the network creation. A dialogue box will pop up where you need to input the network’s name and ‘Confirm’ to start the orchestration. Now,&nbsp; Larch will transition you to the networks page while the network is in the creation state.</p>
<p><strong>Step 11:</strong> Tap on ‘Eye” icon to inspect commands and execution logs. Also, you can&nbsp; click ‘Command’ button to see detailed command and metadata. To see logs/outputs, click the ‘Output’ button, which will open another modal revealing the streams.&nbsp;</p>
<p>Upon this, Zombienet network creation will be completed.</p>
<p><strong>Step 12: </strong>Also, you can see metrics of your deployed network from ‘My Network’ page by tapping on the ‘Monitoring’ icon. You will be redirected to the Grafana service. Now, open the dashboard from ‘General’ folder and inspect metrics.<br>Learn more about Larch’s features <a href="https://www.zeeve.io/blog/zeeves-larch-polkadot-substrate-zombienet-automation-and-monitoring-with-an-intuitive-gui-tool/">here</a>.</p>
<h2 id="h-let-s-wrap-up">Let’s wrap up!</h2>
<p>As discussed, creating a Zombienet network via the traditional method involves writing commands and compiling JSON, .yaml, and .toml files. This will demand time, resource, and development expertise. With Larch, developers get a GUI interface for Zombienet creation that enables quick simulation and configuration of the local Parachain testing network in a few clicks. If you want to gather more details about Larch or other Zeeve’s solutions like <a href="https://www.zeeve.io/blog/zeeve-launched-wrench-a-tool-for-launching-polkadot-and-kusama-parachain-devnet-in-just-a-few-clicks/">Wrench </a>or <a href="https://www.zeeve.io/appchains/polygon-zkrollups/">Polygon CDK</a>, feel free to <a href="https://www.zeeve.io/talk-to-an-expert/">connect with our experts</a>. You can schedule one-to-one meeting with them or drop us your queries via email on this page.</p>