Skip to content

Commit 5b0e37b

Browse files
committed
fix(config): enrich deprecation warnings with config-key mapping
- Add DEPRECATED_CLI_TO_CONFIG map for CLI-to-config key lookup - Show specific config key in warning for params that have equivalents - Use generic "will be removed" message for params without config equiv (--solidity, --p2p-disable) - Replace magic literal 3_000_000L with ENERGY_LIMIT_IN_CONSTANT_TX Addresses review feedback from warku123 and 3for on tronprotocol#6580.
1 parent 84027da commit 5b0e37b

1 file changed

Lines changed: 49 additions & 6 deletions

File tree

  • framework/src/main/java/org/tron/core/config/args

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import static org.tron.core.Constant.DEFAULT_PROPOSAL_EXPIRE_TIME;
88
import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE;
99
import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE;
10+
import static org.tron.core.Constant.ENERGY_LIMIT_IN_CONSTANT_TX;
1011
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
1112
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
1213
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT;
@@ -83,6 +84,41 @@
8384
@Component
8485
public class Args extends CommonParameter {
8586

87+
/**
88+
* Maps deprecated CLI option names to their config-file equivalents.
89+
* Options not in this map have no config equivalent and are being removed entirely.
90+
*/
91+
private static final Map<String, String> DEPRECATED_CLI_TO_CONFIG;
92+
93+
static {
94+
Map<String, String> m = new HashMap<>();
95+
m.put("--storage-db-directory", "storage.db.directory");
96+
m.put("--storage-db-engine", "storage.db.engine");
97+
m.put("--storage-db-synchronous", "storage.db.sync");
98+
m.put("--storage-index-directory", "storage.index.directory");
99+
m.put("--storage-index-switch", "storage.index.switch");
100+
m.put("--storage-transactionHistory-switch", "storage.transHistory.switch");
101+
m.put("--contract-parse-enable", "event.subscribe.contractParse");
102+
m.put("--support-constant", "vm.supportConstant");
103+
m.put("--max-energy-limit-for-constant", "vm.maxEnergyLimitForConstant");
104+
m.put("--lru-cache-size", "vm.lruCacheSize");
105+
m.put("--min-time-ratio", "vm.minTimeRatio");
106+
m.put("--max-time-ratio", "vm.maxTimeRatio");
107+
m.put("--save-internaltx", "vm.saveInternalTx");
108+
m.put("--save-featured-internaltx", "vm.saveFeaturedInternalTx");
109+
m.put("--save-cancel-all-unfreeze-v2-details", "vm.saveCancelAllUnfreezeV2Details");
110+
m.put("--long-running-time", "vm.longRunningTime");
111+
m.put("--max-connect-number", "node.maxHttpConnectNumber");
112+
m.put("--rpc-thread", "node.rpc.thread");
113+
m.put("--solidity-thread", "node.solidity.threads");
114+
m.put("--validate-sign-thread", "node.validateSignThreadNum");
115+
m.put("--trust-node", "node.trustNode");
116+
m.put("--history-balance-lookup", "storage.balance.history.lookup");
117+
m.put("--es", "event.subscribe");
118+
m.put("--fast-forward", "node.fastForward");
119+
DEPRECATED_CLI_TO_CONFIG = Collections.unmodifiableMap(m);
120+
}
121+
86122
@Getter
87123
private static String configFilePath = "";
88124

@@ -152,7 +188,7 @@ public static void applyConfigParams(
152188

153189
if (config.hasPath(ConfigKey.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT)) {
154190
long configLimit = config.getLong(ConfigKey.VM_MAX_ENERGY_LIMIT_FOR_CONSTANT);
155-
PARAMETER.maxEnergyLimitForConstant = max(3_000_000L, configLimit, true);
191+
PARAMETER.maxEnergyLimitForConstant = max(ENERGY_LIMIT_IN_CONSTANT_TX, configLimit, true);
156192
}
157193

158194
if (config.hasPath(ConfigKey.VM_LRU_CACHE_SIZE)) {
@@ -1008,10 +1044,17 @@ private static void applyCLIParams(CLIParameter cmd, JCommander jc) {
10081044
return false;
10091045
}
10101046
})
1011-
.forEach(pd -> logger.warn(
1012-
"CLI option '{}' is deprecated and will be removed in a future release. "
1013-
+ "Please use the corresponding config-file option instead.",
1014-
pd.getLongestName()));
1047+
.forEach(pd -> {
1048+
String cliOption = pd.getLongestName();
1049+
String configKey = DEPRECATED_CLI_TO_CONFIG.get(cliOption);
1050+
if (configKey != null) {
1051+
logger.warn("CLI option '{}' is deprecated and will be removed in a future release."
1052+
+ " Please use config key '{}' instead.", cliOption, configKey);
1053+
} else {
1054+
logger.warn("CLI option '{}' is deprecated and will be removed in a future release.",
1055+
cliOption);
1056+
}
1057+
});
10151058

10161059
if (assigned.contains("--output-directory")) {
10171060
PARAMETER.outputDirectory = cmd.outputDirectory;
@@ -1023,7 +1066,7 @@ private static void applyCLIParams(CLIParameter cmd, JCommander jc) {
10231066
PARAMETER.supportConstant = cmd.supportConstant;
10241067
}
10251068
if (assigned.contains("--max-energy-limit-for-constant")) {
1026-
PARAMETER.maxEnergyLimitForConstant = max(3_000_000L,
1069+
PARAMETER.maxEnergyLimitForConstant = max(ENERGY_LIMIT_IN_CONSTANT_TX,
10271070
cmd.maxEnergyLimitForConstant, true);
10281071
}
10291072
if (assigned.contains("--lru-cache-size")) {

0 commit comments

Comments
 (0)