Setup Local Development
Set up a local development environment for the truf.network.
To set up a local development environment for the truf.network, follow these steps:
Prerequisites
Ensure the following tools are installed on your system:
- Go: Download and install Go.
- Taskfile: Install Taskfile.
- Docker Compose: Install Docker Compose.
- Python (optional, for running seed scripts): Download Python.
- Pandas (optional, for running seed scripts): Install Pandas.
Building Locally
You can build and run the TRUF-Node using Docker Compose or manually.
Using Docker Compose (Recommended)
- Clone the TSN repository:
- Build and start the TRUF-Node containers:
This command builds and starts the TRUF-Node in Docker containers with pre-seeded data.
Manual Build and Run
- Build the Binary:
This compiles the TRUF-Node binary, which will be located in the .build/
directory.
- Run PostgreSQL:
Start PostgreSQL using Docker:
- Run TRUF-Node:
Start a single-node network:
- Configure
kwil-cli
:
Set up kwil-cli
to interact with TRUF-Node:
Provide the following values when prompted:
- Kwil RPC URL:
http://localhost:8484
- Kwil Chain ID: (leave blank)
- Private Key: (any Ethereum private key)
For testing purposes, you can use the private key 0000000000000000000000000000000000000000000000000000000000000001
.
Running the Kwil Gateway (Optional)
The Kwil Gateway (KGW) is a load-balancer with authentication capabilities, enabling data privacy protection for Proof of Authority (POA) Kwil blockchain networks. While not required for development, you can run it locally:
- Navigate to the
deployments/dev-gateway
directory:
- Follow the instructions in the README.md file to set up and run the gateway.
Running the Indexer
The indexer collects and processes data from the TSN-DB. To start the indexer:
Access the metrics dashboard at http://localhost:1337/v0/swagger
.
Fetching the Genesis File
The genesis file contains the initial configuration for the TSN network. To fetch the latest genesis file:
- Ensure you have read access to the repository.
- Create a
.env
file in the root directory, similar to.env.example
, and include your GitHub token. - Run the following command:
System Contract
The system contract stores accepted streams by TSN governance and serves as an entry point for queries.
Fetching Records via System Contract
To fetch records:
This command retrieves records from the system contract for the specified stream and data provider within the given date range.
Metrics and Monitoring
When running the development setup using task compose-dev
, the following monitoring tools are available:
- Prometheus: Accessible at
http://localhost:9090
- Grafana: Accessible at
http://localhost:3000
(default credentials:admin/admin
)
These tools provide insights into the performance and behavior of the TSN-DB system.
For more details on metrics configuration, refer to the files in the deployments/dev-gateway
directory.
Additional Resources
For further assistance, join our Discord community or open an issue on our GitHub repository.