You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration-conventions.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,7 +81,7 @@ A HOCON key named `isOpenFullTcpDisconnect` produces the setter `setIsOpenFullTc
81
81
82
82
## Nesting Depth
83
83
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.
85
85
86
86
```
87
87
level 1: node { ... }
@@ -93,6 +93,22 @@ level 6+: rejected by CI gate unconditionally
93
93
94
94
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.
95
95
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
+
96
112
## Adding a New Parameter: Checklist
97
113
98
114
When adding a configuration parameter, all four steps are required in the same commit.
@@ -137,6 +153,8 @@ if (myNewOption > 64) {
137
153
138
154
`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.
139
155
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`.
Copy file name to clipboardExpand all lines: docs/configuration.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,23 @@
2
2
3
3
This guide explains the two-layer configuration system used by java-tron and walks through the most common customizations a node operator needs.
4
4
5
-
## How the Two Config Files Work Together
5
+
## How Configuration Files Work Together
6
6
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:
8
8
9
9
| File | Location | Purpose |
10
10
|------|----------|---------|
11
11
|`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 |
13
14
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.
15
16
16
17
```
17
18
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)
20
22
```
21
23
22
24
`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):
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.
38
40
39
-
## Minimal config.conf
41
+
## Minimal Config File
40
42
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:
42
44
43
45
```hocon
44
46
node.discovery = {
@@ -212,7 +214,7 @@ rate.limiter = {
212
214
213
215
### Dynamic Config Reload (`node.dynamicConfig`)
214
216
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:
216
218
217
219
```hocon
218
220
node.dynamicConfig = {
@@ -235,7 +237,7 @@ Not all parameters support hot-reload. Parameters that affect node identity, gen
235
237
236
238
## Applying a Config Change
237
239
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.
239
241
2. If `node.dynamicConfig.enable = true`, wait up to `checkInterval` seconds; the node picks up the change automatically.
240
242
3. Otherwise, restart the node: `kill <pid>` then relaunch with the same `-c` flag.
241
243
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