Skip to content

Commit 3bc50f2

Browse files
committed
style: fix all 18978 checkstyle violations with google-java-format
- Apply google-java-format to all 700 Java files for consistent Google Java Style - Expand star imports to explicit imports across 44 files - Fix overloaded method ordering, empty catch blocks, array type style - Fix broken string literals in long hex/ABI constants - Add missing Assume import for fuzz test files - Enable checkstyle on test sources by removing exclude 'test/**' in lint task - Add develop branch to CI workflow triggers
1 parent def65e4 commit 3bc50f2

695 files changed

Lines changed: 111431 additions & 72152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [main, release_workflow, 'release_**']
5+
branches: [main, develop, release_workflow, 'release_**']
66
pull_request:
7-
branches: [main, release_workflow]
7+
branches: [main, develop, release_workflow]
88

99
concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ nodeId.properties
5555

5656
# vm_trace
5757
/vm_trace/
58+
59+
#test dependence
60+
solcDIR
61+
gRPCurl

testcase/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ task lint(type: Checkstyle) {
225225
source 'src'
226226
include '**/*.java'
227227
exclude 'main/gen/**'
228-
exclude 'test/**'
229228
// empty classpath
230229
classpath = files()
231230
//Failing the build

testcase/src/test/java/org/tron/common/zksnark/IncrementalMerkleTreeContainer.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
@Slf4j
1818
public class IncrementalMerkleTreeContainer {
1919

20-
@Getter
21-
@Setter
22-
private static Integer DEPTH = 32;
20+
@Getter @Setter private static Integer DEPTH = 32;
2321

2422
private IncrementalMerkleTreeCapsule treeCapsule;
2523

@@ -53,8 +51,7 @@ public void wfcheck() throws ZksnarkException {
5351
}
5452

5553
if ((!leftIsPresent()) && treeCapsule.getParents().size() > 0) {
56-
throw new ZksnarkException(
57-
"tree has non-canonical representation; parents should be empty");
54+
throw new ZksnarkException("tree has non-canonical representation; parents should be empty");
5855
}
5956
}
6057

@@ -86,9 +83,7 @@ public int size() {
8683
return ret;
8784
}
8885

89-
/**
90-
* append PedersenHash to the merkletree.
91-
*/
86+
/** append PedersenHash to the merkletree. */
9287
public void append(PedersenHash obj) throws ZksnarkException {
9388
if (isComplete(DEPTH)) {
9489
throw new ZksnarkException("tree is full");
@@ -143,9 +138,7 @@ public boolean isComplete(long depth) {
143138
return true;
144139
}
145140

146-
/**
147-
* get the depth of the skip exist element.
148-
*/
141+
/** get the depth of the skip exist element. */
149142
public int nextDepth(int skip) {
150143
if (!leftIsPresent()) {
151144
if (skip != 0) {
@@ -314,9 +307,9 @@ public PedersenHash next(int depth) {
314307

315308
public static class EmptyMerkleRoots {
316309

317-
@Setter
318-
@Getter
310+
@Setter @Getter
319311
private static EmptyMerkleRoots emptyMerkleRootsInstance = new EmptyMerkleRoots();
312+
320313
private List<PedersenHashCapsule> emptyRoots = new ArrayList<>();
321314

322315
public EmptyMerkleRoots() {

testcase/src/test/java/org/tron/common/zksnark/IncrementalMerkleVoucherContainer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
public class IncrementalMerkleVoucherContainer {
1313

14-
@Getter
15-
@Setter
16-
private static Integer DEPTH = IncrementalMerkleTreeContainer.getDEPTH();
14+
@Getter @Setter private static Integer DEPTH = IncrementalMerkleTreeContainer.getDEPTH();
1715

1816
private IncrementalMerkleVoucherCapsule voucherCapsule;
1917

@@ -96,7 +94,7 @@ public int size() {
9694
+ voucherCapsule.getCursor().toMerkleTreeContainer().size();
9795
}
9896

99-
//for test only
97+
// for test only
10098
public void printSize() {
10199
System.out.println(
102100
"TreeSize:"

testcase/src/test/java/org/tron/common/zksnark/JLibrustzcash.java

Lines changed: 107 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
package org.tron.common.zksnark;
22

33
import lombok.extern.slf4j.Slf4j;
4+
import org.tron.common.zksnark.LibrustzcashParam.BindingSigParams;
5+
import org.tron.common.zksnark.LibrustzcashParam.CheckOutputNewParams;
6+
import org.tron.common.zksnark.LibrustzcashParam.CheckOutputParams;
7+
import org.tron.common.zksnark.LibrustzcashParam.CheckSpendNewParams;
8+
import org.tron.common.zksnark.LibrustzcashParam.CheckSpendParams;
9+
import org.tron.common.zksnark.LibrustzcashParam.ComputeCmParams;
10+
import org.tron.common.zksnark.LibrustzcashParam.ComputeNfParams;
11+
import org.tron.common.zksnark.LibrustzcashParam.CrhIvkParams;
12+
import org.tron.common.zksnark.LibrustzcashParam.FinalCheckNewParams;
13+
import org.tron.common.zksnark.LibrustzcashParam.FinalCheckParams;
14+
import org.tron.common.zksnark.LibrustzcashParam.InitZksnarkParams;
15+
import org.tron.common.zksnark.LibrustzcashParam.IvkToPkdParams;
16+
import org.tron.common.zksnark.LibrustzcashParam.KaAgreeParams;
17+
import org.tron.common.zksnark.LibrustzcashParam.KaDerivepublicParams;
18+
import org.tron.common.zksnark.LibrustzcashParam.MerkleHashParams;
19+
import org.tron.common.zksnark.LibrustzcashParam.OutputProofParams;
20+
import org.tron.common.zksnark.LibrustzcashParam.SpendProofParams;
21+
import org.tron.common.zksnark.LibrustzcashParam.SpendSigParams;
22+
import org.tron.common.zksnark.LibrustzcashParam.Zip32XfvkAddressParams;
23+
import org.tron.common.zksnark.LibrustzcashParam.Zip32XskDeriveParams;
24+
import org.tron.common.zksnark.LibrustzcashParam.Zip32XskMasterParams;
425
import stest.tron.wallet.common.client.utils.ByteUtil;
526
import stest.tron.wallet.common.client.utils.CommonParameter;
627
import stest.tron.wallet.common.client.utils.exception.ZksnarkException;
7-
import org.tron.common.zksnark.LibrustzcashParam.*;
828

929
@Slf4j
1030
public class JLibrustzcash {
@@ -22,8 +42,11 @@ public static void librustzcashInitZksnarkParams(InitZksnarkParams params) {
2242
if (!isOpenZen()) {
2343
return;
2444
}
25-
INSTANCE.librustzcashInitZksnarkParams(params.getSpend_path(),
26-
params.getSpend_hash(), params.getOutput_path(), params.getOutput_hash());
45+
INSTANCE.librustzcashInitZksnarkParams(
46+
params.getSpend_path(),
47+
params.getSpend_hash(),
48+
params.getOutput_path(),
49+
params.getOutput_hash());
2750
}
2851

2952
public static void librustzcashZip32XskDerive(Zip32XskDeriveParams params) {
@@ -37,8 +60,8 @@ public static boolean librustzcashZip32XfvkAddress(Zip32XfvkAddressParams params
3760
if (!isOpenZen()) {
3861
return true;
3962
}
40-
return INSTANCE.librustzcashZip32XfvkAddress(params.getXfvk(), params.getJ(),
41-
params.getJ_ret(), params.getAddr_ret());
63+
return INSTANCE.librustzcashZip32XfvkAddress(
64+
params.getXfvk(), params.getJ(), params.getJ_ret(), params.getAddr_ret());
4265
}
4366

4467
public static void librustzcashCrhIvk(CrhIvkParams params) {
@@ -59,14 +82,21 @@ public static boolean librustzcashComputeCm(ComputeCmParams params) {
5982
if (!isOpenZen()) {
6083
return true;
6184
}
62-
return INSTANCE.librustzcashSaplingComputeCm(params.getD(), params.getPkD(),
63-
params.getValue(), params.getR(), params.getCm());
85+
return INSTANCE.librustzcashSaplingComputeCm(
86+
params.getD(), params.getPkD(), params.getValue(), params.getR(), params.getCm());
6487
}
6588

6689
public static boolean librustzcashComputeNf(ComputeNfParams params) {
6790
if (isOpenZen()) {
68-
INSTANCE.librustzcashSaplingComputeNf(params.getD(), params.getPkD(), params.getValue(),
69-
params.getR(), params.getAk(), params.getNk(), params.getPosition(), params.getResult());
91+
INSTANCE.librustzcashSaplingComputeNf(
92+
params.getD(),
93+
params.getPkD(),
94+
params.getValue(),
95+
params.getR(),
96+
params.getAk(),
97+
params.getNk(),
98+
params.getPosition(),
99+
params.getResult());
70100
}
71101
return true;
72102
}
@@ -101,9 +131,7 @@ public static byte[] librustzcashNskToNk(byte[] nsk) throws ZksnarkException {
101131

102132
// void librustzcash_nsk_to_nk(const unsigned char *nsk, unsigned char *result);
103133

104-
/**
105-
* @return r: random number, less than r_J, 32 bytes
106-
*/
134+
/** @return r: random number, less than r_J, 32 bytes */
107135
public static byte[] librustzcashSaplingGenerateR(byte[] r) throws ZksnarkException {
108136
if (!isOpenZen()) {
109137
return ByteUtil.EMPTY_BYTE_ARRAY;
@@ -117,8 +145,8 @@ public static boolean librustzcashSaplingKaDerivepublic(KaDerivepublicParams par
117145
if (!isOpenZen()) {
118146
return true;
119147
}
120-
return INSTANCE.librustzcashSaplingKaDerivepublic(params.getDiversifier(), params.getEsk(),
121-
params.getResult());
148+
return INSTANCE.librustzcashSaplingKaDerivepublic(
149+
params.getDiversifier(), params.getEsk(), params.getResult());
122150
}
123151

124152
public static long librustzcashSaplingProvingCtxInit() {
@@ -145,35 +173,50 @@ public static boolean librustzcashSaplingSpendProof(SpendProofParams params) {
145173
if (!isOpenZen()) {
146174
return true;
147175
}
148-
return INSTANCE.librustzcashSaplingSpendProof(params.getCtx(), params.getAk(),
149-
params.getNsk(), params.getD(), params.getR(), params.getAlpha(), params.getValue(),
150-
params.getAnchor(), params.getVoucherPath(), params.getCv(), params.getRk(),
176+
return INSTANCE.librustzcashSaplingSpendProof(
177+
params.getCtx(),
178+
params.getAk(),
179+
params.getNsk(),
180+
params.getD(),
181+
params.getR(),
182+
params.getAlpha(),
183+
params.getValue(),
184+
params.getAnchor(),
185+
params.getVoucherPath(),
186+
params.getCv(),
187+
params.getRk(),
151188
params.getZkproof());
152189
}
153190

154191
public static boolean librustzcashSaplingOutputProof(OutputProofParams params) {
155192
if (!isOpenZen()) {
156193
return true;
157194
}
158-
return INSTANCE.librustzcashSaplingOutputProof(params.getCtx(), params.getEsk(),
159-
params.getD(), params.getPkD(), params.getR(), params.getValue(), params.getCv(),
195+
return INSTANCE.librustzcashSaplingOutputProof(
196+
params.getCtx(),
197+
params.getEsk(),
198+
params.getD(),
199+
params.getPkD(),
200+
params.getR(),
201+
params.getValue(),
202+
params.getCv(),
160203
params.getZkproof());
161204
}
162205

163206
public static boolean librustzcashSaplingSpendSig(SpendSigParams params) {
164207
if (!isOpenZen()) {
165208
return true;
166209
}
167-
return INSTANCE.librustzcashSaplingSpendSig(params.getAsk(), params.getAlpha(),
168-
params.getSigHash(), params.getResult());
210+
return INSTANCE.librustzcashSaplingSpendSig(
211+
params.getAsk(), params.getAlpha(), params.getSigHash(), params.getResult());
169212
}
170213

171214
public static boolean librustzcashSaplingBindingSig(BindingSigParams params) {
172215
if (!isOpenZen()) {
173216
return true;
174217
}
175-
return INSTANCE.librustzcashSaplingBindingSig(params.getCtx(),
176-
params.getValueBalance(), params.getSighash(), params.getResult());
218+
return INSTANCE.librustzcashSaplingBindingSig(
219+
params.getCtx(), params.getValueBalance(), params.getSighash(), params.getResult());
177220
}
178221

179222
/**
@@ -209,52 +252,74 @@ public static boolean librustzcashSaplingCheckSpend(CheckSpendParams params) {
209252
if (!isOpenZen()) {
210253
return true;
211254
}
212-
return INSTANCE.librustzcashSaplingCheckSpend(params.getCtx(), params.getCv(),
213-
params.getAnchor(), params.getNullifier(), params.getRk(), params.getZkproof(),
214-
params.getSpendAuthSig(), params.getSighashValue());
255+
return INSTANCE.librustzcashSaplingCheckSpend(
256+
params.getCtx(),
257+
params.getCv(),
258+
params.getAnchor(),
259+
params.getNullifier(),
260+
params.getRk(),
261+
params.getZkproof(),
262+
params.getSpendAuthSig(),
263+
params.getSighashValue());
215264
}
216265

217266
public static boolean librustzcashSaplingCheckOutput(CheckOutputParams params) {
218267
if (!isOpenZen()) {
219268
return true;
220269
}
221-
return INSTANCE.librustzcashSaplingCheckOutput(params.getCtx(), params.getCv(),
222-
params.getCm(), params.getEphemeralKey(), params.getZkproof());
270+
return INSTANCE.librustzcashSaplingCheckOutput(
271+
params.getCtx(),
272+
params.getCv(),
273+
params.getCm(),
274+
params.getEphemeralKey(),
275+
params.getZkproof());
223276
}
224277

225278
public static boolean librustzcashSaplingFinalCheck(FinalCheckParams params) {
226279
if (!isOpenZen()) {
227280
return true;
228281
}
229-
return INSTANCE.librustzcashSaplingFinalCheck(params.getCtx(),
230-
params.getValueBalance(), params.getBindingSig(), params.getSighashValue());
282+
return INSTANCE.librustzcashSaplingFinalCheck(
283+
params.getCtx(),
284+
params.getValueBalance(),
285+
params.getBindingSig(),
286+
params.getSighashValue());
231287
}
232288

233289
public static boolean librustzcashSaplingCheckSpendNew(CheckSpendNewParams params) {
234290
if (!isOpenZen()) {
235291
return true;
236292
}
237-
return INSTANCE.librustzcashSaplingCheckSpendNew(params.getCv(),
238-
params.getAnchor(), params.getNullifier(), params.getRk(), params.getZkproof(),
239-
params.getSpendAuthSig(), params.getSighashValue());
293+
return INSTANCE.librustzcashSaplingCheckSpendNew(
294+
params.getCv(),
295+
params.getAnchor(),
296+
params.getNullifier(),
297+
params.getRk(),
298+
params.getZkproof(),
299+
params.getSpendAuthSig(),
300+
params.getSighashValue());
240301
}
241302

242303
public static boolean librustzcashSaplingCheckOutputNew(CheckOutputNewParams params) {
243304
if (!isOpenZen()) {
244305
return true;
245306
}
246-
return INSTANCE.librustzcashSaplingCheckOutputNew(params.getCv(), params.getCm(),
247-
params.getEphemeralKey(), params.getZkproof());
307+
return INSTANCE.librustzcashSaplingCheckOutputNew(
308+
params.getCv(), params.getCm(), params.getEphemeralKey(), params.getZkproof());
248309
}
249310

250311
public static boolean librustzcashSaplingFinalCheckNew(FinalCheckNewParams params) {
251312
if (!isOpenZen()) {
252313
return true;
253314
}
254-
return INSTANCE
255-
.librustzcashSaplingFinalCheckNew(params.getValueBalance(), params.getBindingSig(),
256-
params.getSighashValue(), params.getSpendCv(), params.getSpendCvLen(),
257-
params.getOutputCv(), params.getOutputCvLen());
315+
return INSTANCE.librustzcashSaplingFinalCheckNew(
316+
params.getValueBalance(),
317+
params.getBindingSig(),
318+
params.getSighashValue(),
319+
params.getSpendCv(),
320+
params.getSpendCvLen(),
321+
params.getOutputCv(),
322+
params.getOutputCvLen());
258323
}
259324

260325
public static void librustzcashSaplingVerificationCtxFree(long ctx) {
@@ -275,13 +340,11 @@ public static void librustzcashMerkleHash(MerkleHashParams params) {
275340
if (!isOpenZen()) {
276341
return;
277342
}
278-
INSTANCE.librustzcashMerkleHash(params.getDepth(), params.getA(), params.getB(),
279-
params.getResult());
343+
INSTANCE.librustzcashMerkleHash(
344+
params.getDepth(), params.getA(), params.getB(), params.getResult());
280345
}
281346

282-
/**
283-
* @param result uncommitted value, 32 bytes
284-
*/
347+
/** @param result uncommitted value, 32 bytes */
285348
public static void librustzcashTreeUncommitted(byte[] result) throws ZksnarkException {
286349
if (!isOpenZen()) {
287350
return;
@@ -297,5 +360,4 @@ public static boolean isOpenZen() {
297360
}
298361
return res;
299362
}
300-
301363
}

0 commit comments

Comments
 (0)