Skip to content

refactor(config): improve startup errors and remove inactive assertions - #45

Draft
bladehan1 wants to merge 1 commit into
developfrom
feature/opt_config_error
Draft

refactor(config): improve startup errors and remove inactive assertions#45
bladehan1 wants to merge 1 commit into
developfrom
feature/opt_config_error

Conversation

@bladehan1

@bladehan1 bladehan1 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

  • Replace selected startup IllegalArgumentException failures with TronError(PARAMETER_INIT).
  • Remove selected historical Java assertions that are inactive under the default production JVM configuration.
  • Preserve the assertions in the EthereumJ-derived TrieImpl and the Besu-derived Blake2bfMessageDigest implementations.
  • Add focused unit and integration tests for the affected configuration error paths.

Why are these changes required?

The selected failures are parameter initialization errors. Classifying them with PARAMETER_INIT makes startup failures consistent while preserving their messages and exit behavior.

The assertion cleanup is limited to historical java-tron code where the assertions are inactive by default. Assertions in TrieImpl are retained because its core implementation is derived from EthereumJ and the checks document internal node-type invariants. The Besu-derived Blake2bf assertion is retained for the same upstream-maintenance reason. Keeping these assertions avoids unnecessary divergence from their source implementations; replacing them with production runtime checks, if required, should be evaluated separately.

This PR has been tested by:

  • Unit tests:
    • ./gradlew :common:test --tests org.tron.core.config.args.CommitteeConfigTest
    • ./gradlew :framework:test --tests org.tron.core.config.args.ArgsTest
    • ./gradlew -g /private/tmp/java-tron-gradle-home :framework:test --tests org.tron.core.tire.TrieTest
  • Coverage reports:
    • ./gradlew :common:jacocoTestReport :framework:jacocoTestReport
    • Verified zero missed instructions for CommitteeConfig.java:166 and Args.java:1048,1092.
  • Checkstyle:
    • ./gradlew :framework:checkstyleTest
  • Whitespace validation:
    • git diff --check

Follow up

Other startup failures and any replacement of upstream-derived assertions with explicit runtime checks should be evaluated separately according to their semantics and performance impact.

Extra details

  • Valid configuration and Trie behavior are unchanged.
  • No protocol, database, network, or performance impact is expected.
  • TrieImpl and Blake2bfMessageDigest are excluded from the assertion-removal scope.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e8d904ec-25a1-4906-9e94-8d770ceb1baf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bladehan1 bladehan1 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Automated review by the Codex review pipeline.

Decision: Approve with one concern
Findings: P0=0, P1=1, P2=0, nit=0

NOTE: This review contains AI suggestions; human reviewers retain final judgment.

.withFallback(ConfigFactory.defaultReference());

TronError error = Assert.assertThrows(TronError.class,
() -> Args.applyConfigParams(config));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

[SHOULD] Clear the shared Args state after the expected failure

Args.applyConfigParams(config) updates several shared Args/CommonParameter fields before CommitteeConfig.fromConfig() throws the expected TronError. This test does not call Args.clearParam(), and the class has no common @After cleanup, so the partially initialized configuration can leak into later tests that share the same JVM. The neighboring applyConfigParams tests already clear this state.

Suggestion: guarantee Args.clearParam() with try/finally around this assertion, or add equivalent cleanup that also covers exceptional exits.

Use TronError with PARAMETER_INIT for invalid startup configuration, remove assertions that are inactive at runtime, and cover the new error paths with unit tests.
@bladehan1
bladehan1 force-pushed the feature/opt_config_error branch from c95607d to 59af200 Compare August 7, 2026 07:09
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.

1 participant