Skip to content

Commit 512cd16

Browse files
Little-Peonyclaude
andcommitted
docs: update outdated content across all six doc files
implement-a-customized-actuator (EN+ZH): - Fix test lifecycle: @Before/@after → @BeforeClass/@afterclass so the Spring context is created only once per test class, not per test method - Fix Args initialization order: Args.setParam() must be called before Args.getInstance() to avoid passing a stale unconfigured instance to appTest.initServices() - Replace hardcoded dbPath with @ClassRule TemporaryFolder to keep test directories isolated and auto-cleaned - Add @rule Timeout to guard against hangs - Remove the specific protoc v3.4.0 version note; point readers to the version declared in build.gradle instead modular-deployment (EN+ZH): - Replace CMS GC flags (-XX:+UseConcMarkSweepGC, -XX:+CMSParallelRemarkEnabled, -XX:+CMSScavengeBeforeRemark) that were removed in JDK 14 and would cause startup failures on JDK 17 (required for ARM64) - Add -Xms/-Xmx to the example and note JDK 8/17 compatibility modular-introduction (EN+ZH): - Update module count from six to eight - Add descriptions for the crypto and plugins modules Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3ab5adf commit 512cd16

6 files changed

Lines changed: 78 additions & 62 deletions

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

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@ service Wallet {
6060
```
6161
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.
6262

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

69-
# or build via protoc
67+
# or build via protoc (ensure the protoc version matches the one declared in build.gradle)
7068
protoc -I=src/main/protos -I=src/main/protos/core --java_out=src/main/java Tron.proto
7169
protoc -I=src/main/protos/core/contract --java_out=src/main/java math_contract.proto
7270
protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java_out=src/main/java api.proto
@@ -210,48 +208,52 @@ At last, run a test class to validate whether the above steps are correct:
210208
```java
211209
public class SumActuatorTest {
212210
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;
211+
private static final String SERVICE_NODE = "127.0.0.1:50051";
212+
213+
@ClassRule
214+
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
215+
216+
@Rule
217+
public Timeout timeout = new Timeout(30, TimeUnit.SECONDS);
218+
219+
private static TronApplicationContext context;
220+
private static Application appTest;
221+
private static ManagedChannel channelFull;
222+
private static WalletGrpc.WalletBlockingStub blockingStubFull;
220223

221224
/**
222-
* init the application.
225+
* init the application once for all tests in this class.
223226
*/
224-
@Before
225-
public void init() {
226-
CommonParameter argsTest = Args.getInstance();
227-
Args.setParam(new String[]{"--output-directory", dbPath},
228-
confFile);
227+
@BeforeClass
228+
public static void init() throws IOException {
229+
Args.setParam(new String[]{"--output-directory",
230+
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
229231
context = new TronApplicationContext(DefaultConfig.class);
230232
RpcApiService rpcApiService = context.getBean(RpcApiService.class);
231233
appTest = ApplicationFactory.create(context);
232234
appTest.addService(rpcApiService);
233-
appTest.initServices(argsTest);
235+
appTest.initServices(Args.getInstance());
234236
appTest.startServices();
235237
appTest.startup();
236-
channelFull = ManagedChannelBuilder.forTarget(serviceNode)
238+
channelFull = ManagedChannelBuilder.forTarget(SERVICE_NODE)
237239
.usePlaintext()
238240
.build();
239241
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
240242
}
241243

242244
/**
243-
* destroy the context.
245+
* destroy the context after all tests finish.
244246
*/
245-
@After
246-
public void destroy() throws InterruptedException {
247+
@AfterClass
248+
public static void destroy() throws InterruptedException {
247249
if (channelFull != null) {
248-
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
250+
channelFull.shutdown();
251+
channelFull.awaitTermination(5, TimeUnit.SECONDS);
249252
}
250-
Args.clearParam();
251253
appTest.shutdownServices();
252254
appTest.shutdown();
253255
context.destroy();
254-
FileUtil.deleteDir(new File(dbPath));
256+
Args.clearParam();
255257
}
256258

257259
@Test

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

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ service Wallet {
6262
```
6363
最后重新编译修改过 proto 文件,可自行编译也可直接通过编译 java-tron 项目来编译 proto 文件:
6464

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

71-
# or build via protoc
69+
# 或者手动使用 protoc(版本需与 build.gradle 中声明的一致)
7270
protoc -I=src/main/protos -I=src/main/protos/core --java_out=src/main/java Tron.proto
7371
protoc -I=src/main/protos/core/contract --java_out=src/main/java math_contract.proto
7472
protoc -I=src/main/protos/api -I=src/main/protos/core -I=src/main/protos --java_out=src/main/java api.proto
@@ -212,48 +210,52 @@ public class WalletApi extends WalletImplBase {
212210
```java
213211
public class SumActuatorTest {
214212
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;
213+
private static final String SERVICE_NODE = "127.0.0.1:50051";
214+
215+
@ClassRule
216+
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
217+
218+
@Rule
219+
public Timeout timeout = new Timeout(30, TimeUnit.SECONDS);
220+
221+
private static TronApplicationContext context;
222+
private static Application appTest;
223+
private static ManagedChannel channelFull;
224+
private static WalletGrpc.WalletBlockingStub blockingStubFull;
222225

223226
/**
224-
* init the application.
227+
* 整个测试类只初始化一次应用上下文。
225228
*/
226-
@Before
227-
public void init() {
228-
CommonParameter argsTest = Args.getInstance();
229-
Args.setParam(new String[]{"--output-directory", dbPath},
230-
confFile);
229+
@BeforeClass
230+
public static void init() throws IOException {
231+
Args.setParam(new String[]{"--output-directory",
232+
temporaryFolder.newFolder().toString()}, "config-localtest.conf");
231233
context = new TronApplicationContext(DefaultConfig.class);
232234
RpcApiService rpcApiService = context.getBean(RpcApiService.class);
233235
appTest = ApplicationFactory.create(context);
234236
appTest.addService(rpcApiService);
235-
appTest.initServices(argsTest);
237+
appTest.initServices(Args.getInstance());
236238
appTest.startServices();
237239
appTest.startup();
238-
channelFull = ManagedChannelBuilder.forTarget(serviceNode)
240+
channelFull = ManagedChannelBuilder.forTarget(SERVICE_NODE)
239241
.usePlaintext()
240242
.build();
241243
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
242244
}
243245

244246
/**
245-
* destroy the context.
247+
* 所有测试结束后统一销毁上下文。
246248
*/
247-
@After
248-
public void destroy() throws InterruptedException {
249+
@AfterClass
250+
public static void destroy() throws InterruptedException {
249251
if (channelFull != null) {
250-
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
252+
channelFull.shutdown();
253+
channelFull.awaitTermination(5, TimeUnit.SECONDS);
251254
}
252-
Args.clearParam();
253255
appTest.shutdownServices();
254256
appTest.shutdown();
255257
context.destroy();
256-
FileUtil.deleteDir(new File(dbPath));
258+
Args.clearParam();
257259
}
258260

259261
@Test

docs/modular-deployment-en.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
-Xms256m
50+
-Xmx4g
5051
-XX:+PrintGCDetails
5152
-Xloggc:./gc.log
5253
-XX:+PrintGCDateStamps
53-
-XX:+CMSParallelRemarkEnabled
5454
-XX:ReservedCodeCacheSize=256m
55-
-XX:+CMSScavengeBeforeRemark
5655
```

docs/modular-deployment-zh.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ java-tron-1.0.0/bin/FullNode -c config.conf -w
4343

4444
java-tron 支持对 jvm 参数进行配置,配置文件为 bin 目录下的 java-tron.vmoptions 文件。
4545
```
46-
# demo
47-
-XX:+UseConcMarkSweepGC
46+
# demo(兼容 JDK 8 / JDK 17)
47+
-Xms256m
48+
-Xmx4g
4849
-XX:+PrintGCDetails
4950
-Xloggc:./gc.log
5051
-XX:+PrintGCDateStamps
51-
-XX:+CMSParallelRemarkEnabled
5252
-XX:ReservedCodeCacheSize=256m
53-
-XX:+CMSScavengeBeforeRemark
5453
```

docs/modular-introduction-en.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The aim of java-tron modularization is to enable developers to easily build a de
1616

1717
![modular-structure](https://github.com/tronprotocol/java-tron/blob/develop/docs/images/module.png)
1818

19-
A modularized java-tron consists of six modules: framework, protocol, common, chainbase, consensus and actuator. The function of each module is elaborated below.
19+
A modularized java-tron consists of eight modules: framework, protocol, common, chainbase, consensus, actuator, crypto and plugins. The function of each module is elaborated below.
2020

2121
### framework
2222

@@ -67,4 +67,11 @@ Actuator module defines the `Actuator` interface, which includes 4 different met
6767
4. calcFee: define the logic of calculating transaction fees
6868

6969
Depending on their businesses, developers may set up Actuator accordingly and customize the processing of different types of transactions.
70-
70+
71+
### crypto
72+
73+
Crypto module encapsulates cryptographic primitives used across the project, including elliptic curve key operations, hash functions and signature verification. It depends only on `common` and has no dependency on other business modules, keeping cryptographic logic isolated and auditable.
74+
75+
### plugins
76+
77+
Plugins module provides standalone operational tools packaged as independent executable JARs, such as `Toolkit.jar` and `ArchiveManifest.jar`. These tools support database maintenance tasks like migration, compaction and lite-node data pruning, and can be run without starting a full node.

docs/modular-introduction-zh.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ java-tron 模块化的目的是为了帮助开发者方便地构建出特定应
1414

1515
![modular-structure](https://github.com/tronprotocol/java-tron/blob/develop/docs/images/module.png)
1616

17-
模块化后的 java-tron 目前分为6个模块:framework、protocol、common、chainbase、consensus、actuator,下面分别简单介绍一下各个模块的作用。
17+
模块化后的 java-tron 目前分为8个模块:framework、protocol、common、chainbase、consensus、actuator、crypto、plugins,下面分别简单介绍一下各个模块的作用。
1818

1919
### framework
2020

@@ -65,4 +65,11 @@ actuator模块定义了 Actuator 接口,该接口有4个方法:
6565
4. calcFee: 定义交易手续费计算逻辑
6666

6767
开发者可以根据自身业务实现 Actuator 接口,就能实现自定义交易类型的处理。
68-
68+
69+
### crypto
70+
71+
crypto 模块封装了项目中使用的密码学原语,包括椭圆曲线密钥操作、哈希函数及签名验证等。该模块仅依赖 `common`,不依赖其他业务模块,保持密码学逻辑的独立性与可审计性。
72+
73+
### plugins
74+
75+
plugins 模块提供独立的运维工具,打包为可单独执行的 JAR(如 `Toolkit.jar``ArchiveManifest.jar`)。这些工具支持数据库迁移、压缩、轻节点数据裁剪等维护任务,无需启动完整节点即可运行。

0 commit comments

Comments
 (0)