Skip to content

fix(config): optimize config binding#77

Open
317787106 wants to merge 5 commits into
developfrom
hotfix/config_error
Open

fix(config): optimize config binding#77
317787106 wants to merge 5 commits into
developfrom
hotfix/config_error

Conversation

@317787106
Copy link
Copy Markdown
Owner

@317787106 317787106 commented May 9, 2026

What does this PR do?

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details


Summary by cubic

Optimizes node config binding by removing deprecated keys, fixing discovery external IP parsing, and consolidating JSON‑RPC limits. Clarifies shielded API precedence and removes its default from reference.conf.

  • Bug Fixes

    • Treat HOCON null and the string "null" as unset for node.discovery.external.ip; return empty when unset.
    • Use allowShieldedTransactionApi if set; otherwise fall back to fullNodeAllowShieldedTransaction with a deprecation warning. The modern key takes priority when both are set. Do not default allowShieldedTransactionApi in reference.conf.
    • Removed unused node bindings: connection/channel timeouts and Netty thread counts; pruned defaults in reference.conf/config.conf.
    • Removed redundant JSON-RPC fields (maxBlockFilterNum, maxAddressSize, maxRequestTimeout); route limits through jsonRpcMaxBatchSize/jsonRpcMaxResponseSize.
  • Migration

    • Remove these keys from custom configs (now ignored): node.connection.timeout, node.channel.read.timeout, node.tcpNettyWorkThreadNum, node.udpNettyWorkThreadNum, maxBlockFilterNum, maxAddressSize, maxRequestTimeout.

Written for commit 8fea4e7. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Removed network tuning parameters (connection timeout, channel read timeout, TCP/UDP thread sizing) from configuration defaults and public APIs.
  • Refactor
    • Simplified discovery external-IP handling to a direct property on node config.
  • Tests
    • Updated and expanded tests to reflect removed parameters and to cover shielded-transaction API behavior and external-IP parsing.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

📝 Walkthrough

Walkthrough

This PR removes deprecated networking configuration parameters across the codebase. CommonParameter loses timeout and thread-count fields; NodeConfig refactors external IP binding and shielded-API binding; defaults are removed; Args stops propagating the values; and tests and test configs are updated.

Changes

Network Configuration Deprecation

Layer / File(s) Summary
Remove Deprecated Networking Fields
common/src/main/java/org/tron/common/parameter/CommonParameter.java
CommonParameter removes four public int fields: nodeConnectionTimeout, nodeChannelReadTimeout, tcpNettyWorkThreadNum, and udpNettyWorkThreadNum.
Refactor NodeConfig Configuration Binding
common/src/main/java/org/tron/core/config/args/NodeConfig.java
NodeConfig adds explicit externalIP, suppresses Lombok auto-binding for allowShieldedTransactionApi, removes nested DiscoveryConfig.ExternalConfig, drops connection/channel convenience getters, and updates fromConfig() to explicitly read discovery.external.ip and allowShieldedTransactionApi.
Remove Configuration Defaults
common/src/main/resources/reference.conf
reference.conf removes node.connection.timeout, channel.read.timeout, tcpNettyWorkThreadNum, udpNettyWorkThreadNum, and other legacy defaults; allowShieldedTransactionApi default is commented out.
Stop Propagating Removed Values
framework/src/main/java/org/tron/core/config/args/Args.java, framework/src/main/resources/config.conf
Args.applyNodeConfig() no longer copies removed NodeConfig fields into CommonParameter; framework config.conf removes connection.timeout = 2.
NodeConfig Tests and External IP Handling
common/src/test/java/org/tron/core/config/args/NodeConfigTest.java
Removed timeout/channel assertions; expanded shielded-API tests; added tests for node.discovery.external.ip sentinel handling and valid value preservation.
Update Test Configuration Files
framework/src/test/resources/...
Test config files remove connection.timeout and related Netty thread-count settings where present.
Update Test Code Assertions
framework/src/test/java/org/tron/common/ParameterTest.java, framework/src/test/java/org/tron/core/config/args/ArgsTest.java
Removed assertions and setup that referenced the removed CommonParameter networking fields and Netty thread-counts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit nibbles old config lines,
Snips timeouts, threads, in tidy signs,
External IPs now gently parsed,
Tests adjusted, defaults unmasked —
Hopping on with code made fine. 🐇✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix(config): optimize config binding' is vague and doesn't clearly communicate the specific configuration optimizations being made. Consider using a more specific title that highlights the main change, such as 'fix(config): remove deprecated timeout and netty thread config parameters' or 'fix(config): consolidate and clean up node networking configuration'.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/config_error

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 and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="common/src/main/java/org/tron/core/config/args/NodeConfig.java">

<violation number="1" location="common/src/main/java/org/tron/core/config/args/NodeConfig.java:386">
P1: Legacy `fullNodeAllowShieldedTransaction` is never applied because `allowShieldedTransactionApi` is always present via defaults, making the `else if` fallback unreachable.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread common/src/main/java/org/tron/core/config/args/NodeConfig.java
…parameter binding

Remove maxBlockFilterNum, maxAddressSize, and maxRequestTimeout from NodeConfig/CommonParameter
since they were superseded by the jsonRpcMaxBatchSize/jsonRpcMaxResponseSize parameters.
Consolidate the config binding path so all JSON-RPC size limits flow through a single
reference.conf entry, and clean up stale test-config fixtures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@317787106 317787106 force-pushed the hotfix/config_error branch from 84265a1 to 30aa2c6 Compare May 9, 2026 16:45
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
common/src/test/java/org/tron/core/config/args/NodeConfigTest.java (1)

304-316: ⚡ Quick win

Misleading test name and duplicated test coverage.

The test testShieldedApiLegacyKeyRespected() suggests it should verify legacy key behavior, but lines 307-312 test the modern key (allowShieldedTransactionApi) and lines 313-315 test the empty config default. These scenarios are already covered by testShieldedApiModernKeyRespected() (lines 290-294) and testShieldedApiDefaultsToFalseWhenNeitherKeySet() (lines 284-287).

Consider limiting this test to only legacy key scenarios or renaming it to reflect the broader coverage (e.g., testShieldedApiAcrossVariousConfigurations()).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@common/src/test/java/org/tron/core/config/args/NodeConfigTest.java` around
lines 304 - 316, The test method testShieldedApiLegacyKeyRespected() currently
duplicates coverage of modern-key and default cases; either restrict it to only
verify the legacy configuration key behavior (call NodeConfig.fromConfig with
withRef("node.fullNodeAllowShieldedTransaction = true") and
withRef("node.fullNodeAllowShieldedTransaction = false") and assert via
nc.isAllowShieldedTransactionApi()) or rename the test to something like
testShieldedApiAcrossVariousConfigurations() to reflect that it intentionally
covers legacy, modern (withRef("node.allowShieldedTransactionApi =
true"/"false")), and default (withRef("")) cases; update assertions and method
name accordingly so coverage is not redundant with
testShieldedApiModernKeyRespected() and
testShieldedApiDefaultsToFalseWhenNeitherKeySet().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@common/src/test/java/org/tron/core/config/args/NodeConfigTest.java`:
- Line 320: The inline comment is incorrect: update the comment above
testShieldedApiModernKeyTakesPriorityOverLegacy to reflect that the modern key
(allowShieldedTransactionApi) takes priority over the legacy key (not the other
way around); locate the comment near the test method name
NodeConfigTest::testShieldedApiModernKeyTakesPriorityOverLegacy and replace the
text "legacy key presence wins over modern" with a phrase like "modern key
presence wins over legacy (allowShieldedTransactionApi takes priority)" so it
matches the assertions in the test.

---

Nitpick comments:
In `@common/src/test/java/org/tron/core/config/args/NodeConfigTest.java`:
- Around line 304-316: The test method testShieldedApiLegacyKeyRespected()
currently duplicates coverage of modern-key and default cases; either restrict
it to only verify the legacy configuration key behavior (call
NodeConfig.fromConfig with withRef("node.fullNodeAllowShieldedTransaction =
true") and withRef("node.fullNodeAllowShieldedTransaction = false") and assert
via nc.isAllowShieldedTransactionApi()) or rename the test to something like
testShieldedApiAcrossVariousConfigurations() to reflect that it intentionally
covers legacy, modern (withRef("node.allowShieldedTransactionApi =
true"/"false")), and default (withRef("")) cases; update assertions and method
name accordingly so coverage is not redundant with
testShieldedApiModernKeyRespected() and
testShieldedApiDefaultsToFalseWhenNeitherKeySet().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47c8a6a0-c6f4-4689-9e69-ae8cdd5f504b

📥 Commits

Reviewing files that changed from the base of the PR and between 84265a1 and 5b3cbc0.

📒 Files selected for processing (14)
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
  • common/src/main/java/org/tron/core/config/args/NodeConfig.java
  • common/src/main/resources/reference.conf
  • common/src/test/java/org/tron/core/config/args/NodeConfigTest.java
  • framework/src/main/java/org/tron/core/config/args/Args.java
  • framework/src/main/resources/config.conf
  • framework/src/test/java/org/tron/common/ParameterTest.java
  • framework/src/test/java/org/tron/core/config/args/ArgsTest.java
  • framework/src/test/resources/args-test.conf
  • framework/src/test/resources/config-localtest.conf
  • framework/src/test/resources/config-test-index.conf
  • framework/src/test/resources/config-test-mainnet.conf
  • framework/src/test/resources/config-test-storagetest.conf
  • framework/src/test/resources/config-test.conf
💤 Files with no reviewable changes (10)
  • framework/src/test/resources/config-test-storagetest.conf
  • framework/src/test/resources/config-localtest.conf
  • framework/src/test/resources/config-test-index.conf
  • framework/src/test/resources/config-test-mainnet.conf
  • framework/src/test/java/org/tron/core/config/args/ArgsTest.java
  • framework/src/test/resources/args-test.conf
  • framework/src/test/resources/config-test.conf
  • framework/src/main/resources/config.conf
  • framework/src/test/java/org/tron/common/ParameterTest.java
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • framework/src/main/java/org/tron/core/config/args/Args.java
  • common/src/main/resources/reference.conf
  • common/src/main/java/org/tron/core/config/args/NodeConfig.java

Comment thread common/src/test/java/org/tron/core/config/args/NodeConfigTest.java Outdated
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