refactor(config): extract CLIParameter and restructure Args init flow#7
Open
vividctrlalt wants to merge 10 commits intodevelopfrom
Open
refactor(config): extract CLIParameter and restructure Args init flow#7vividctrlalt wants to merge 10 commits intodevelopfrom
vividctrlalt wants to merge 10 commits intodevelopfrom
Conversation
Removed 4 config files from framework/src/main/resources that were not referenced anywhere in the codebase: - config-backup.conf: no references - config-beta.conf: no references - config-test-net.conf: no references - config-localtest.conf: only used in tests, shadowed by src/test/resources/config-localtest.conf on the test classpath
Extract all @parameter annotations from CommonParameter into a new CLIParameter class, removing JCommander dependency from common module. Refactor Args.setParam() into a four-step flow: parse CLI, apply config, apply CLI overrides via isAssigned(), init witness. Simplify clearParam() from ~160 lines to CommonParameter.reset().
- Restructure Args.setParam into 4-step flow: parse CLI, apply config, apply CLI overrides, init witnesses - Rename setParam(Config) to applyConfigParams, setCLIParameter to applyCLIParams for clarity - Extract WitnessInitializer into 3 static methods (initFromCLIPrivateKey, initFromCFGPrivateKey, initFromKeystore) with routing in Args - Remove password/privateKey/witnessAddress/help/version/configFilePath from CommonParameter — pass as method params instead of global state - Move JDK version check from Args to FullNode entry point - Extract Configuration.getByFileName for single-param config loading
applyCLIParams() wrote 7 storage-related values to intermediate fields on CommonParameter instead of the Storage object that is actually used at runtime. Since applyConfigParams() runs first, these CLI values were silently ignored. - Remove 7 intermediate fields from CommonParameter - Simplify applyConfigParams() to read directly from config - Fix applyCLIParams() to write directly to PARAMETER.storage - Add tests for CLI-overrides-config and config-defaults scenarios
The test failed on ARM64 because Storage.getDbEngineFromConfig() silently overrode the user's config to ROCKSDB, which is unreasonable as it hides incompatible configuration from the user. Replace the silent override with an explicit validateConfig() check in Args that fails fast with IllegalArgumentException when LevelDB is configured on ARM64. This makes the incompatibility visible instead of silently swallowed.
…erride The validateConfig() approach caused 1273 test failures on ARM64 because most tests use config files with db.engine="LEVELDB" and setParam() was throwing IllegalArgumentException before any test logic could run. Restore the original silent override in Storage.getDbEngineFromConfig() which automatically switches to ROCKSDB on ARM64. Update the testConfigStorageDefaults test to be architecture-aware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@Parameterannotations fromCommonParameterinto a newCLIParameterclass, separating CLI parsing from runtime config stateArgs.setParam()into a clear 4-step flow: parse CLI →applyConfigParams→applyCLIParams→initLocalWitnessesWitnessInitializerinto three static methods (initFromCLIPrivateKey,initFromCFGPrivateKey,initFromKeystore), with routing logic moved toArgs.initLocalWitnessespassword,privateKey,witnessAddressfromCommonParameter— sensitive credentials are now passed directly as method parameters and never stored in global stateTest plan
./gradlew :framework:test --tests "org.tron.core.config.args.*"— all parameter tests pass./gradlew :framework:test— full framework tests pass