How to set up a Tosi node

This section explains how to set up, run, and verify Tosi nodes. Before you begin, reading Introduction to Tosi is highly recommended.

Objectives

  • Set up Tosi node

  • Run and verify Tosi node

Prerequisites

Setting up

Before running the node, you must set up the following:

  1. Clone Tosi repo from GitHub

git clone https://github.com/tosichain/tosi -b stable
  1. Navigate to the tosi folder

cd tosi
  1. Update and initialize all submodules

git submodule update --recursive --init

Starting and running a node

After successfully completing the setup steps outlined above, you can begin running the Mainnet node by executing the following commands:

Build containers

docker compose --profile build -p tosi-chain -f docker-compose-tosi-node-mainnet.yml build

Generate key

To generate your private key, run the commands below:

docker run tosi-chain-client-base node genkey.mjs

Next, create an .env file at the root directory, and add the following line: TOSI_CLIENT_BLS_SEC_KEY=xxxxxxxxx, where xxxxxxxxx is the BLS_SEC_KEY you generated above.

Starting the node

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml up --wait --detach

Once all the services have started up, they should report a status of 'Healthy'. If any of the services fail to start up, you can use the 'docker logs' to investigate and diagnose the issue.

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml logs

To stop the node from running, use the command below:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml down

Node sync status

After all the services are running successfully, you can check the node sync status by running the command:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts status

After, the output will look like this example:

Node Health: Healthy
Head Block Hash: f19c5cc8c809f5a914674f8853010c589fbe3923437716a43d6a3717b07759a6
BLS Public Key: a17b78d31f4ca698e353bf1a2ff3eb10a4d6fd9967140ae30b787c049d4dece5de2f5f2aada3f3752b1370ec5453bf37
Node Sync Status: Synced

Test token/staking

Send your BLS Public Key output to get test tokens on our Discord channel. Staking on TosichainTestnet

You can choose to stake as either a DA verifier or a State verifier. As a DA verifier, you're in a waiting position to be selected for two tasks: to confirm if the data is accessible (data availability), and to compute the Merkle tree roots for the data. To stake, run the command:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts stake DAVerifier <amount> <nonce>

Replace <amount> with the number of tokens you want to stake, and <nonce> with your account's nonce value incremented by 1.

And to unstake, use the command:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts unstake DAVerifier <amount> <nonce>

Alternatively, if you stake as a State verifier, your role involves downloading the necessary data, executing calculations on this data, and standing ready to confirm the validity of your results if challenged.

To stake as a state verifier, run:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts stake StateVerifier <amount> <nonce>

And to unstake, run:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts unstake StateVerifier <amount> <nonce>

You can check your account balance and the status of your stake by running this command:

docker compose -p tosi-chain -f docker-compose-tosi-node-mainnet.yml exec client npx ts-node --files src/tosi-cli.ts balance <address>

Replace <address> with your BLS public key

Last updated