-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathCommonParameter.java
More file actions
697 lines (675 loc) · 15.5 KB
/
Copy pathCommonParameter.java
File metadata and controls
697 lines (675 loc) · 15.5 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
package org.tron.common.parameter;
import com.google.common.annotations.VisibleForTesting;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.slf4j.bridge.SLF4JBridgeHandler;
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 {
// Install the JUL->SLF4J bridge early so that JUL log records emitted during
// static init of grpc classes (or from unit tests that don't invoke
// LogService.load()) still reach Logback.
// removeHandlersForRootLogger() strips JUL's default ConsoleHandler so the
// same record is not emitted twice (once by JUL's own console output and
// once via the bridge to Logback).
static {
SLF4JBridgeHandler.removeHandlersForRootLogger();
if (!SLF4JBridgeHandler.isInstalled()) {
SLF4JBridgeHandler.install();
}
}
protected static CommonParameter PARAMETER = new CommonParameter();
// Runtime chain state: set by VMConfig.initVmHardFork()
// when the energy-limit governance proposal is activated.
// Legacy: should belong to VMConfig, not here.
@Setter
public static boolean ENERGY_LIMIT_HARD_FORK = false;
// -- Startup parameters --
@Getter
public String outputDirectory = "output-directory";
@Getter
public String logbackPath = "";
// -- Flags (CLI + Config) --
@Getter
@Setter
public boolean witness = false;
@Getter
@Setter
public boolean supportConstant = false;
@Getter
@Setter
public long maxEnergyLimitForConstant = 100_000_000L;
@Getter
@Setter
public int lruCacheSize = 500;
@Getter
@Setter
public boolean debug = false;
@Getter
@Setter
public double minTimeRatio = 0.0;
@Getter
@Setter
public double maxTimeRatio = calcMaxTimeRatio();
/**
* Max TVM execution time (ms) for constant calls — covers
* triggerconstantcontract, triggersmartcontract dispatched to view/pure
* functions, estimateenergy, eth_call, eth_estimateGas, and any other
* RPC routed through Wallet#callConstantContract. 0 = use the same
* deadline as block processing (current behaviour). When operators set
* this in config the value must be positive and fit VM deadline conversion;
* validated at config-load in VmConfig.
*/
@Getter
@Setter
public long constantCallTimeoutMs = 0L;
@Getter
@Setter
public boolean saveInternalTx;
@Getter
@Setter
public boolean saveFeaturedInternalTx;
@Getter
@Setter
public boolean saveCancelAllUnfreezeV2Details;
@Getter
@Setter
public int longRunningTime = 10;
@Getter
@Setter
public int maxHttpConnectNumber = 50;
@Getter
public List<String> seedNodes = new ArrayList<>();
@Getter
public boolean fastForward = false;
// -- Network / P2P --
@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 = 2000; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int fetchBlockTimeout;
@Getter
@Setter
public int nodeChannelReadTimeout;
@Getter
@Setter
public int maxConnections = 30; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int minConnections = 8; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int minActiveConnections = 3; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int maxConnectionsWithSameIp = 2; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int maxTps; // clearParam: 1000
@Getter
@Setter
public int maxBlockInvPerSecond = 10; // default: 10 block inv hashes/s per peer
@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; // clearParam: new ArrayList<>()
@Getter
@Setter
public PublishConfig dnsPublishConfig;
@Getter
@Setter
public long syncFetchBatchNum; // clearParam: 2000
@Getter
@Setter
public int maxPendingBlockSize;
// If you are running a solidity node for java tron,
// this flag is set to true
@Getter
@Setter
public boolean solidityNode = false;
// If you are running KeystoreFactory,
// this flag is set to true
@Getter
@Setter
public boolean keystoreFactory = false;
// -- RPC / HTTP --
@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
public int rpcThreadNum;
@Getter
@Setter
public int solidityThreads;
@Getter
@Setter
public int maxConcurrentCallsPerConnection;
@Getter
@Setter
public int flowControlWindow;
@Getter
@Setter
public int rpcMaxRstStream;
@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;
// Refers to RPC (gRPC) max message size; see httpMaxMessageSize / jsonRpcMaxMessageSize
// below for the HTTP / JSON-RPC counterparts.
@Getter
@Setter
public int maxMessageSize;
@Getter
@Setter
public long httpMaxMessageSize;
@Getter
@Setter
public long jsonRpcMaxMessageSize;
@Getter
@Setter
public int maxHeaderListSize;
@Getter
@Setter
public boolean isRpcReflectionServiceEnable;
@Getter
@Setter
public int validateSignThreadNum;
@Getter
@Setter
public long maintenanceTimeInterval;
@Getter
@Setter
public long proposalExpireTime;
@Getter
@Setter
public int checkFrozenTime; // clearParam: 1
// -- Committee parameters --
@Getter
@Setter
public long allowCreationOfContracts;
@Getter
@Setter
public long allowAdaptiveEnergy;
@Getter
@Setter
public long allowDelegateResource;
@Getter
@Setter
public long allowSameTokenName;
@Getter
@Setter
public long allowTvmTransferTrc10;
@Getter
@Setter
public long allowTvmConstantinople;
@Getter
@Setter
public long allowTvmSolidity059;
@Getter
@Setter
public long forbidTransferToContract;
// -- Netty --
@Getter
@Setter
public int tcpNettyWorkThreadNum;
@Getter
@Setter
public int udpNettyWorkThreadNum;
@Getter
@Setter
public String trustNodeAddr; // clearParam: ""
@Getter
@Setter
public boolean walletExtensionApi;
@Getter
@Setter
public boolean estimateEnergy;
@Getter
@Setter
public int estimateEnergyMaxRetry = 3; // from clearParam(), consistent with mainnet.conf
@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; // clearParam: 2048
@Getter
@Setter
public boolean isOpenFullTcpDisconnect;
@Getter
@Setter
public int inactiveThreshold = 600; // from clearParam(), consistent with mainnet.conf
@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;
@Getter
@Setter
public long allowTransactionFeePool;
@Getter
@Setter
public long allowBlackHoleOptimization;
@Getter
@Setter
public long allowNewResourceModel;
@Getter
@Setter
public boolean allowShieldedTransactionApi; // clearParam: false
@Getter
@Setter
public long blockNumForEnergyLimit;
@Getter
@Setter
public boolean eventSubscribe = false;
@Getter
@Setter
public long trxExpirationTimeInMilliseconds;
// -- Shielded / ZK --
@Getter
@Setter
public String zenTokenId; // clearParam: "000000"
@Getter
@Setter
public long allowProtoFilterNum;
@Getter
@Setter
public long allowAccountStateRoot;
@Getter
@Setter
public int validContractProtoThreadNum = 1;
@Getter
@Setter
public int shieldedTransInPendingMaxCounts; // clearParam: 10
@Getter
@Setter
public long changedDelegation;
@Getter
@Setter
public RateLimiterInitialization rateLimiterInitialization;
@Getter
@Setter
public int rateLimiterGlobalQps = 50000; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public int rateLimiterGlobalIpQps = 10000; // from clearParam(), consistent with mainnet.conf
@Getter
public int rateLimiterGlobalApiQps = 1000; // from clearParam(), consistent with mainnet.conf
@Getter
@Setter
public double rateLimiterSyncBlockChain; // clearParam: 3.0
@Getter
@Setter
public double rateLimiterFetchInvData; // clearParam: 3.0
@Getter
@Setter
public double rateLimiterDisconnect; // clearParam: 1.0
@Getter
public DbBackupConfig dbBackupConfig;
@Getter
public RocksDbSettings rocksDBCustomSettings;
@Getter
public GenesisBlock genesisBlock;
@Getter
@Setter
public boolean p2pDisable = false;
@Getter
@Setter
// from clearParam(), consistent with mainnet.conf
public List<InetSocketAddress> activeNodes = new ArrayList<>();
@Getter
@Setter
// from clearParam(), consistent with mainnet.conf
public List<InetAddress> passiveNodes = new ArrayList<>();
@Getter
public List<InetSocketAddress> fastForwardNodes; // clearParam: new ArrayList<>()
@Getter
public int maxFastForwardNum; // clearParam: 4
@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 int maxTrxCacheSize;
@Getter
@Setter
public boolean nodeMetricsEnable = false;
@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 int maxNestingDepth = 100;
@Getter
@Setter
public int maxTokenCount = 100_000;
@Getter
@Setter
public long pBFTExpireNum; // clearParam: 20
@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
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; // clearParam: Collections.emptyList()
@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; // clearParam: 600
@Getter
@Setter
public long allowTvmShangHai;
@Getter
@Setter
public long allowCancelAllUnfreezeV2;
@Getter
@Setter
public boolean unsolidifiedBlockCheck;
@Getter
@Setter
public int maxUnsolidifiedBlocks; // clearParam: 54
@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 5.0;
}
public static CommonParameter getInstance() {
return PARAMETER;
}
/**
* Reset to a fresh instance. Test-only.
*/
@VisibleForTesting
public static void reset() {
if (PARAMETER.storage != null) {
PARAMETER.storage.deleteAllStoragePaths();
}
PARAMETER = new CommonParameter();
}
public boolean isECKeyCryptoEngine() {
return cryptoEngine.equalsIgnoreCase(Constant.ECKey_ENGINE);
}
public boolean isJsonRpcFilterEnabled() {
return jsonRpcHttpFullNodeEnable
|| jsonRpcHttpSolidityNodeEnable;
}
public int getSafeLruCacheSize() {
return lruCacheSize < 1 ? 500 : lruCacheSize;
}
}