Skip to content

Commit ab7225f

Browse files
fix: harden start.sh (#7003)
1 parent 0504f45 commit ab7225f

4 files changed

Lines changed: 566 additions & 452 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ The java-tron project comes with several runnable artifacts and helper scripts f
8282
| **`FullNode.jar`** | Main TRON node executable (generated in `build/libs/` after a successful build following the above guidance). Runs as a full node by default. `java -jar FullNode.jar --help` for command line options|
8383
| **`Toolkit.jar`** | Node management utility (generated in `build/libs/`): partition, prune, copy, convert DBs; shadow-fork tool. [Usage](https://tronprotocol.github.io/documentation-en/using_javatron/toolkit/#toolkit-a-java-tron-node-maintenance-suite) |
8484
| **`p2p-standalone.jar`** | Peer discovery, connection management and DNS-based node lists (generated in `build/libs/`). See the [p2p guide](./p2p/README.md). |
85-
| **`start.sh`** | Quick start script (x86_64, JDK 8) to download/build/run `FullNode.jar`. See the tool [guide](./shell.md). |
86-
| **`start.sh.simple`** | Quick start script template (ARM64, JDK 17). See usage notes inside the script. |
85+
| **`start.sh`** | Quick start script to download/build/run `FullNode.jar` on x86_64 (JDK 8) and ARM64 (JDK 17). See the tool [guide](./shell.md). |
8786

8887
# Running java-tron
8988

@@ -246,6 +245,7 @@ Thank you for considering to help out with the source code! If you'd like to con
246245
pub: 1254 F859 D2B1 BD9F 66E7 107D F859 BCB4 4A28 290B
247246
uid: build@tron.network
248247
```
248+
- `start.sh` only accepts release jars signed by this key, whose fingerprint is written into the script. This protects against tampered release files, but not against a compromise of this repository, which hosts both the script and the release files: a `start.sh` taken from a compromised repository could carry a different fingerprint.
249249

250250
# License
251251

‎shell.md‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ If you already downloaded the `FullNode.jar`, you can use `start.sh` to run it,
88

99
The script is available in the java-tron project at [github](https://github.com/tronprotocol/java-tron), or if you need a separate script: [start.sh](https://github.com/tronprotocol/java-tron/blob/develop/start.sh)
1010

11+
The script runs on x86_64 with JDK 8 and on ARM64 with JDK 17. It picks the JVM options for the Java version it finds, and downloads the release jars built for that architecture (`FullNode-aarch64.jar` on ARM64).
12+
13+
Downloaded release jars are verified against the GPG signature published with each release, made by the key listed under "Integrity Check" in the [README](./README.md), so `gpg` must be installed; a jar that fails verification is not used. The mainnet config is downloaded from java-tron and the Nile testnet config from [nile-testnet](https://github.com/tron-nile-testnet/nile-testnet).
14+
15+
For each download the release key is fetched by its fingerprint from keys.openpgp.org, or from keyserver.ubuntu.com if the first server does not answer, so installing a release jar needs outbound HTTPS access (port 443) to one of these key servers. If neither can be reached, the signature cannot be checked and the downloaded jar is removed.
16+
1117
***
1218

1319
# Usage
@@ -32,6 +38,8 @@ The script is available in the java-tron project at [github](https://github.com/
3238
sh start.sh --stop
3339
```
3440

41+
`--run` records the process id in `<jar name>.pid` (`FullNode.jar.pid` by default) next to `start.log`, and `--stop` reads it. Run `--stop` in the directory the node was started from, with the same `-j` name if one was given. After `--release` or `-cb` the node runs in `FullNode/`; `--stop` finds it there from the parent directory as well. A node started by an earlier version of the script (a `start.log` but no pid file) is still found by its jar name.
42+
3543
* Get the latest version of `FullNode.jar` and start it
3644

3745
```
@@ -58,17 +66,21 @@ The script is available in the java-tron project at [github](https://github.com/
5866

5967
start the service
6068

61-
* `--stop`
69+
* `--stop` or `-s`
70+
71+
stop the service started from the current directory
6272

63-
stop the service
73+
* `--`
74+
75+
Everything after it is passed to `FullNode.jar` unchanged. Options the script does not know are passed on as well, so `--` is only needed when a value of such an option looks like a script option or a jar name.
6476

6577
* `-c`
6678

67-
Specify the configuration file, by default it will load the `config.conf` in the same directory as `FullNode.jar`
79+
Specify the configuration file, by default it will load the `config.conf` in the current directory
6880

6981
* `-d`
7082

71-
Specify the database storage path, The default path is the same directory where `FullNode.jar` is located.
83+
Specify the database storage path. The default is `output-directory` in the directory the script is run from (`FullNode/` after `--release` or `-cb`).
7284

7385
* `-j`
7486

@@ -79,7 +91,7 @@ The script is available in the java-tron project at [github](https://github.com/
7991
Specify the maximum memory of the `FullNode.jar` service in`MB`, jvm's startup maximum memory will be adjusted according to this parameter.
8092

8193
* `--net`
82-
Select test and private networks.
94+
Select test (Nile) and private networks.
8395

8496
### build project
8597

@@ -91,6 +103,14 @@ The script is available in the java-tron project at [github](https://github.com/
91103

92104
Get the latest released version of the `jar` package from github.
93105

106+
* `--upgrade`
107+
108+
Replace the local `jar` package with the latest release; the previous one is kept as `FullNode.jar_bak`.
109+
110+
* `--download`
111+
112+
Download the latest released `jar` package into the current directory without starting it.
113+
94114

95115
### rebuild the manifest
96116

@@ -100,7 +120,7 @@ The script is available in the java-tron project at [github](https://github.com/
100120

101121
* `-m`
102122

103-
specify the minimum required manifest file size ,unit:M,default:0
123+
specify the minimum required manifest file size ,unit:M,default:128
104124

105125
* `-b`
106126

@@ -152,7 +172,7 @@ sh start.sh --stop
152172
Format:
153173

154174
```
155-
sh start.sh <[--release | -cb]> <--run> [-m <manifest size>] | [-b <batch size>] | [-d <db database-directory> | [-dr | --disable-rewrite-manifes]]
175+
sh start.sh <[--release | -cb]> <--run> [-m <manifest size>] | [-b <batch size>] | [-d <db database-directory> | [-dr | --disable-rewrite-manifest]]
156176
```
157177

158178
Get the latest released version.
@@ -162,13 +182,15 @@ Get the latest released version.
162182
sh start.sh --release --run
163183
```
164184

165-
Following file structure will be generated after executing the above command and the `FullNode.jar` will be started.
185+
Following file structure will be generated after executing the above command and the `FullNode.jar` will be started. The node runs from `FullNode/`, so later `--run` commands are executed there with the copied script; `--stop` works both there and from the parent directory.
166186

167187
```
168188
├── ...
169189
├── FullNode/
170190
├── config.conf
171191
├── FullNode.jar
192+
├── FullNode.jar.pid
193+
├── start.log
172194
├── start.sh
173195
```
174196

@@ -214,12 +236,14 @@ Following file structure will be created:
214236
├── FullNode/
215237
|── config.conf
216238
├── FullNode.jar
239+
├── FullNode.jar.pid
240+
├── start.log
217241
├── start.sh
218242
```
219243

220244
### 3. rebuild manifest tool
221245

222-
This tool provides the ability to reformat the manifest based on current database, Enabled by default.
246+
This tool provides the ability to reformat the manifest based on current database, Enabled by default. It applies to LevelDB only and is skipped on ARM64, which runs RocksDB.
223247

224248
1.Local mode:
225249

0 commit comments

Comments
 (0)