Skip to content

Commit 171a528

Browse files
committed
update configuration documents
1 parent a93ec15 commit 171a528

3 files changed

Lines changed: 81 additions & 20 deletions

File tree

common/src/main/resources/reference.conf

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,18 @@ node {
434434

435435
## Rate limiter config
436436
rate.limiter = {
437-
# Strategies: GlobalPreemptibleAdapter, QpsRateLimiterAdapter, IPQPSRateLimiterAdapter
438-
# Default: QpsRateLimiterAdapter with qps=1000
439-
437+
# Each HTTP servlet and gRPC method can have its own rate-limit strategy.
438+
# Three blocking strategies are available:
439+
# GlobalPreemptibleAdapter – limits maximum concurrent requests globally.
440+
# paramString = "permit=N" (N = max concurrent calls)
441+
# QpsRateLimiterAdapter – limits average QPS across all callers.
442+
# paramString = "qps=N" (N may be a decimal)
443+
# IPQPSRateLimiterAdapter – limits average QPS per source IP.
444+
# paramString = "qps=N" (N may be a decimal)
445+
# If no strategy is configured for an endpoint, QpsRateLimiterAdapter with
446+
# qps=1000 is applied automatically.
447+
448+
# Per-servlet HTTP rate limits. component is the servlet class simple name.
440449
http = [
441450
# {
442451
# component = "GetNowBlockServlet",
@@ -455,6 +464,7 @@ rate.limiter = {
455464
# }
456465
]
457466

467+
# Per-method gRPC rate limits. component is "package.ServiceName/MethodName".
458468
rpc = [
459469
# {
460470
# component = "protocol.Wallet/GetBlockByLatestNum2",
@@ -474,14 +484,20 @@ rate.limiter = {
474484
]
475485

476486
p2p = {
477-
syncBlockChain = 3.0
478-
fetchInvData = 3.0
479-
disconnect = 1.0
487+
# QPS ceiling for individual P2P message types received from peers.
488+
# Values are doubles; fractional QPS is allowed (e.g. 0.5 = one per 2 s).
489+
syncBlockChain = 3.0 # SyncBlockChain handshake messages
490+
fetchInvData = 3.0 # FetchInvData (block/tx fetch) messages
491+
disconnect = 1.0 # Disconnect messages
480492
}
481493

494+
# Node-wide QPS ceiling across all HTTP + gRPC requests combined.
482495
global.qps = 50000
496+
# Per-source-IP QPS ceiling across all HTTP + gRPC requests from that IP.
483497
global.ip.qps = 10000
498+
# Default per-endpoint QPS limit applied to any endpoint with no explicit strategy.
484499
global.api.qps = 1000
500+
# true = reject over-limit requests immediately; false = queue and block the caller.
485501
apiNonBlocking = false
486502
}
487503

@@ -522,7 +538,21 @@ seed.node = {
522538
]
523539
}
524540

541+
## Genesis block config
542+
# WARNING: All nodes in the same network must have identical genesis.block settings.
543+
# Any change here produces a different genesis block hash and creates an incompatible chain.
525544
genesis.block = {
545+
# Pre-allocated accounts created at block 0, before any transactions are processed.
546+
# Fields:
547+
# accountName – human-readable label stored on-chain; must not be blank
548+
# accountType – one of: Normal, AssetIssue, Contract
549+
# address – Base58Check-encoded account address (T...)
550+
# balance – initial balance in SUN (1 TRX = 1,000,000 SUN); stored as String
551+
# to accommodate values that exceed Integer range
552+
# Mainnet special accounts:
553+
# Zion – holds the initial circulating supply (99,000,000,000 TRX = 99×10¹⁵ SUN)
554+
# Sun – the founding account; starts at 0
555+
# Blackhole – receives burned TRX; initialized to Long.MIN_VALUE so it can only increase
526556
assets = [
527557
{
528558
accountName = "Zion"
@@ -544,6 +574,12 @@ genesis.block = {
544574
}
545575
]
546576

577+
# Initial Super Representatives at block 0.
578+
# Fields:
579+
# address – Base58Check-encoded SR address (T...)
580+
# url – SR's public URL (informational only, stored on-chain)
581+
# voteCount – initial vote count; seeds SR ranking before any user votes are cast
582+
# The 27 witnesses with the highest voteCount produce the first round of blocks.
547583
witnesses = [
548584
{
549585
address: THKJYuUmMKKARNf7s2VT51g5uPY6KEqnat,
@@ -682,8 +718,13 @@ genesis.block = {
682718
}
683719
]
684720

721+
# Genesis block timestamp in milliseconds since Unix epoch. Must be >= 0.
722+
# Stored as a numeric String to accommodate Long-range values.
685723
timestamp = "0"
686724

725+
# Hash of the genesis block's conceptual parent. This is a fixed sentinel value
726+
# embedded in the genesis block header; changing it changes the genesis block hash
727+
# and therefore the chain identity.
687728
parentHash = "0xe58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f"
688729
}
689730

docs/configuration-conventions.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ A HOCON key named `isOpenFullTcpDisconnect` produces the setter `setIsOpenFullTc
8181

8282
## Nesting Depth
8383

84-
The CI gate enforces a hard ceiling of **5 levels** (the historical maximum in `reference.conf`). New parameters must stay within **3 levels** from the top-level section. The gap between 3 and 5 is reserved for legacy paths that already exist — it is not a license to add new deep keys.
84+
The CI gate enforces a hard ceiling of **5 levels** (the historical maximum in `reference.conf`). New parameters should stay within **3 levels** from the top-level section. The gap between 3 and 5 is reserved for legacy paths that already exist — it is not a license to add new deep keys.
8585

8686
```
8787
level 1: node { ... }
@@ -93,6 +93,22 @@ level 6+: rejected by CI gate unconditionally
9393

9494
Each level of nesting requires a corresponding inner static bean class. If you find yourself going beyond 3 levels deep, consider flattening by moving the leaf keys up one level or using a longer camelCase key at level 2.
9595

96+
## Configuration Loading Order
97+
98+
java-tron loads configuration in two layers at startup:
99+
100+
```
101+
Priority (highest wins):
102+
1. User config file — passed via -c; replaces the bundled config.conf entirely
103+
2. reference.conf — always loaded from inside the jar; provides defaults for every key
104+
```
105+
106+
When a user passes `-c /path/to/node.conf`, the bundled `config.conf` is **not loaded at all** — it is completely replaced by the user's file. `reference.conf` is the only built-in file that is guaranteed to be read in every deployment.
107+
108+
When `-c` is omitted (development or quick-start), the bundled `config.conf` fills the same role a user file would: it overrides `reference.conf` defaults for the keys it declares.
109+
110+
The practical consequence for developers: **the default value you put in `reference.conf` is the value every production node uses.** The bundled `config.conf` only matters for users who start the node without `-c`.
111+
96112
## Adding a New Parameter: Checklist
97113

98114
When adding a configuration parameter, all four steps are required in the same commit.
@@ -137,6 +153,8 @@ if (myNewOption > 64) {
137153

138154
`config.conf` (in `framework/src/main/resources/`) is the sample user config shipped with the distribution. Only add your new key there if the value users should start with differs from the `reference.conf` default, or if the key needs a visible comment for users.
139155

156+
Remember: in any real deployment the user passes `-c` and the bundled `config.conf` is bypassed entirely (see [Configuration Loading Order](#configuration-loading-order)). `reference.conf` is where your default actually takes effect — make sure it is safe and correct before touching `config.conf`.
157+
140158
## Field Types and HOCON Value Types
141159

142160
| Java field type | HOCON value | Notes |

docs/configuration.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
This guide explains the two-layer configuration system used by java-tron and walks through the most common customizations a node operator needs.
44

5-
## How the Two Config Files Work Together
5+
## How Configuration Files Work Together
66

7-
java-tron uses [Typesafe Config](https://github.com/lightbend/config) and applies two layers of configuration at startup:
7+
java-tron uses [Typesafe Config](https://github.com/lightbend/config) and applies configuration in priority order at startup:
88

99
| File | Location | Purpose |
1010
|------|----------|---------|
1111
| `reference.conf` | Bundled inside the jar (`common` module) | Declares every parameter with its default value |
12-
| `config.conf` | Bundled template, optionally edited & passed via -c | Overrides only the values that differ from defaults |
12+
| Bundled `config.conf` | Bundled inside the jar (`framework` module) | Shipped template; active only when `-c` is omitted |
13+
| Your config file (e.g. `node.conf`) | Operator-supplied, passed via `-c` | Overrides values that differ from defaults; replaces the bundled `config.conf` entirely |
1314

14-
**Loading priority:** values in `config.conf` always win. Any parameter that your `config.conf` omits is automatically filled in from `reference.conf`. You never need to copy the entire `reference.conf` into your own file — only include the parameters you actually want to change.
15+
**Loading priority:** values in your config file always win. Any parameter your file omits is automatically filled in from `reference.conf`. You never need to copy the entire `reference.conf` into your own file — only include the parameters you actually want to change.
1516

1617
```
1718
startup resolution order (highest wins):
18-
1. config.conf (your file, passed with -c)
19-
2. reference.conf (bundled in jar, fallback for everything)
19+
1. your config file (passed with -c; replaces bundled config.conf)
20+
2. bundled config.conf (only when -c is omitted)
21+
3. reference.conf (always loaded; fallback for every key)
2022
```
2123

2224
`reference.conf` is the authoritative source of truth for every parameter name and its default. When in doubt, consult that file to see what a parameter does and what value the node will use if you leave it out.
@@ -25,20 +27,20 @@ startup resolution order (highest wins):
2527

2628
```bash
2729
# Using the distribution script
28-
java-tron-1.0.0/bin/FullNode -c /path/to/config.conf
30+
java-tron-1.0.0/bin/FullNode -c /path/to/node.conf
2931

3032
# Using the jar directly
31-
java -jar FullNode.jar -c /path/to/config.conf
33+
java -jar FullNode.jar -c /path/to/node.conf
3234

3335
# SR (Super Representative) mode
34-
java-tron-1.0.0/bin/FullNode -c /path/to/config.conf -w
36+
java-tron-1.0.0/bin/FullNode -c /path/to/node.conf -w
3537
```
3638

3739
If `-c` is omitted, the node loads the `config.conf` bundled inside the jar (the same file shipped with the distribution) merged with `reference.conf` as fallback. The bundled file already enables discovery/persist for mainnet operation. For production, copy it out, edit, and pass the edited copy via `-c` to make your configuration visible to operators.
3840

39-
## Minimal config.conf
41+
## Minimal Config File
4042

41-
A `config.conf` only needs to contain what you want to change. The following is sufficient for a mainnet full node:
43+
Your config file only needs to contain what you want to change. The following is sufficient for a mainnet full node:
4244

4345
```hocon
4446
node.discovery = {
@@ -212,7 +214,7 @@ rate.limiter = {
212214

213215
### Dynamic Config Reload (`node.dynamicConfig`)
214216

215-
When enabled, the node re-reads `config.conf` periodically without restarting:
217+
When enabled, the node re-reads your config file periodically without restarting:
216218

217219
```hocon
218220
node.dynamicConfig = {
@@ -235,7 +237,7 @@ Not all parameters support hot-reload. Parameters that affect node identity, gen
235237

236238
## Applying a Config Change
237239

238-
1. Edit your `config.conf` — only add or change the keys you need.
240+
1. Edit your config file — only add or change the keys you need.
239241
2. If `node.dynamicConfig.enable = true`, wait up to `checkInterval` seconds; the node picks up the change automatically.
240242
3. Otherwise, restart the node: `kill <pid>` then relaunch with the same `-c` flag.
241243
4. Check startup logs for a `[config]` line confirming the file was loaded and watch for any `ERROR` lines about unknown or invalid keys.

0 commit comments

Comments
 (0)