Before any changes are deployed to Symbol mainnet or a new project gets launches on the blockchain, a test version is deployed to testnet first. Symbol test network(testnet) simulates the Symbol main network which gives developers and the community a chance to test features before real assets are used.
Sai Testnet is the current testnet for Symbol. You can add a node and get test tokens from the Faucet. The Faucet allow an account to request up to 10k in test xym. If more token are needed to test or run a voting node, you can be requested from the Symbol's helpdesk on discord. It can be fun to have 3 or 4 million of test xym to splurge a bit, even though they carry no real-world value.
Creating and maintaining a Symbol testnet requires some work like certs and voting key renewals, so why bother setting up your own? These are some reasons you would want to setup your own dev testnet.
Test Scenario - you might want to run specific test scenarios for your application. Let's say you want to fork the network and stall finalization to verify that your application also stops accepting deposits and withdrawals.
Persistence - there is no guarantee that the testnet won't be reset. Symbol testnet is reset at least once a year to keep storage low. But it can also be reset if a major feature stops working. If your application requires the data kept for a longer time then a dev testnet would be better.
Control Funds - your use case might require a large sum of funds like 500 Million xym. Even though there is the Faucet, requesting that much token is best done on dev testnet.
Hardware requirements - using the Symbol testnet requires your node to sync with the blockchain. The storage requirements will be higher than simply rolling our own.
For each Symbol test network, there are one or more properties in the config-network.properties
file which needs to be unique. All the network properties can be found on the Symbol's docs site.
The nemesis block contains the initial accounts and assets that is required to start the network. Some of these accounts will be harvester to create blocks others might be voters to vote on finalization. Below is a network template that describes the accounts in the nemesis.
Note: The host information is not required to create the nemesis seed.
Nemgen needs account address, key pairs and assets to create the nemesis seed. We will create an generator using the Symbol Python SDK. The network generator will read the network template file and creates a new yaml with the required key pairs and assets to create the nemesis.
Below is the main logic for the network generator. A key pair is created for each account which is the main private/public keys. For each role associated with an account, a handler will add the other metadata the required.
The network generator output the yaml file below. I only added the first node since the others are the similar except with different key pairs.
Before we can run the nemgen tool to create the nemesis file, there are couple more things needed.
The Network.yaml has all the information needed to create the nemgen configuration file. The snippet of code below reads the Network yaml into the configuration object. This is then use to generate the nemgen configuration file.
This will create a nemgen configuration below. The main note here is that all the address under the distribution
section, are the main key pair for each account that was created. These addresses will be converted to transfer transactions with the specified amount in the nemesis.
Note: transactionsDirectory
is the folder where the extra transactions to configure the nodes will be stored.
Lets create all the extra transactions(remote, vrf, voting) needed to setup each node and place them in the transactionsDirectory. The trick here is that all the transactions needs to be signed with the generation hash seed of the new network. After creating the facade for Symbol, the network information needs to be updated.
Now that the SymbolFacade is created and updated to use the new network generation hash seed, creating the extra transactions for the nemesis is no different than setting up your current node on the Symbol blockchain.
Note: for transaction in the nemesis, the deadline is 1 and fee is 0.
We are almost ready to run the nemgen. The last step is to update the Symbol node resources. We will create a patcher which updates the config-network.properties file to match the information of the new testnet network.
Note: Only the network config needs to be update for a new testnet. If you want to change any values in any other properties file is fine as long as its valid.
Now we are ready to run the nemgen tool. If you build the catapult client code from scratch, you can find the nemgen in the bin folder. I will take the easy route and run the tool from the latest docker image.
After this is complete the nemesis seed should be in the output folder. This can be used to bootstrap your test network.
Now you have three nodes that can be setup to bootstrap your test network. Each node has
All that is left is to generate configuration for each node. There are tools that does this already like shoestring so won't go over this here in details. But to give an idea of the steps
Your testnet should be up and running in a couple of seconds, which you can confirm by navigating to http://localhost:3000.