Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ libs/
metric_monitor/datadir
private_net/datadir
tron-docker.iml
bin/
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ repos:
- repo: 'https://github.com/jumanjihouse/pre-commit-hooks'
rev: 3.0.0
hooks:
- id: shellcheck
- id: script-must-have-extension
- id: git-dirty
- id: git-check
- repo: 'https://github.com/koalaman/shellcheck-precommit'
rev: v0.7.2
hooks:
- id: shellcheck
- repo: local # check java files format use a customized script
hooks:
- id: checkstyle
Expand Down
29 changes: 18 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
tron-docker is an open-source project designed to facilitate the usage of the TRON network. We understand that there is much left to be desired, and if you see any room for improvement, please let us know. Thank you. All contributed code will be covered by the [LGPLv3 license](https://github.com/tronprotocol/tron-docker/blob/main/LICENSE) of this project.

Here are some guidelines to get started quickly and easily:
- [Before contribution](#Before-contribution)
- [Contribute to tron-docker](#Contribute-to-tron-docker)
- [Key Branches](#Key-Branches)
- [Submitting Code Steps](#Submitting-Code-Steps)
- [Commit Messages](#Commit-Messages)
- [Branch Naming Conventions](#Branch-Naming-Conventions)
- [Pull Request Best Practise](#Pull-request-best-practise)
- [Special Situations And How To Deal With Them](#Special-Situations-And-How-To-Deal-With-Them)
- [Conduct](#Conduct)
- [Contributing](#contributing)
- [Before contribution](#before-contribution)
- [Ask a question](#ask-a-question)
- [Reporting an issue](#reporting-an-issue)
- [Request a feature](#request-a-feature)
- [Contribute to tron-docker](#contribute-to-tron-docker)
- [Key branches](#key-branches)
- [Submitting code steps](#submitting-code-steps)
- [Fork then make changes](#fork-then-make-changes)
- [Linting](#linting)
- [Push code](#push-code)
- [Commit messages](#commit-messages)
- [Branch naming conventions](#branch-naming-conventions)
- [Pull request best practise](#pull-request-best-practise)
- [Special situations and how to deal with them](#special-situations-and-how-to-deal-with-them)
- [Conduct](#conduct)

## Before contribution

Expand Down Expand Up @@ -94,7 +101,7 @@ Commit the new branch to your personal remote repository.

#### Linting

tron-docker CI uses [pre-commit](https://pre-commit.com/) to lint all code within the repo. Add it to your local following the [installation](https://pre-commit.com/#installation). Check [.pre-commit-config.yaml](.pre-commit-config-fix.yaml) for existing validators.
tron-docker CI uses [pre-commit](https://pre-commit.com/) to lint all code within the repo. Add it to your local following the [installation](https://pre-commit.com/#installation). And ensure ShellCheck is also installed, refer to [installation](https://github.com/koalaman/shellcheck?tab=readme-ov-file#installing). Check [.pre-commit-config.yaml](.pre-commit-config-fix.yaml) for existing validators.

#### Push code

Expand Down Expand Up @@ -148,7 +155,7 @@ Here is an example:
```
fix(private_net): update docker-compose

1. fix docker-compose container tron_node1 command paramters, add more JVM GC flags
1. fix docker-compose container tron-node1 command paramters, add more JVM GC flags
2. update the corresponding JVM flags explanation in README.md

Closes #1234
Expand Down
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,54 @@
# TRON Docker

This repository provides guidance and tools for the community to quickly get started with TRON network and development.
This repository provides tools and guidance to help the community quickly get started with the TRON network and development.

## Features

### Quick start for single FullNode
### 🚀 Quick start for single FullNode
Easily deploy a single TRON FullNode connected to **Mainnet** or **Nile testnet** using Docker. Follow the instructions to get your node up and running in minutes.

This repository includes Docker configurations to quickly start a single TRON FullNode connected to the Mainnet or NileNet. Simply follow the instructions to get your node up and running in no time.
### 🔗 Private chain setup
Set up your own private TRON blockchain network for development and testing. The provided configurations simplify deployment and management, making it ideal for custom use cases.

### Private chain setup

You can also use this repository to set up a private TRON blockchain network. This is useful for development and testing purposes. The provided configurations make it straightforward to deploy and manage your own private chain.

### Node monitoring with Prometheus and Grafana

Monitoring the health and performance of your TRON nodes is made easy with integrated Prometheus and Grafana services. The repository includes configurations to set up these monitoring tools, allowing you to visualize and track various metrics in real time.

### Tools
### 📊 Node monitoring with Prometheus and Grafana
Monitor the health and performance of your TRON nodes with integrated **Prometheus** and **Grafana** services. Real-time metrics and visualizations are just a few steps away.

### 🛠️ Tools
We also provide tools to facilitate the CI and testing process:
- Gradle Docker: Using Gradle to automate the build and test processes for java-tron image.
- DB Fork: This tool helps launch a private Java-Tron network based on the state of the Mainnet database to support shadow fork testing.
- **Gradle Docker**: Automate the build and testing of the `java-tron` Docker image using Gradle.
- **DBFork**: Launch a private java-tron network based on the Mainnet database state, enabling shadow fork testing.

## Getting Started

### Prerequisites

- Docker
- Docker Compose

### Installation
### Start the services
First clone the repository:

```sh
git clone https://github.com/tronprotocol/tron-docker.git
cd tron-docker
```

1. **Clone the repository:**
```sh
git clone https://github.com/tronprotocol/tron-docker.git
cd tron-docker
```
Then, navigate to the relevant directory and follow the instructions in the respective README to start the services:
- **TRON network deployment related:**
- **Single FullNode**: Use the [single_node](./single_node) folder.
- **Private TRON network**: Use the [private_net](./private_net) folder.
- **Node monitoring**: Use the [metric_monitor](./metric_monitor) folder.

2. **Start the services:**
Navigate to the corresponding directory and follow the instructions in the respective README. Then you can easily start the services.
- To start a single FullNode, use the folder [single_node](./single_node).
- To set up a private TRON network, use the folder [private_net](./private_net).
- To monitor the TRON node, use the folder [metric_monitor](./metric_monitor).
- To use Gradle with Docker, check [gradle docker](./tools/docker/README.md).
- To do shadow fork testing, check [db fork guidance](./tools/dbfork/README.md).
- **Tools**:
- **Gradle Docker**: Automate Docker image builds and testing. Check the [gradle docker](./tools/docker/README.md) documentation.
- **DBFork**: Perform shadow fork testing. Follow the [DBFork guidance](./tools/dbfork/README.md).

## Troubleshooting
If you encounter any difficulties, please refer to the [Issue Work Flow](https://tronprotocol.github.io/documentation-en/developers/issue-workflow/#issue-work-flow), then raise an issue on [GitHub](https://github.com/tronprotocol/tron-docker/issues). For general questions, please use [Discord](https://discord.gg/cGKSsRVCGm) or [Telegram](https://t.me/TronOfficialDevelopersGroupEn).

# Contributing
## Contributing

All contributions are welcome. Check [contribution](CONTRIBUTING.md) for more details.

# License
## License

This repository is released under the [LGPLv3 license](https://github.com/tronprotocol/tron-docker/blob/main/LICENSE).
6 changes: 3 additions & 3 deletions conf/main_net_config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ node {
isOpenFullTcpDisconnect = false

p2p {
version = 11111 # 11111: mainnet; 20180622: testnet
version = 11111 # 11111: Mainnet; 20180622: Nile testnet
}

active = [
Expand Down Expand Up @@ -660,8 +660,8 @@ vm = {
}

committee = {
allowCreationOfContracts = 0 //mainnet:0 (reset by committee),test:1
allowAdaptiveEnergy = 0 //mainnet:0 (reset by committee),test:1
allowCreationOfContracts = 0 //Mainnet:0 (reset by committee),test:1
allowAdaptiveEnergy = 0 //Mainnet:0 (reset by committee),test:1
}

event.subscribe = {
Expand Down
4 changes: 2 additions & 2 deletions conf/nile_net_config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ vm = {
}

committee = {
allowCreationOfContracts = 0 //mainnet:0 (reset by committee),test:1
allowAdaptiveEnergy = 0 //mainnet:0 (reset by committee),test:1
allowCreationOfContracts = 0 //Mainnet:0 (reset by committee),test:1
allowAdaptiveEnergy = 0 //Mainnet:0 (reset by committee),test:1
}

event.subscribe = {
Expand Down
8 changes: 4 additions & 4 deletions conf/private_net_config_others.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ node {
isOpenFullTcpDisconnect = true

p2p {
version = 1 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
version = 1 # 11111: Mainnet; 20180622: Nile testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
}

active = [
Expand Down Expand Up @@ -198,9 +198,9 @@ seed.node = {
# "ip:port",
# ]
ip.list = [
# used for docker deployment, to connect container named in tron_witness, defined in docker-compose.yml
"tron_witness1:18888",
#"tron_witness2:18888",
# used for docker deployment, to connect container named in tron-witness, defined in docker-compose.yml
"tron-witness1:18888",
#"tron-witness2:18888",

# used for local deployment
"127.0.0.1:18888"
Expand Down
2 changes: 1 addition & 1 deletion conf/private_net_config_witness1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ node {
isOpenFullTcpDisconnect = true

p2p {
version = 1 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
version = 1 # 11111: Mainnet; 20180622: Nile testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
}

active = [
Expand Down
4 changes: 2 additions & 2 deletions conf/private_net_config_witness2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ node {
isOpenFullTcpDisconnect = true

p2p {
version = 1 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
version = 1 # 11111: Mainnet; 20180622: Nile testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net.
}

active = [
Expand Down Expand Up @@ -196,7 +196,7 @@ seed.node = {
# "ip:port"
# ]
ip.list = [
"tron_witness1:18888",
"tron-witness1:18888",
]
}

Expand Down
5 changes: 2 additions & 3 deletions metric_monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Download the `tron-docker` repository, enter the `metric` directory, and start t
```sh
docker-compose up -d
```
Then check the Docker resource settings to ensure it has at least 16GB of memory.
It will start a TRON FullNode that connects to the Mainnet, along with Prometheus and Grafana services. Note that in [main_net_config.conf](../conf/main_net_config.conf), it contains the configuration below to enable metrics.
```
metrics{
Expand All @@ -34,7 +33,7 @@ metrics{
The Prometheus service will use the configuration file [prometheus.yml](metric_conf/prometheus.yml). It uses the configuration below to add targets for monitoring.
```
- targets:
- tron_node1:9527 # use container name
- tron-node1:9527 # use container name
labels:
group: group-tron
instance: fullnode-01
Expand All @@ -45,7 +44,7 @@ You can view the running status of the Prometheus service at `http://localhost:9

If you want to monitor more nodes, simply add more targets following the same format. Click on "Status" -> "Targets" to view the status of each monitored java-tron node.
![image](../images/prometheus_targets.png)
**Notice**: If you want to check metrics, please use `http://localhost:9527/metrics` on host machine instead of `http://tron_node1:9527/metrics`, as the latter is used for container access inside Docker.
**Notice**: If you want to check metrics, please use `http://localhost:9527/metrics` on host machine instead of `http://tron-node1:9527/metrics`, as the latter is used for container access inside Docker.

### Grafana service
After startup, you can log in to the Grafana web UI through [http://localhost:3000/](http://localhost:3000/). The initial username and password are both `admin`. After logging in, change the password according to the prompts, and then you can enter the main interface.
Expand Down
4 changes: 2 additions & 2 deletions metric_monitor/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3.8'
services:
tron_node1:
tron-node1:
image: tronprotocol/java-tron:latest
container_name: tron_node1
container_name: tron-node1
networks:
- tron_network
deploy:
Expand Down
15 changes: 10 additions & 5 deletions metric_monitor/metric_conf/grafana_dashboard_tron_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -1479,17 +1479,22 @@
"pluginVersion": "11.4.0",
"targets": [
{
"exemplar": true,
"expr": " rate(tron:block_generate_latency_seconds_sum{group=`$group`,instance=`$instance`,sync =\"false\"}[$__interval])\n/\n rate(tron:block_generate_latency_seconds_count{group=`$group`,instance=`$instance`,sync =\"false\"}[$__interval])",
"editorMode": "code",
"exemplar": false,
"expr": " rate(tron:block_generate_latency_seconds_sum{group=`$group`,instance=`$instance`}[$__interval])\n/\n rate(tron:block_generate_latency_seconds_count{group=`$group`,instance=`$instance`}[$__interval])",
"format": "time_series",
"hide": false,
"interval": "1m",
"legendFormat": "avg",
"interval": "12s",
"legendFormat": "__auto",
"range": true,
"refId": "B"
},
{
"editorMode": "code",
"exemplar": true,
"expr": "histogram_quantile(0.99, sum(rate(tron:block_generate_latency_seconds_bucket{group=`$group`,instance=`$instance`,sync =\"false\"}[$__interval])) by (le))",
"expr": "histogram_quantile(0.99, sum(rate(tron:block_generate_latency_seconds_bucket{group=`$group`,instance=`$instance`}[$__interval])) by (le))",
"format": "time_series",
"hide": false,
"instant": false,
"interval": "1m",
"intervalFactor": 1,
Expand Down
4 changes: 2 additions & 2 deletions metric_monitor/metric_conf/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ scrape_configs:
follow_redirects: true
static_configs:
- targets:
- tron_node1:9527 # use container name
- tron-node1:9527 # use container name
labels:
group: group-tron
instance: fullnode-01
# - targets: # to add more fullnodes
# - tron_node2:9527
# - tron-node2:9527
# labels:
# group: group-tron
# instance: fullnode-01
25 changes: 14 additions & 11 deletions private_net/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A private chain needs at least one fullnode run by a [Super Representative (SR)]

### Minimum hardware requirements
- CPU with 8+ cores
- 32GB RAM
- 16GB RAM
- 100GB free storage space

### Docker
Expand All @@ -18,7 +18,10 @@ Please download and install the latest version of Docker from the official Docke
* Docker Installation for [Windows](https://docs.docker.com/docker-for-windows/install/)
* Docker Installation for [Linux](https://docs.docker.com/desktop/setup/install/linux/)

Then check the Docker resource settings to ensure it has at least 12GB of memory per TRON node.
Then check the Docker resource settings to ensure it has at least 3GB of memory per TRON node.

**Notice:** The actual memory consumption for a FullNode depends heavily on your configurations and use case. Factors such as block generation frequency, transactions per second (TPS), and external API request QPS can significantly impact memory usage. To help you get started quickly, the memory consumption under the following guidance should remain below **3GB**. However, for a TRON Mainnet Super Representative (SR) FullNode capable of supporting **2000 TPS**, the maximum memory consumption can reach up to **12GB**.


## Quick-Start using Docker
Download the folder [private_net](../private_net) from GitHub. Enter the directory and run the docker-composer.
Expand All @@ -30,7 +33,7 @@ A TRON private network will be started with one [SR](https://tronprotocol.github

Check the witness logs by running the command below:
```
docker exec -it tron_witness1 tail -f ./logs/tron.log
docker exec tron-witness1 tail -f ./logs/tron.log
```
Normally, it should show the witness initializing the database and network, then starting to produce blocks every 3 seconds.
```
Expand All @@ -47,18 +50,18 @@ Peer stats: channels 1, activePeers 1, active 0, passive 1

Check the other fullnode logs by running the command below:
```
docker exec -it tron_node1 tail -f ./logs/tron.log
docker exec tron-node1 tail -f ./logs/tron.log
```
After initialization, it should show messages about syncing blocks, just following the SR.

**What docker-compose do?**

Check the docker-compose.yml, the two container services use the same TRON image with different configurations.

- `ports`: Used in the tron_witness1 service are exposed for API requests to interact with the TRON private network.
- `ports`: Used in the tron-witness1 service are exposed for API requests to interact with the TRON private network.

- `command`: Used for java-tron image start-up arguments.
- `-jvm` is used for Java Virtual Machine parameters, which must be enclosed in double quotes and braces. `"{-Xmx16g -Xms12g}"` sets the maximum heap size to 16GB.
- `-jvm` is used for Java Virtual Machine parameters, which must be enclosed in double quotes and braces. `"{-Xmx12g -Xms3g}"` sets the maximum and minimum heap size to 12GB and 3GB.
- `-c` defines the configuration file to use.
- `-d` defines the database file to use. By mounting a local data directory, it ensures that the block data is persistent.
- `-w` means to start as a witness. You need to fill the `localwitness` field with private keys in the configuration file. Refer to [**Run as Witness**](https://tronprotocol.github.io/documentation-en/using_javatron/installing_javatron/#startup-a-fullnode-that-produces-blocks).
Expand All @@ -69,15 +72,15 @@ If you want to add more witness or other syncing fullnodes, you need to make bel

**Add more services in docker-compose.yml**

Inside the docker-compose.yml, refer to the commented containers `tron_witness2` and `tron_node2`. Make sure the configuration files are changed accordingly, following the details below.
Inside the docker-compose.yml, refer to the commented containers `tron-witness2` and `tron-node2`. Make sure the configuration files are changed accordingly, following the details below.

**Common settings**

For all configurations, you need to set `node.p2p.version` to the same value and `node.discovery.enable = true`.
```
node {
p2p {
version = 1 # 11111: mainnet; 20180622: nilenet; others for private networks.
version = 1 # 11111: Mainnet; 20180622: Nile testnet; others for private networks.
}
...
}
Expand Down Expand Up @@ -144,9 +147,9 @@ Then, in other configuration files, add witness `container_name:port` to connect
```
seed.node = {
ip.list = [
# used for docker deployment, to connect containers in tron_witness defined in docker-compose.yml
"tron_witness1:18888",
"tron_witness2:18888",
# used for docker deployment, to connect containers in tron-witness defined in docker-compose.yml
"tron-witness1:18888",
"tron-witness2:18888",
...
]
}
Expand Down
Loading