Setting up the Benchmarker
This guide will be using the tig-benchmarker
to spin up a Master node and Slave nodes to benchmark and compute solutions.
Getting Started
Topping Up the Balance
Each challenge has its own base fee, which is the amount of TIG deducted from your Available Fee Balance when initiating a benchmark.
Current base fees:
Challenge | Fee |
---|---|
satisfiability | 0.001 TIG |
vehicle_routing | 0.001 TIG |
knapsack | 0.001 TIG |
vector_search | 0.001 TIG |
Head over to the Main Dashboard and select the Benchmarker tab. For testnet, you can use the Testnet Dashboard.
Accept the terms and conditions and connect your wallet.
Add the TIG Token to your wallet and sign the message. You will now be redirected to the Benchmarker page.
Scroll down to the Base Fees for Benchmarks and top up your balance with 5 TIG.
Making a top-up transaction means that you are burning TIG for paying submission fees. To increase your cutoff, head over to Making Deposits.
You can request for Testnet TIG on Base Sepolia Testnet using the TIG faucet.
Reward Share
Benchmarkers can share a percentage of their rewards with their delegators. The reward share can range from 0% to 25% and can be updated once every 1440 blocks. This is to attract delegators to delegate their deposits to your Benchmarker.
Scroll down to the Reward Share section and set/update your reward share percentage.
Read more about Delegated Deposits.
Benchmarkers can use this script to estimate the impact of delegated deposits on their earnings.
Obtaining the API Key
The API Key can be either obtained from the Main Benchmarker Dashboard or by using the Official API.
To obtain the API Key from the frontend, right click on the page and select Inspect to open up the Inspect tool on your browser.
Navigate to the Console tab and run the following command:
JSON.parse(Cookies.get("account")).api_key
To obtain a testnet API Key, you can head over to the Testnet Dashboard and do the same.
This will return your API Key for the connected wallet address.
If you wish to use the API directly, you can obtain the API Key by making a POST request to the following endpoint:
curl -X 'POST' \
'https://mainnet-api.tig.foundation/request-api-key' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"address": "0x7f1ddd40c04ca1682960155d0b95fdb380456826",
"signature": "0xf9120ef1fb1e95542581c9ea8586dd5ca1b20028e79d6fdac2f450a31de2ddc0b27aac26deb4cce33f44acdc5b15147b7c8e2e75bbb978a69d06dcaacbc2111fbd"
}'
<address>
must be lowercase. The <signature>
must be generated from signing the following message:
I am signing this message to prove that I control address <address>
This will return the API Key for the connected wallet address.
Setting up the Developer Environment
To set up the environment, clone the TIG Monorepo:
git clone https://github.com/tig-foundation/tig-monorepo.git
Switch to the appropriate branch:
git switch main
## OR
git switch blank_slate
Navigate to the tig-monorepo
directory and compile tig-worker
:
cd tig-monorepo
cargo build -p tig-worker --release
Setting up the Master node
The Master node is responsible for managing multiple Slave nodes by generating batches for slaves to work on. It also takes care of the benchmarking process, which includes submitting precommits, benchmarks and proofs.
To start the Master node, make sure you are in the tig-benchmarker
directory and run the following command:
POSTGRES_USER=postgres \
POSTGRES_PASSWORD=password \
POSTGRES_DB=postgres \
UI_PORT=80 \
DB_PORT=5432 \
MASTER_PORT=5115 \
VERBOSE= \
docker-compose up --build
## Set VERBOSE = 1 for debug master logs.
## Set the POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, UI_PORT, DB_PORT, MASTER_PORT to your desired values.
Make sure that Docker is up and running before starting the Master node.
After running the command, you should see the Master node UI running on http://localhost:80
. If you are using a different UI_PORT
, you can access the Master node UI on http://localhost:<UI_PORT>
.
The Master node UI will look like this:
The Master node is responsible for 4 services:
- The main
master
service: The main Master node. Responsible for managing the slave nodes and the benchmarking process. This service by default runs on port5115
. - The
db
service: Responsible for maintaining a local postgres database for your benchmarks and batches. You can use a tool like pgAdmin to query the database. This service by default runs on port5432
. - The
ui
service: Responsible for the user interface of the Master node. This service by default runs on port80
. - The
nginx
service: Responsible for routing the requests to theui
andmaster
.
You can view the logs of each service
individually:
docker-compose logs -f `<service>`
Setting up the Configuration
To configure the benchmarker, head over to your localhost Benchmarker UI’s config page. You can edit the configuration to include your api_key
, player_id
, api_url
and configure other benchmarker settings.
https://mainnet-api.tig.foundation
{
"player_id": "<YOUR_PLAYER_ID>",
"api_key": "<YOUR_API_KEY>",
"api_url": "<TESTNET_OR_MAINNET_API_URL>",
"job_manager_config": {
...
},
"slave_manager_config": {
...
},
"precommit_manager_config": {
...
},
"difficulty_sampler_config": {
...
},
"submissions_manager_config": {
...
}
}
The player_id
is the wallet address of your benchmarker, i.e, the address you used to obtain the API Key and sign the message.
To read more about optimising the configuration, head over to Optimizing Benchmarker Configuration.
Setting up Slave Nodes
The Slave nodes are responsible for benchmarking and computing solutions. Slave node polls the Master node for batches to work on, using tig-worker
to compute solutions and batches.
To connect a Slave node to the Master node, make sure you have the tig-worker
binary compiled and ready.
Install the dependencies for the Slave node:
pip3 install randomname requests
Start the Slave node by running the following command:
python3 slave.py <path-to-tig-worker> --master <master-ip> --workers <number-of-threads>
- The
master-ip
by default should be0.0.0.0
if you are running the Master node on your local machine. You can leave this empty if you are running the Master node on the same machine. path-to-tig-worker
should be the path to thetig-worker
binary, which should be located at should be located attig-monorepo/target/release/tig-worker
.- The
number-of-threads
should be the number of threads you want to run for the Slave node.
The Slave node will now be connected to the Master node and will start polling for batches.
You can head over to the Master node UI to view the latest jobs.
Benchmarkers can use this script to verify batches submitted by slaves.