Multi-Node Testnet
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
Please follow to build smartbchd
, the executable of smartBCH's full node client.
The above command generates one private key. And the corresponding EOA address is 0xF0c6969C2a554ddae639ba1Aa1d2fA11382CAb2B
.
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
.
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.
The genesis-generator will send you a tarball named dot.smartbchd.tgz, which contains the initial content for the data directory.
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 .
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.
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.
Collect the p2p seeds information and modify the ~/dot.smartbchd/config/config.toml
file.
Make a tarball:
Then send this dot.smartbchd.tgz file to all the other nodes.
You can also join in an already-running smartBCH chain as a 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.
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.
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.
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.
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.
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.
Just finish the steps 0-5 as .
Run the step 6 and 7 as .
Someone must vote for your validator to make it active in a future epoch. If you are using , the voting for new validator can be started using the following command: