Multi-Node Testnet
This document shows how to start a testnet of smartBCH with multiple nodes.
We suggest to use ubuntu 20.04.
Among these nodes, just pick one to generate the genesis file. And all the other nodes do not generate the genesis file, instead, they use the generated genesis file as is.
1. On the nodes which do not generate the genesis file
Step 0: build smartbchd
Please follow this document to build smartbchd
, the executable of smartBCH's full node client.
Step 1: generate the private keys to operate one validator
The above command generates one private key. And the corresponding EOA address is 0xF0c6969C2a554ddae639ba1Aa1d2fA11382CAb2B
.
Step 2: generate genesis validator consensus key info
Now we generate the ed25519 private key for consensus engine:
The output hex string is consensus pubkey which will be used in generate-genesis-validator
command, and a file containing the consensus public and private key is generated under the current directory, named priv_validator_key.json
.
Step 3: generate genesis validator info using pubkey generated above
The validator-address
is the one we get at step 1, and the consensus-pubkey
is the one we get at step 2.
The output hex string contains the information of a validator. Send the this hex string to the node who is genesis-generator.
Step 4: wait for the data directory's tarball and unpack it
The genesis-generator will send you a tarball named dot.smartbchd.tgz, which contains the initial content for the data directory.
Step 5: Copy private key file to data directory and start node
Copy priv_validator_key.json generated in Step 2, to get the data directory:
Now start the node:
For the smartbchd start
command, you can use --mainnet-url
option to specify a bitcoincashnode's RPC endpoint, and use --home
option to specifiy another data directory other than ~/.smartbchd .
Step 6: activate validator
Before you activate your genesis validator, try to get testnet BCH in your validator address, it needs at least
You can ask the genesis-generator to send you some testnet BCH. And you can check your balance with below command (Replace your_validator_address
with your genesis validator address):
After you have enough bch, you can run the following command:
Note: replace the content after --validator-key
with your validator private key, and repace the content after --staking-coin
with 1000000000000000000000
or even more you have.
⚠️Keep your private key safe, and execute this command on a secure, offline machine
Then broadcast the transaction (replace --your_tx_data
with what hex string get above):
Now, you had send an editValidator
transaction to staking contract. Check this transaction's receipt (replace your_tx_hash
with what the hex string you get above):
If the status
is 0x1
, congratulations, your genesis validator is activated now.
2. On the node which generates the genesis file
Step 0: Prepare
Just finish the steps 0-5 as running a single-node testnet.
Step 1: add genesis validator info to genesis.json using hex strings sent by other nodes
Using ./smartbchd add-genesis-validator
multiple times, one time with one hex string sent by one node. Finally you'll include all the validators' information in the genesis.json file.
Then, make a copy of the ~/.smartbchd
directory, excluding the node_key.json
file.
Step 2: start the node
Run the step 6 and 7 as running a single-node testnet.
Step 4: collect seeds information
Collect the p2p seeds information and modify the ~/dot.smartbchd/config/config.toml
file.
Step 5: send information to all the other nodes
Make a tarball:
Then send this dot.smartbchd.tgz file to all the other nodes.
3. Join in as a validator after genesis
You can also join in an already-running smartBCH chain as a new validator.
Step 0: create new validator
Follow the step 0,1,2 described in the above section 1, to get the validator account key and the consensus key. Then, you can use these key information to build command below:
This command will output a hex string to be used in the next step.
Step 1: send transaction to register as a validator
Make sure you have enough BCH in you validator account.
Then broadcast the transaction (replace your_tx_data
with what hex string get above):
OK, now you had send a createValidator
transaction to the staking contract. Check this transaction's receipt (replace your_tx_hash
with what the hex string you get in above command):
If the status
is 0x1
, congratulations, your validator is created now, but it has no voting power now.
Step 2: voting in the BCH mainnet
Someone must vote for your validator to make it active in a future epoch. If you are using a fake BCH node, the voting for new validator can be started using the following command:
Like this: ./pubkey.sh d4849694a7105200464dfc1160c95ed26664b556c3e468b03312ed9ebd937eb4-1-add
If you are using a real BCH node, please use getblocktemplate
to specify the coinbase transaction for voting.
You can also starting voting before registering the validator, which can make sure then it is registered, it gets voting power as soon as possible.
4. Adjust minGasPrice
You can adjust minmum gas price that tx must pay for its gas in smartBCH chain, but only an active validator and its rewardTo address has permission to do this.
Step 0: generate minGasPrice adjust signed rawTx
Follow the step 0,1,2 described in the above section 1, to get the validator account key and the consensus key. Then, you can use these key information to build increase minGasPrice command below:
or decrease minGasPrice command below:
These two command will output a hex string to be used in the next step.
Step 1: send transaction to adjust minGasPrice
Make sure you have enough BCH in you sender account.
Then broadcast the transaction (replace your_tx_data
with what hex string get above):
OK, now you had send a increaseMinGasPrice
transaction to the staking contract. Check this transaction's receipt (replace your_tx_hash
with what the hex string you get in above command):
If the status
is 0x1
, congratulations, your update success.
Last updated