Skip to content

Commit a4aaeca

Browse files
authored
chore: fix outdated content across docs/ and root-level docs (tronprotocol#6662)
* docs: update outdated content across all six doc files
1 parent f0a8f0f commit a4aaeca

10 files changed

Lines changed: 122 additions & 361 deletions

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ We would like all developers to follow a standard development flow and coding st
147147
2. Review the code before submission.
148148
3. Run standardized tests.
149149
150-
`Sonar`-scanner and `Travis CI` continuous integration scanner will be automatically triggered when a pull request has been submitted. When a PR passes all the checks, the **java-tron** maintainers will then review the PR and offer feedback and modifications when necessary. Once adopted, the PR will be closed and merged into the `develop` branch.
150+
`Sonar`-scanner and CI checks (GitHub Actions) will be automatically triggered when a pull request has been submitted. When a PR passes all the checks, the **java-tron** maintainers will then review the PR and offer feedback and modifications when necessary. Once adopted, the PR will be closed and merged into the `develop` branch.
151151
152152
We are glad to receive your pull requests and will try our best to review them as soon as we can. Any pull request is welcome, even if it is for a typo.
153153
@@ -161,7 +161,7 @@ Please make sure your submission meets the following code style:
161161
- The code must have passed the Sonar scanner test.
162162
- The code has to be pulled from the `develop` branch.
163163
- The commit message should start with a verb, whose initial should not be capitalized.
164-
- The commit message should be less than 50 characters in length.
164+
- The commit message title should be between 10 and 72 characters in length.
165165
166166
167167
@@ -196,7 +196,7 @@ The message header is a single line that contains succinct description of the ch
196196
The `scope` can be anything specifying place of the commit change. For example: `framework`, `api`, `tvm`, `db`, `net`. For a full list of scopes, see [Type and Scope Reference](#type-and-scope-reference). You can use `*` if there isn't a more fitting scope.
197197
198198
The subject contains a succinct description of the change:
199-
1. Limit the subject line, which briefly describes the purpose of the commit, to 50 characters.
199+
1. Limit the subject line, which briefly describes the purpose of the commit, to 72 characters (minimum 10).
200200
2. Start with a verb and use first-person present-tense (e.g., use "change" instead of "changed" or "changes").
201201
3. Do not capitalize the first letter.
202202
4. Do not end the subject line with a period.

build.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

docs/implement-a-customized-actuator-en.md

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ message Transaction {
3636
AccountCreateContract = 0;
3737
TransferContract = 1;
3838
........
39-
SumContract = 52;
39+
SumContract = 60;
4040
}
4141
...
4242
}
4343
```
4444

45-
Then register a function to ensure that gRPC can receive and identify the requests of this contract. Currently, gRPC protocols are all defined in `src/main/protos/api/api.proto`. To add an `InvokeSum` interface in Wallet Service:
45+
Then register a function to ensure that gRPC can receive and identify the requests of this contract. Currently, gRPC protocols are all defined in `src/main/protos/api/api.proto`. First add the import for the new proto file at the top of `api.proto`:
46+
47+
```protobuf
48+
import "core/contract/math_contract.proto";
49+
```
50+
51+
Then add an `InvokeSum` interface in the Wallet service:
4652

4753
```protobuf
4854
service Wallet {
@@ -60,13 +66,11 @@ service Wallet {
6066
```
6167
At last, recompile the modified proto files. Compiling the java-tron project directly will compile the proto files as well, `protoc` command is also supported.
6268

63-
*Currently, java-tron uses protoc v3.4.0. Please keep the same version when compiling by `protoc` command.*
64-
6569
```shell
66-
# recommended
70+
# recommended — also recompiles proto files automatically
6771
./gradlew build -x test
6872

69-
# or build via protoc
73+
# or build via protoc (ensure the protoc version matches the one declared in build.gradle)
7074
protoc -I=src/main/protos -I=src/main/protos/core --java_out=src/main/java Tron.proto
7175
protoc -I=src/main/protos/core/contract --java_out=src/main/java math_contract.proto
7276
protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java_out=src/main/java api.proto
@@ -78,7 +82,11 @@ After compilation, the corresponding .class under the java_out directory will be
7882

7983
For now, the default Actuator supported by java-tron is located in `org.tron.core.actuator`. Creating `SumActuator` under this directory:
8084

85+
> **Note**: The Actuator must be placed in the `org.tron.core.actuator` package. At node startup, `TransactionRegister.registerActuator()` uses reflection to scan that package and auto-discovers every `AbstractActuator` subclass. Each subclass is instantiated once (triggering the `super()` constructor which calls `TransactionFactory.register()`), so no manual registration code is needed.
86+
8187
```java
88+
import static org.tron.core.config.Parameter.ChainConstant.TRANSFER_FEE;
89+
8290
public class SumActuator extends AbstractActuator {
8391

8492
public SumActuator() {
@@ -210,48 +218,47 @@ At last, run a test class to validate whether the above steps are correct:
210218
```java
211219
public class SumActuatorTest {
212220
private static final Logger logger = LoggerFactory.getLogger("Test");
213-
private String serviceNode = "127.0.0.1:50051";
214-
private String confFile = "config-localtest.conf";
215-
private String dbPath = "output-directory";
216-
private TronApplicationContext context;
217-
private Application appTest;
218-
private ManagedChannel channelFull = null;
219-
private WalletGrpc.WalletBlockingStub blockingStubFull = null;
221+
private static final String SERVICE_NODE = "127.0.0.1:50051";
222+
223+
@ClassRule
224+
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
225+
226+
@Rule
227+
public Timeout timeout = new Timeout(30, TimeUnit.SECONDS);
228+
229+
private static TronApplicationContext context;
230+
private static Application appTest;
231+
private static ManagedChannel channelFull;
232+
private static WalletGrpc.WalletBlockingStub blockingStubFull;
220233

221234
/**
222-
* init the application.
235+
* init the application once for all tests in this class.
223236
*/
224-
@Before
225-
public void init() {
226-
CommonParameter argsTest = Args.getInstance();
227-
Args.setParam(new String[]{"--output-directory", dbPath},
228-
confFile);
237+
@BeforeClass
238+
public static void init() throws IOException {
239+
Args.setParam(new String[]{"--output-directory",
240+
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
229241
context = new TronApplicationContext(DefaultConfig.class);
230-
RpcApiService rpcApiService = context.getBean(RpcApiService.class);
231242
appTest = ApplicationFactory.create(context);
232-
appTest.addService(rpcApiService);
233-
appTest.initServices(argsTest);
234-
appTest.startServices();
235243
appTest.startup();
236-
channelFull = ManagedChannelBuilder.forTarget(serviceNode)
244+
channelFull = ManagedChannelBuilder.forTarget(SERVICE_NODE)
237245
.usePlaintext()
238246
.build();
239247
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
240248
}
241249

242250
/**
243-
* destroy the context.
251+
* destroy the context after all tests finish.
244252
*/
245-
@After
246-
public void destroy() throws InterruptedException {
253+
@AfterClass
254+
public static void destroy() throws InterruptedException {
247255
if (channelFull != null) {
248-
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
256+
channelFull.shutdown();
257+
channelFull.awaitTermination(5, TimeUnit.SECONDS);
249258
}
250-
Args.clearParam();
251-
appTest.shutdownServices();
252259
appTest.shutdown();
253260
context.destroy();
254-
FileUtil.deleteDir(new File(dbPath));
261+
Args.clearParam();
255262
}
256263

257264
@Test

docs/implement-a-customized-actuator-zh.md

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ message Transaction {
3838
AccountCreateContract = 0;
3939
TransferContract = 1;
4040
........
41-
SumContract = 52;
41+
SumContract = 60;
4242
}
4343
...
4444
}
4545
```
4646

47-
然后还需要注册一个方法来保证 gRPC 能够接收并识别该类型合约的请求,目前 gRPC 协议统一定义在 src/main/protos/api/api.proto,在 api.proto 中的 Wallet Service 新增 `InvokeSum` 接口:
47+
然后还需要注册一个方法来保证 gRPC 能够接收并识别该类型合约的请求,目前 gRPC 协议统一定义在 src/main/protos/api/api.proto。首先在 `api.proto` 顶部添加对新 proto 文件的 import:
48+
49+
```protobuf
50+
import "core/contract/math_contract.proto";
51+
```
52+
53+
然后在 Wallet service 中新增 `InvokeSum` 接口:
4854

4955
```protobuf
5056
service Wallet {
@@ -62,13 +68,11 @@ service Wallet {
6268
```
6369
最后重新编译修改过 proto 文件,可自行编译也可直接通过编译 java-tron 项目来编译 proto 文件:
6470

65-
*目前 java-tron 采用的是 protoc v3.4.0,自行编译时确保 protoc 版本一致。*
66-
6771
```shell
68-
# recommended
72+
# 推荐方式 —— 直接编译项目,proto 文件会自动重新编译
6973
./gradlew build -x test
7074

71-
# or build via protoc
75+
# 或者手动使用 protoc(版本需与 build.gradle 中声明的一致)
7276
protoc -I=src/main/protos -I=src/main/protos/core --java_out=src/main/java Tron.proto
7377
protoc -I=src/main/protos/core/contract --java_out=src/main/java math_contract.proto
7478
protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java_out=src/main/java api.proto
@@ -80,7 +84,11 @@ protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java
8084

8185
目前 java-tron 默认支持的 Actuator 存放在该模块的 org.tron.core.actuator 目录下,同样在该目录下创建 `SumActuator`
8286

87+
> **注意**:Actuator 必须放在 `org.tron.core.actuator` 包下。节点启动时,`TransactionRegister.registerActuator()` 会通过反射扫描该包,自动发现所有 `AbstractActuator` 的子类,并各实例化一次(触发 `super()` 构造器,进而调用 `TransactionFactory.register()`)。因此无需手动编写注册代码。
88+
8389
```java
90+
import static org.tron.core.config.Parameter.ChainConstant.TRANSFER_FEE;
91+
8492
public class SumActuator extends AbstractActuator {
8593

8694
public SumActuator() {
@@ -212,48 +220,47 @@ public class WalletApi extends WalletImplBase {
212220
```java
213221
public class SumActuatorTest {
214222
private static final Logger logger = LoggerFactory.getLogger("Test");
215-
private String serviceNode = "127.0.0.1:50051";
216-
private String confFile = "config-localtest.conf";
217-
private String dbPath = "output-directory";
218-
private TronApplicationContext context;
219-
private Application appTest;
220-
private ManagedChannel channelFull = null;
221-
private WalletGrpc.WalletBlockingStub blockingStubFull = null;
223+
private static final String SERVICE_NODE = "127.0.0.1:50051";
224+
225+
@ClassRule
226+
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
227+
228+
@Rule
229+
public Timeout timeout = new Timeout(30, TimeUnit.SECONDS);
230+
231+
private static TronApplicationContext context;
232+
private static Application appTest;
233+
private static ManagedChannel channelFull;
234+
private static WalletGrpc.WalletBlockingStub blockingStubFull;
222235

223236
/**
224-
* init the application.
237+
* 整个测试类只初始化一次应用上下文。
225238
*/
226-
@Before
227-
public void init() {
228-
CommonParameter argsTest = Args.getInstance();
229-
Args.setParam(new String[]{"--output-directory", dbPath},
230-
confFile);
239+
@BeforeClass
240+
public static void init() throws IOException {
241+
Args.setParam(new String[]{"--output-directory",
242+
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
231243
context = new TronApplicationContext(DefaultConfig.class);
232-
RpcApiService rpcApiService = context.getBean(RpcApiService.class);
233244
appTest = ApplicationFactory.create(context);
234-
appTest.addService(rpcApiService);
235-
appTest.initServices(argsTest);
236-
appTest.startServices();
237245
appTest.startup();
238-
channelFull = ManagedChannelBuilder.forTarget(serviceNode)
246+
channelFull = ManagedChannelBuilder.forTarget(SERVICE_NODE)
239247
.usePlaintext()
240248
.build();
241249
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
242250
}
243251

244252
/**
245-
* destroy the context.
253+
* 所有测试结束后统一销毁上下文。
246254
*/
247-
@After
248-
public void destroy() throws InterruptedException {
255+
@AfterClass
256+
public static void destroy() throws InterruptedException {
249257
if (channelFull != null) {
250-
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
258+
channelFull.shutdown();
259+
channelFull.awaitTermination(5, TimeUnit.SECONDS);
251260
}
252-
Args.clearParam();
253-
appTest.shutdownServices();
254261
appTest.shutdown();
255262
context.destroy();
256-
FileUtil.deleteDir(new File(dbPath));
263+
Args.clearParam();
257264
}
258265

259266
@Test

docs/modular-deployment-en.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# How to deploy java-tron after modularization
22

3-
After modularization, java-tron is launched via shell script instead of typing command: `java -jar FullNode.jar`.
3+
After modularization, the recommended way to launch java-tron is via the shell script generated in `bin/`. The classic `java -jar FullNode.jar` command is still fully supported as an alternative.
44

5-
*`java -jar FullNode.jar` still works, but will be deprecated in future*.
5+
> **Supported platforms**: Linux and macOS. Windows is not supported.
66
77
## Download
88

@@ -29,7 +29,7 @@ After unzip, two directories will be generated in java-tron: `bin` and `lib`, sh
2929

3030
## Startup
3131

32-
Use the corresponding script to start java-tron according to the OS type, use `*.bat` on Windows, Linux demo is as below:
32+
Use the shell script to start java-tron (Linux / macOS):
3333
```
3434
# default
3535
java-tron-1.0.0/bin/FullNode
@@ -45,12 +45,11 @@ java-tron-1.0.0/bin/FullNode -c config.conf -w
4545

4646
JVM options can also be specified, located in `bin/java-tron.vmoptions`:
4747
```
48-
# demo
49-
-XX:+UseConcMarkSweepGC
48+
# demo (compatible with JDK 8 / JDK 17)
49+
-Xms2g
50+
-Xmx9g
5051
-XX:+PrintGCDetails
5152
-Xloggc:./gc.log
5253
-XX:+PrintGCDateStamps
53-
-XX:+CMSParallelRemarkEnabled
5454
-XX:ReservedCodeCacheSize=256m
55-
-XX:+CMSScavengeBeforeRemark
5655
```

0 commit comments

Comments
 (0)