Testnet for simulations
An EcoMobiCoin testnet can be easily created with a minimum of 2 nodes from the truite
client.
A set of tools were built to facilitate the simulations, but to correctly leverage them for your simulation you need to have precise goals for testnet. One could ask himself:
- Is the network open or closed i.e. can unknown nodes join or not?
- Do you want to run it on your computer or several servers?
- Will you inject simulation data in it? Behaviors? Transactions? Both?
Tools
To send transactions and behaviors, mine and more:
To view blocks, transactions and behaviors:
For demo purposes:
- example-app to make a tx or bx from a browser and wallet e.g. MetaMask
- Tickets API for transportation demo
Please note all local & simulation testnets have the same chain ID 636363
. You can update it in .ron
files or use another id.
Methods
CLI
See https://gitlab.limos.fr/ecomobicoin/truite/-/releases for all available versions (or build the project yourself)
You can get a list of all available parameters thanks to truite --help
Example:
truite --chain-spec-file src/res/chainspec/local.ron --rpc-listen-address 0.0.0.0:8545 --no-dns-discovery
More examples: https://gitlab.limos.fr/-/snippets/28
Docker
Image: registry.gitlab.limos.fr/ecomobicoin/truite
docker-compose.yaml
files are available in truite/docker
's network subfolders.
For the demo testnet and from the truite
repo folder:
cd docker/demo
docker compose up
Clean up a testnet
- Backup the node key(s) if you want to further work on it.
- Delete the chaindata folder on every node
Please note that for the node key you can bring your own key as a truite
CMD arg.
CLI
All the data is located in the ecomobicoin-data
. So the node keys will be there.
On macOS (for user=paul): rm -rf /Users/paul/Library/Application\ Support/truite/chaindata
On Linux (for user=paul): rm -rf /home/paul/.local/share/truite/chaindata
Docker
All the data is located in the ecomobicoin-data
. So the node keys will be there.
To delete the chaindata, once the containers stopped, remove the ecomobicoin-data
volume either by running docker compose down -v
or docker volume rm ecomobicoin-data
. Note that this will also delete the keys.
Transport ticket demo
Example of a 2 nodes testnet using docker, with blocks mined thanks to testnet-injector
, end-user's behavior from example-app
and explored with the block-explorer
.
Troubleshooting
When I try to mine I got an RPC error: "not synced"
It means your node is not sync. Either it's a networking issue i.e. you have 0 peers, either your node is a bootnode and didn't do the init sync with block 0.
If you didn't execute the stages with the genesis block (block 0), you need to add the --max-block 0
to your truite
CLI to force the first sync. Once the node is sync you can restart it without the --max-block
arg.
I don't have active peers
2024-02-23T10:16:49.971678Z INFO P2P node peer info: 0 active (+0 dialing) / 100 max.
- Check if the ports are open,
truite
need the port 30303 for peers discovery and 8545 for rpc operations. - Check the bootnodes configuration in your
.ron
spec file. - Use the
static_peers
option, example:
RUST_BACKTRACE=1 RUST_LOG="INFO,truite::stages=debug,truite::trie=debug,truite::state=debug,truite::consensus=debug,truite::rpc=debug"
cargo run -- --chain-spec-file src/res/chainspec/local.ron --rpc-listen-address 0.0.0.0:8545 --no-dns-discovery --no-discovery
--static-peers enode://cd15b75eca40cdc1fe8328cd9a8870583401e2586be00dcd24fae56ea55ef18b6857419d5646e6feb73bd6de0a3028cfafe46c3e5e64e8949b91d81c576de546@0.0.0.0:31303
What is a bootnode ?
A bootnode is responsible for starting the blockchain and act as an archive node. Its network details are specified in the chainspec .ron
file so new nodes can rely on it.