Skip to content

fix(config): deprecate CLI params and add guardrails#6580

Open
vividctrlalt wants to merge 3 commits intotronprotocol:developfrom
vividctrlalt:fix/pr6569-review-followup
Open

fix(config): deprecate CLI params and add guardrails#6580
vividctrlalt wants to merge 3 commits intotronprotocol:developfrom
vividctrlalt:fix/pr6569-review-followup

Conversation

@vividctrlalt
Copy link
Contributor

Summary

Follow-up to #6569 review feedback:

  • Deprecate 23 CLI parameters that can be replaced by config-file options, marking them with @Deprecated in CLIParameter and logging runtime warnings via reflection when used
  • Add max(3_000_000L, ...) guardrail for --max-energy-limit-for-constant CLI path, consistent with config-file validation (addresses @waynercheung's review in refactor(config): extract CLIParameter and restructure Args init flow #6569)
  • Document seedNodes positional parameter behavior with comment explaining why isEmpty() is used instead of isAssigned(), plus deprecation warning

Retained CLI params (11)

-c, -d, --log-config, -h, -v, -w, -p, --witness-address, --password, --keystore-factory, --debug

Deprecated CLI params (23)

All storage, VM, network/thread, and misc runtime parameters — these should be configured via config file.

Test plan

Related

…rotocol#6569 review follow-up

- Mark 23 config-file-replaceable CLI parameters as @deprecated in CLIParameter
- Add runtime deprecation warning via reflection when deprecated CLI options are used
- Add max(3_000_000L, ...) guardrail for --max-energy-limit-for-constant CLI path,
  consistent with config-file validation (addresses waynercheung's review feedback)
- Document seedNodes positional parameter behavior and add deprecation warning
- Retain 11 essential CLI params: -c, -d, --log-config, -h, -v, -w, -p,
  --witness-address, --password, --keystore-factory, --debug
@vividctrlalt vividctrlalt changed the title fix(config): deprecate CLI params and add safety guardrails (#6569 follow-up) fix(config): deprecate CLI params and add guardrails Mar 16, 2026
// isAssigned(). An empty-check is used instead — this is safe because the default
// is an empty list, so non-empty means the user explicitly passed values on CLI.
if (!cmd.seedNodes.isEmpty()) {
logger.warn("Positional seed-node arguments are deprecated. "
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since seedNodes is deprecated, the corresponding help info should also be removed, such as: helpStr.append(String.format("%nUsage: java -jar %s [options] [seedNode ...]%n", programName));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Since seedNodes is deprecated but not yet removed, users may still want to use it, so I kept the Usage line but added a deprecation note right below it. Also noticed that --es and --solidity in the help output are deprecated too (marked in this PR), so I added (deprecated) hints to all deprecated options in the help text. See 84027da.

Mark deprecated options with "(deprecated)" in help text and add a
note below the Usage line that positional seedNode args are deprecated.
})
.forEach(pd -> logger.warn(
"CLI option '{}' is deprecated and will be removed in a future release. "
+ "Please use the corresponding config-file option instead.",
Copy link

@warku123 warku123 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enriching the warning message with the specific config-file key mapping so users know exactly how to migrate.

And if we implement this, it's necessary to add a static map like this:

private static final Map<String, String> DEPRECATED_CLI_TO_CONFIG = Map.ofEntries(
    Map.entry("--storage-db-directory", "storage.db.directory"),
    Map.entry("--storage-db-engine", "storage.db.engine"),
    Map.entry("--storage-db-synchronous", "storage.db.synchronous"),
    // add remaining params...
);

And change this log like this:

   .forEach(pd -> {
      String cliOption = pd.getLongestName();
      String configKey = DEPRECATED_CLI_TO_CONFIG.get(cliOption);
      String suggestion = configKey != null 
          ? String.format(" Please use config key '%s' instead.", configKey)
          : " Please use the corresponding config-file option instead.";
      logger.warn("CLI option '{}' is deprecated and will be removed in a future release.{}",
          cliOption, suggestion);
    });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! Added a DEPRECATED_CLI_TO_CONFIG map that provides specific config-key hints in deprecation warnings.

For params with a config equivalent:
CLI option '--storage-db-engine' is deprecated and will be removed in a future release. Please use config key 'storage.db.engine' instead.

For params without a config equivalent (--solidity, --p2p-disable):
CLI option '--solidity' is deprecated and will be removed in a future release.

This also addresses @3for's concern about misleading messages. See 5b0e37b.

}
if (assigned.contains("--max-energy-limit-for-constant")) {
PARAMETER.maxEnergyLimitForConstant = cmd.maxEnergyLimitForConstant;
PARAMETER.maxEnergyLimitForConstant = max(3_000_000L,
Copy link

@warku123 warku123 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that 3_000_000L is already defined as ENERGY_LIMIT_IN_CONSTANT_TX in Constant.java:

// In common/src/main/java/org/tron/core/Constant.java
public static final long ENERGY_LIMIT_IN_CONSTANT_TX = 3_000_000L;

Would it make sense to reuse this constant here instead of the inline literal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Replaced both occurrences of 3_000_000L with ENERGY_LIMIT_IN_CONSTANT_TX from Constant.java. See 5b0e37b.

})
.forEach(pd -> logger.warn(
"CLI option '{}' is deprecated and will be removed in a future release. "
+ "Please use the corresponding config-file option instead.",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some deprecated CLI parameters (e.g., --solidity, --p2p-disable, --es, --fast-forward) have no equivalent "config-file option" in .conf, making the message “Please use the corresponding config-file option instead” misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. Params like --solidity and --p2p-disable have no config-file equivalent — they are runtime mode switches being phased out entirely. The warning now omits the "use config-file option" suggestion for these params and simply states they will be removed. See 5b0e37b.

vividctrlalt added a commit to vividctrlalt/java-tron that referenced this pull request Mar 17, 2026
- 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.
- 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.
@vividctrlalt vividctrlalt force-pushed the fix/pr6569-review-followup branch from 731abdb to 5b0e37b Compare March 17, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants