forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonParameter.java
More file actions
777 lines (704 loc) · 18 KB
/
CommonParameter.java
File metadata and controls
777 lines (704 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
package org.tron.common.parameter;
import com.beust.jcommander.Parameter;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import org.tron.common.args.GenesisBlock;
import org.tron.common.config.DbBackupConfig;
import org.tron.common.cron.CronExpression;
import org.tron.common.logsfilter.EventPluginConfig;
import org.tron.common.logsfilter.FilterQuery;
import org.tron.common.setting.RocksDbSettings;
import org.tron.core.Constant;
import org.tron.core.config.args.Overlay;
import org.tron.core.config.args.SeedNode;
import org.tron.core.config.args.Storage;
import org.tron.p2p.P2pConfig;
import org.tron.p2p.dns.update.PublishConfig;
public class CommonParameter {
public static final String IGNORE_WRONG_WITNESS_ADDRESS_FORMAT =
"The localWitnessAccountAddress format is incorrect, ignored";
public static CommonParameter PARAMETER = new CommonParameter();
@Setter
public static boolean ENERGY_LIMIT_HARD_FORK = false;
@Getter
@Parameter(names = {"-c", "--config"}, description = "Config file (default:config.conf)")
public String shellConfFileName = "";
@Getter
@Parameter(names = {"-d", "--output-directory"},
description = "Data directory for the databases (default:output-directory)")
public String outputDirectory = "output-directory";
@Getter
@Parameter(names = {"--log-config"}, description = "Logback config file")
public String logbackPath = "";
@Getter
@Parameter(names = {"-h", "--help"}, help = true, description = "Show help message")
public boolean help = false;
@Getter
@Setter
@Parameter(names = {"-w", "--witness"}, description = "Is witness node")
public boolean witness = false;
@Getter
@Setter
@Parameter(names = {"--support-constant"}, description = "Support constant calling for TVM. "
+ "(defalut: false)")
public boolean supportConstant = false;
@Getter
@Setter
@Parameter(names = {"--max-energy-limit-for-constant"}, description = "Max energy limit for "
+ "constant calling. (default: 100,000,000)")
public long maxEnergyLimitForConstant = 100_000_000L;
@Getter
@Setter
@Parameter(names = {"--lru-cache-size"}, description = "Max LRU size for caching bytecode and "
+ "result of JUMPDEST analysis. (default: 500)")
public int lruCacheSize = 500;
@Getter
@Setter
@Parameter(names = {"--debug"}, description = "Switch for TVM debug mode. In debug model, TVM "
+ "will not check for timeout. (default: false)")
public boolean debug = false;
@Getter
@Setter
@Parameter(names = {"--min-time-ratio"}, description = "Maximum CPU tolerance when executing "
+ "timeout transactions while synchronizing blocks. (default: 0.0)")
public double minTimeRatio = 0.0;
@Getter
@Setter
@Parameter(names = {"--max-time-ratio"}, description = "Maximum CPU tolerance when executing "
+ "non-timeout transactions while synchronizing blocks. (default: 5.0)")
public double maxTimeRatio = calcMaxTimeRatio();
@Getter
@Setter
@Parameter(names = {"--save-internaltx"}, description = "Save internal transactions generated "
+ "during TVM execution, such as create, call and suicide. (default: false)")
public boolean saveInternalTx;
@Getter
@Setter
@Parameter(names = {"--save-featured-internaltx"}, description = "Save featured internal "
+ "transactions generated during TVM execution, such as freeze, vote and so on. "
+ "(default: false)")
public boolean saveFeaturedInternalTx;
@Getter
@Setter
@Parameter(names = {"--save-cancel-all-unfreeze-v2-details"}, description = "Record the details of the internal "
+ "transactions generated by the CANCELALLUNFREEZEV2 opcode, such as bandwidth/energy/tronpower cancel amount. "
+ "(default: false)")
public boolean saveCancelAllUnfreezeV2Details;
@Getter
@Setter
@Parameter(names = {"--long-running-time"})
public int longRunningTime = 10;
@Getter
@Setter
@Parameter(names = {"--max-connect-number"}, description = "Http server max connect number "
+ "(default:50)")
public int maxHttpConnectNumber = 50;
@Getter
@Parameter(description = "--seed-nodes")
public List<String> seedNodes = new ArrayList<>();
@Parameter(names = {"-p", "--private-key"}, description = "Witness private key")
public String privateKey = "";
@Parameter(names = {"--witness-address"}, description = "witness-address")
public String witnessAddress = "";
@Parameter(names = {"--password"}, description = "password")
public String password;
@Parameter(names = {"--storage-db-directory"}, description = "Storage db directory")
public String storageDbDirectory = "";
@Parameter(names = {
"--storage-db-engine"}, description = "Storage db engine.(leveldb or rocksdb)")
public String storageDbEngine = "";
@Parameter(names = {
"--storage-db-synchronous"},
description = "Storage db is synchronous or not.(true or false)")
public String storageDbSynchronous = "";
@Parameter(names = {"--contract-parse-enable"}, description = "Switch for contract parses in " +
"java-tron. (default: true)")
public String contractParseEnable = "";
@Parameter(names = {"--storage-index-directory"},
description = "Storage index directory")
public String storageIndexDirectory = "";
@Parameter(names = {"--storage-index-switch"}, description = "Storage index switch.(on or off)")
public String storageIndexSwitch = "";
@Parameter(names = {"--storage-transactionHistory-switch"},
description = "Storage transaction history switch.(on or off)")
public String storageTransactionHistorySwitch = "";
@Getter
@Parameter(names = {"--fast-forward"})
public boolean fastForward = false;
@Getter
@Setter
public String chainId;
@Getter
@Setter
public boolean needSyncCheck;
@Getter
@Setter
public boolean nodeDiscoveryEnable;
@Getter
@Setter
public boolean nodeDiscoveryPersist;
@Getter
@Setter
public boolean nodeEffectiveCheckEnable;
@Getter
@Setter
public int nodeConnectionTimeout;
@Getter
@Setter
public int fetchBlockTimeout;
@Getter
@Setter
public int nodeChannelReadTimeout;
@Getter
@Setter
public int maxConnections;
@Getter
@Setter
public int minConnections;
@Getter
@Setter
public int minActiveConnections;
@Getter
@Setter
public int maxConnectionsWithSameIp;
@Getter
@Setter
public int maxTps;
@Getter
@Setter
public int minParticipationRate;
@Getter
public P2pConfig p2pConfig;
@Getter
@Setter
public int nodeListenPort;
@Getter
@Setter
public String nodeLanIp;
@Getter
@Setter
public String nodeExternalIp;
@Getter
@Setter
public int nodeP2pVersion;
@Getter
@Setter
public boolean nodeEnableIpv6 = false;
@Getter
@Setter
public List<String> dnsTreeUrls;
@Getter
@Setter
public PublishConfig dnsPublishConfig;
@Getter
@Setter
public long syncFetchBatchNum;
//If you are running a solidity node for java tron, this flag is set to true
@Getter
@Setter
@Parameter(names = {"--solidity"}, description = "running a solidity node for java tron")
public boolean solidityNode = false;
//If you are running KeystoreFactory, this flag is set to true
@Getter
@Setter
@Parameter(names = {"--keystore-factory"}, description = "running KeystoreFactory")
public boolean keystoreFactory = false;
@Getter
@Setter
public int rpcPort;
@Getter
@Setter
public int rpcOnSolidityPort;
@Getter
@Setter
public int fullNodeHttpPort;
@Getter
@Setter
public int solidityHttpPort;
@Getter
@Setter
public int jsonRpcHttpFullNodePort;
@Getter
@Setter
public int jsonRpcHttpSolidityPort;
@Getter
@Setter
public int jsonRpcHttpPBFTPort;
@Getter
@Setter
@Parameter(names = {"--rpc-thread"}, description = "Num of gRPC thread")
public int rpcThreadNum;
@Getter
@Setter
@Parameter(names = {"--solidity-thread"}, description = "Num of solidity thread")
public int solidityThreads;
@Getter
@Setter
public int maxConcurrentCallsPerConnection;
@Getter
@Setter
public int flowControlWindow;
// the positive limit of RST_STREAM frames per connection per period for grpc,
// 0 or Integer.MAX_VALUE for unlimited, by default there is no limit.
@Getter
@Setter
public int rpcMaxRstStream;
// the positive number of seconds per period for grpc
@Getter
@Setter
public int rpcSecondsPerWindow;
@Getter
@Setter
public long maxConnectionIdleInMillis;
@Getter
@Setter
public int blockProducedTimeOut;
@Getter
@Setter
public long netMaxTrxPerSecond;
@Getter
@Setter
public long maxConnectionAgeInMillis;
@Getter
@Setter
public int maxMessageSize;
@Getter
@Setter
public int maxHeaderListSize;
@Getter
@Setter
public boolean isRpcReflectionServiceEnable;
@Getter
@Setter
@Parameter(names = {"--validate-sign-thread"}, description = "Num of validate thread")
public int validateSignThreadNum;
@Getter
@Setter
public long maintenanceTimeInterval; // (ms)
@Getter
@Setter
public long proposalExpireTime; // (ms)
@Getter
@Setter
public int checkFrozenTime; // for test only
@Getter
@Setter
public long allowCreationOfContracts; //committee parameter
@Getter
@Setter
public long allowAdaptiveEnergy; //committee parameter
@Getter
@Setter
public long allowDelegateResource; //committee parameter
@Getter
@Setter
public long allowSameTokenName; //committee parameter
@Getter
@Setter
public long allowTvmTransferTrc10; //committee parameter
@Getter
@Setter
public long allowTvmConstantinople; //committee parameter
@Getter
@Setter
public long allowTvmSolidity059; //committee parameter
@Getter
@Setter
public long forbidTransferToContract; //committee parameter
@Getter
@Setter
public int tcpNettyWorkThreadNum;
@Getter
@Setter
public int udpNettyWorkThreadNum;
@Getter
@Setter
@Parameter(names = {"--trust-node"}, description = "Trust node addr")
public String trustNodeAddr;
@Getter
@Setter
public boolean walletExtensionApi;
@Getter
@Setter
public boolean estimateEnergy;
@Getter
@Setter
public int estimateEnergyMaxRetry;
@Getter
@Setter
public int backupPriority;
@Getter
@Setter
public int backupPort;
@Getter
@Setter
public int keepAliveInterval;
@Getter
@Setter
public List<String> backupMembers;
@Getter
@Setter
public long receiveTcpMinDataLength;
@Getter
@Setter
public boolean isOpenFullTcpDisconnect;
@Getter
@Setter
public int inactiveThreshold;
@Getter
@Setter
public boolean nodeDetectEnable;
@Getter
@Setter
public int allowMultiSign;
@Getter
@Setter
public boolean vmTrace;
@Getter
@Setter
public boolean needToUpdateAsset;
@Getter
@Setter
public String trxReferenceBlock;
@Getter
@Setter
public int minEffectiveConnection;
@Getter
@Setter
public boolean trxCacheEnable;
@Getter
@Setter
public long allowMarketTransaction; //committee parameter
@Getter
@Setter
public long allowTransactionFeePool;
@Getter
@Setter
public long allowBlackHoleOptimization;
@Getter
@Setter
public long allowNewResourceModel;
// @Getter
// @Setter
// public long allowShieldedTransaction; //committee parameter
// full node used this parameter to close shielded transaction
@Getter
@Setter
public boolean allowShieldedTransactionApi;
@Getter
@Setter
public long blockNumForEnergyLimit;
@Getter
@Setter
@Parameter(names = {"--es"}, description = "Start event subscribe server")
public boolean eventSubscribe = false;
@Getter
@Setter
public long trxExpirationTimeInMilliseconds; // (ms)
@Parameter(names = {"-v", "--version"}, description = "Output code version", help = true)
public boolean version;
@Getter
@Setter
public String zenTokenId;
@Getter
@Setter
public long allowProtoFilterNum;
@Getter
@Setter
public long allowAccountStateRoot;
@Getter
@Setter
public int validContractProtoThreadNum = 1;
@Getter
@Setter
public int shieldedTransInPendingMaxCounts;
@Getter
@Setter
public long changedDelegation;
@Getter
@Setter
public Set<String> actuatorSet;
@Getter
@Setter
public RateLimiterInitialization rateLimiterInitialization;
@Getter
@Setter
public int rateLimiterGlobalQps;
@Getter
@Setter
public int rateLimiterGlobalIpQps;
@Getter
public int rateLimiterGlobalApiQps;
@Getter
@Setter
public double rateLimiterSyncBlockChain;
@Getter
@Setter
public double rateLimiterFetchInvData;
@Getter
@Setter
public double rateLimiterDisconnect;
@Getter
public DbBackupConfig dbBackupConfig;
@Getter
public RocksDbSettings rocksDBCustomSettings;
@Getter
public GenesisBlock genesisBlock;
@Getter
@Setter
@Parameter(names = {"--p2p-disable"}, description = "Switch for p2p module initialization. "
+ "(defalut: false)", arity = 1)
public boolean p2pDisable = false;
@Getter
@Setter
public List<InetSocketAddress> activeNodes;
@Getter
@Setter
public List<InetAddress> passiveNodes;
@Getter
public List<InetSocketAddress> fastForwardNodes;
@Getter
public int maxFastForwardNum;
@Getter
public Storage storage;
@Getter
public Overlay overlay;
@Getter
public SeedNode seedNode;
@Getter
public EventPluginConfig eventPluginConfig;
@Getter
public FilterQuery eventFilter;
@Getter
@Setter
public String cryptoEngine = Constant.ECKey_ENGINE;
@Getter
@Setter
public boolean rpcEnable = true;
@Getter
@Setter
public boolean rpcSolidityEnable = true;
@Getter
@Setter
public boolean rpcPBFTEnable = true;
@Getter
@Setter
public boolean fullNodeHttpEnable = true;
@Getter
@Setter
public boolean solidityNodeHttpEnable = true;
@Getter
@Setter
public boolean pBFTHttpEnable = true;
@Getter
@Setter
public boolean jsonRpcHttpFullNodeEnable = false;
@Getter
@Setter
public boolean jsonRpcHttpSolidityNodeEnable = false;
@Getter
@Setter
public boolean jsonRpcHttpPBFTNodeEnable = false;
@Getter
@Setter
public int jsonRpcMaxBlockRange = 5000;
@Getter
@Setter
public int jsonRpcMaxSubTopics = 1000;
@Getter
@Setter
public int jsonRpcMaxBlockFilterNum = 50000;
@Getter
@Setter
public int maxTransactionPendingSize;
@Getter
@Setter
public long pendingTransactionTimeout;
@Getter
@Setter
public boolean nodeMetricsEnable = false;
@Getter
@Setter
public boolean metricsStorageEnable = false;
@Getter
@Setter
public String influxDbIp;
@Getter
@Setter
public int influxDbPort;
@Getter
@Setter
public String influxDbDatabase;
@Getter
@Setter
public int metricsReportInterval = 10;
@Getter
@Setter
public boolean metricsPrometheusEnable = false;
@Getter
@Setter
public int metricsPrometheusPort;
@Getter
@Setter
public int agreeNodeCount;
@Getter
@Setter
public long allowPBFT;
@Getter
@Setter
public int rpcOnPBFTPort;
@Getter
@Setter
public int pBFTHttpPort;
@Getter
@Setter
public long pBFTExpireNum;
@Getter
@Setter
public long oldSolidityBlockNum = -1;
@Getter/**/
@Setter
public long allowShieldedTRC20Transaction;
@Getter/**/
@Setter
public long allowTvmIstanbul;
@Getter
@Setter
public long allowTvmFreeze;
@Getter
@Setter
public long allowTvmVote;
@Getter
@Setter
public long allowTvmLondon;
@Getter
@Setter
public long allowTvmCompatibleEvm;
@Getter
@Setter
public long allowHigherLimitForMaxCpuTimeOfOneTx;
@Getter
@Setter
public boolean openHistoryQueryWhenLiteFN = false;
@Getter
@Setter
@Parameter(names = {"--history-balance-lookup"})
public boolean historyBalanceLookup = false;
@Getter
@Setter
public boolean openPrintLog = true;
@Getter
@Setter
public boolean openTransactionSort = false;
@Getter
@Setter
public long allowAccountAssetOptimization;
@Getter
@Setter
public long allowAssetOptimization;
@Getter
@Setter
public List<String> disabledApiList;
@Getter
@Setter
public CronExpression shutdownBlockTime = null;
@Getter
@Setter
public long shutdownBlockHeight = -1;
@Getter
@Setter
public long shutdownBlockCount = -1;
@Getter
@Setter
public long blockCacheTimeout = 60;
@Getter
@Setter
public long allowNewRewardAlgorithm;
@Getter
@Setter
public long allowNewReward = 0L;
@Getter
@Setter
public long memoFee = 0L;
@Getter
@Setter
public long allowDelegateOptimization = 0L;
@Getter
@Setter
public long unfreezeDelayDays = 0L;
@Getter
@Setter
public long allowOptimizedReturnValueOfChainId = 0L;
@Getter
@Setter
public long allowDynamicEnergy = 0L;
@Getter
@Setter
public long dynamicEnergyThreshold = 0L;
@Getter
@Setter
public long dynamicEnergyIncreaseFactor = 0L;
@Getter
@Setter
public long dynamicEnergyMaxFactor = 0L;
@Getter
@Setter
public boolean dynamicConfigEnable;
@Getter
@Setter
public long dynamicConfigCheckInterval;
@Getter
@Setter
public long allowTvmShangHai;
@Getter
@Setter
public long allowCancelAllUnfreezeV2;
@Getter
@Setter
public boolean unsolidifiedBlockCheck;
@Getter
@Setter
public int maxUnsolidifiedBlocks;
@Getter
@Setter
public long allowOldRewardOpt;
@Getter
@Setter
public long allowEnergyAdjustment;
@Getter
@Setter
public long maxCreateAccountTxSize = 1000L;
@Getter
@Setter
public long allowStrictMath;
@Getter
@Setter
public long consensusLogicOptimization;
@Getter
@Setter
public long allowTvmCancun;
@Getter
@Setter
public long allowTvmBlob;
private static double calcMaxTimeRatio() {
//return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1)));
return 5.0;
}
public static CommonParameter getInstance() {
return PARAMETER;
}
public boolean isECKeyCryptoEngine() {
return cryptoEngine.equalsIgnoreCase(Constant.ECKey_ENGINE);
}
public boolean isJsonRpcFilterEnabled() {
return jsonRpcHttpFullNodeEnable || jsonRpcHttpSolidityNodeEnable;
}
public int getSafeLruCacheSize() {
return lruCacheSize < 1 ? 500 : lruCacheSize;
}
}