Skip to content

refactor(config): merge config files with BeanDefaults fallback#76

Open
317787106 wants to merge 10 commits into
hotfix/restrict_jsonrpc_sizefrom
hotfix/fix_dup_config
Open

refactor(config): merge config files with BeanDefaults fallback#76
317787106 wants to merge 10 commits into
hotfix/restrict_jsonrpc_sizefrom
hotfix/fix_dup_config

Conversation

@317787106
Copy link
Copy Markdown
Owner

@317787106 317787106 commented May 5, 2026

What does this PR do?

Eliminates reference.conf and makes Java bean field initializers the single source of truth for configuration defaults.

Previously, configuration defaults were maintained in two places:

  1. Java bean field initializers (e.g., private int maxConnections = 30)
  2. common/src/main/resources/reference.conf (HOCON fallback loaded automatically by Typesafe Config)

Any new config field or default value change required keeping both in sync. reference.conf was invisible to most developers and frequently fell out of date.

Core change: Introduce BeanDefaults, a utility that serializes a bean instance's current field values into a Typesafe Config object. Each XxxConfig.fromConfig() now calls BeanDefaults.toConfig(new XxxConfig()) and uses it as a withFallback(), so ConfigBeanFactory always finds every key it needs — even when the user's config.conf only sets a subset of fields.

Specific changes:

  • Add BeanDefaults.java: reflects public getter+setter pairs via BeanInfo, recurses into nested beans, serializes lists — mirrors exactly what ConfigBeanFactory binds
  • Update all XxxConfig.fromConfig() methods (BlockConfig, CommitteeConfig, EventConfig, GenesisConfig, MetricsConfig, NodeConfig, RateLimiterConfig, StorageConfig, VmConfig): replace hard config.getConfig(section) calls with hasPath guard + withFallback(BeanDefaults.toConfig(...)); all classes now use an explicit userSection variable to hold the user's raw values before merging with defaults
  • Remove reference.conf: no longer needed; BeanDefaults replaces its role
  • Update Configuration.java: remove the withFallback(ConfigFactory.defaultReference()) call from the file-based load path
  • Update config.conf: add previously undocumented parameters that were silently defaulted through reference.conf (e.g. storage.backup, storage.checkpoint, node.maxFastForwardNum, rate.limiter.p2p.*, etc.)
  • Add BeanDefaultsTest.java: 16 tests covering default values, round-trip with ConfigBeanFactory, and user-value override for all major config beans

Why are these changes required?

1. Dual-source maintenance with no compile-time enforcement

The dual-source maintenance created recurring issues:

  • Developers adding a new config field to a bean had to also add it to reference.conf, with no compile-time enforcement of that requirement
  • reference.conf was not visible to users browsing source code or Java docs
  • Divergence between Java defaults and reference.conf defaults was only caught at runtime
  • Users reading reference.conf could not tell which keys were still active vs. superseded by bean logic

After this change, the only place a developer needs to touch to add a new config parameter is the Java bean class.

2. node.discovery.external.ip = null in reference.conf caused startup failure

The old reference.conf contained:

node.discovery.external.ip = null

When Typesafe Config merged this with the user's config.conf, the null value propagated into the merged config. ConfigBeanFactory would then attempt to bind null to the String field, causing a startup crash even when the user had not set this key at all. This PR introduces BeanDefaults.stripNullLeaves(), which strips all HOCON null leaves from the user section before merging with bean defaults — so a user's explicit null entry never overwrites a valid Java default.

3. allowShieldedTransactionApi priority was silently broken

When both node.allowShieldedTransactionApi (modern) and node.fullNodeAllowShieldedTransaction (legacy) were present in config.conf, the modern key should take precedence. The original fallback logic checked section.hasPath("allowShieldedTransactionApi"), but section is the merged config (user values + BeanDefaults), which always contains allowShieldedTransactionApi from the defaults — making the condition always true and the entire legacy-key branch dead code. As a result, a user who set only fullNodeAllowShieldedTransaction would silently get the default value instead of their configured value.

Fixed by checking userSection.hasPath() (the raw user-supplied values only) instead of section.hasPath(). The correct semantics are now enforced and covered by tests:

  • Only modern key set → modern key used
  • Only legacy key set → legacy key used (with deprecation warning)
  • Both keys set → modern key takes precedence
  • Neither set → code default (true)

4. Legacy-key fallback pattern relied on an implicit invariant that was easy to break

Before this PR, six XxxConfig.fromConfig() methods used an inline one-step form:

Config section = config.hasPath("vm")
    ? BeanDefaults.stripNullLeaves(config.getConfig("vm")).withFallback(defaults)
    : defaults;

This form does not expose the raw user values as a named variable. Any developer adding a legacy-key fallback (like the allowShieldedTransactionApi case above) would be tempted to write section.hasPath() — which checks the merged config and silently makes the fallback dead code. All six classes now use the two-step form with an explicit userSection variable:

Config userSection = config.hasPath("vm")
    ? BeanDefaults.stripNullLeaves(config.getConfig("vm"))
    : ConfigFactory.empty();
Config section = userSection.withFallback(defaults);

The naming makes the invariant obvious: userSection is what the user wrote; section is the merged result. Future legacy-key checks must use userSection.hasPath().

This PR has been tested by:

  • Unit Tests (BeanDefaultsTest, NodeConfigTest, BlockConfigTest, VmConfigTest, StorageConfigTest, CommitteeConfigTest, EventConfigTest, GenesisConfigTest, MetricsConfigTest, RateLimiterConfigTest — all pass)
  • Manual Testing

Summary by CodeRabbit

Release Notes

  • New Features

    • Added advanced metrics configuration options for InfluxDB integration
    • Introduced new performance tuning parameters for storage, networking, and rate limiting
  • Bug Fixes

    • Improved handling of missing configuration sections to prevent startup failures
    • Enhanced null value handling in configuration files
  • Refactor

    • Streamlined configuration system with modernized default value handling
    • Removed bundled configuration defaults file for simplified setup
  • Removals

    • Removed Overlay port configuration feature

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

Run ID: 750820ae-8fd5-4cf1-a195-0521a1e0f167

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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request replaces bundled Typesafe Config defaults (reference.conf) with JavaBean-introspection-based defaults. The BeanDefaults utility converts bean instances to Config objects, strips null leaves, and remaps legacy keys. Configuration classes now build defaults from bean instances and conditionally merge user-provided sections via fallback, tolerating missing configuration paths. The framework config is expanded with storage, node, and rate-limiter tuning. Tests are updated to reflect the new defaults behavior and use empty config fallbacks instead of reference defaults. The Overlay configuration class and its usage are removed.

Changes

Bean Defaults Infrastructure

Layer / File(s) Summary
BeanDefaults utility
common/src/main/java/org/tron/core/config/BeanDefaults.java
New utility class with toConfig(Object bean) converting beans via introspection, stripNullLeaves(Config) removing null-typed leaves, and remapKey(Config, fromKey, toKey) for key migration.
Configuration parsing
common/src/main/java/org/tron/core/config/Configuration.java
Stop applying ConfigFactory.defaultReference() fallback when parsing explicit config files; clarify system property merge behavior in classpath load comment.

Per-Configuration Class Migrations

Layer / File(s) Summary
BlockConfig, CommitteeConfig, EventConfig, GenesisConfig, MetricsConfig, NodeConfig, RateLimiterConfig, StorageConfig, VmConfig
common/src/main/java/org/tron/core/config/args/*
Each config class now builds defaults via BeanDefaults.toConfig(new X()), conditionally reads user section (or empty config when missing), strips null leaves, remaps legacy keys where needed, and merges via withFallback(defaults) before binding.
CommitteeConfig field changes
common/src/main/java/org/tron/core/config/args/CommitteeConfig.java
allowPBFT / pBFTExpireNum changed from special-cased fields to regular long properties for automatic config binding; pBFTExpireNum key remapped to PBFTExpireNum.
NodeConfig accessors
common/src/main/java/org/tron/core/config/args/NodeConfig.java
Added explicit public getter methods for isOpenFullTcpDisconnect, discovery/shutdown settings, and nested bean convenience accessors; removed custom PBFT accessor methods from HTTP/RPC sub-beans; legacy PBFT keys remapped from pBFT* to PBFT* format.
MetricsConfig nesting
common/src/main/java/org/tron/core/config/args/MetricsConfig.java
New nested InfluxDbConfig class with default ip/port/database/metricsReportInterval values.
StorageConfig field access
common/src/main/java/org/tron/core/config/args/StorageConfig.java
Simplified field declarations for rawStorageConfig and DB options; removed merkleRoot field; setters excluded from auto-binding while getters generated via Lombok.

Default Source Deletion

Layer / File(s) Summary
reference.conf deletion
common/src/main/resources/reference.conf
Removed bundled 835-line Typesafe Config defaults file; all defaults now provided by BeanDefaults.toConfig() from bean instances.

Framework Configuration Updates

Layer / File(s) Summary
Storage tuning
framework/src/main/resources/config.conf
Added index.directory, index.switch; reintroduced LevelDB tier blocks (default, defaultM, defaultL); set checkpoint (version=1, sync=true), txCache (estimatedTransactions=1000), snapshot (maxFlushCount=1).
Node core settings
framework/src/main/resources/config.conf
Cleared trustNode, set walletExtensionApi=false, increased fetchBlock.timeout from 200 to 500; added discovery external IP guidance comment.
Node tuning keys
framework/src/main/resources/config.conf
Added p2p/networking/concurrency parameters: maxFastForwardNum, Netty thread counts, pending pool caps/timeouts, blockCacheTimeout, receiveTcpMinDataLength, consensus agreeNodeCount, metricsEnable, channel.read.timeout, validContractProto.threads.
RPC/rate-limiter
framework/src/main/resources/config.conf
Disabled node.rpc.trxCacheEnable; added rate.limiter.p2p strategy weights; set global.api.qps=1000; added legacy-typo config comment stub.

Test Updates

Layer / File(s) Summary
BeanDefaults tests
common/src/test/java/org/tron/core/config/BeanDefaultsTest.java
New tests for stripNullLeaves() removing null-valued leaves and NodeConfig.fromConfig() tolerating null external IP values.
Configuration tests
common/src/test/java/org/tron/core/config/args/*Test.java, framework/src/test/java/org/tron/core/config/args/ArgsTest.java
Updated EventConfigTest, GenesisConfigTest, NodeConfigTest to reflect new bean defaults (empty topics/assets/witnesses); replaced ConfigFactory.defaultReference() with ConfigFactory.empty() in ArgsTest timeout tests; updated RPC sentinel values to MAX_VALUE; renamed and flipped shielded API priority test expectation.
CommonParameter tests
framework/src/test/java/org/tron/common/ParameterTest.java
Removed assertion for getOverlay() returning null; added assertions for rate limiter setters/getters.

Overlay Removal

Layer / File(s) Summary
Overlay class deletion
common/src/main/java/org/tron/core/config/args/Overlay.java
Removed class with port field and setPort(int) validation (range [0,65535]).
CommonParameter cleanup
common/src/main/java/org/tron/common/parameter/CommonParameter.java
Removed Overlay import and overlay field from startup parameters.
OverlayTest deletion
framework/src/test/java/org/tron/core/config/args/OverlayTest.java
Removed JUnit test class verifying port bounds and getter behavior.

Import Cleanup

Layer / File(s) Summary
Unused imports
framework/src/main/java/org/tron/core/config/args/Args.java
Removed unused NetUtil import.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 With beans now bearing defaults bright,
No reference.conf to fight,
Each config class shall merge with care,
Null leaves stripped from thin air,
Fallback safe when paths aren't there! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main refactoring: consolidating configuration defaults by using BeanDefaults as a fallback instead of reference.conf.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/fix_dup_config

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@317787106 317787106 changed the title refactor(config): optimize config file refactor(config): eliminate reference.conf with BeanDefaults fallback May 5, 2026
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 15 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/Configuration.java">

<violation number="1" location="common/src/main/java/org/tron/core/config/Configuration.java:51">
P1: `parseFile(confFile)` drops the default `reference.conf` fallback, so file-based config loading can lose required defaults and diverge from classpath loading behavior.</violation>
</file>

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

if (confFile.exists()) {
config = ConfigFactory.parseFile(confFile)
.withFallback(ConfigFactory.defaultReference());
config = ConfigFactory.parseFile(confFile);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: parseFile(confFile) drops the default reference.conf fallback, so file-based config loading can lose required defaults and diverge from classpath loading behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At common/src/main/java/org/tron/core/config/Configuration.java, line 51:

<comment>`parseFile(confFile)` drops the default `reference.conf` fallback, so file-based config loading can lose required defaults and diverge from classpath loading behavior.</comment>

<file context>
@@ -48,10 +48,11 @@ public static com.typesafe.config.Config getByFileName(
     if (confFile.exists()) {
-      config = ConfigFactory.parseFile(confFile)
-          .withFallback(ConfigFactory.defaultReference());
+      config = ConfigFactory.parseFile(confFile);
     } else if (Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)
         != null) {
</file context>
Suggested change
config = ConfigFactory.parseFile(confFile);
config = ConfigFactory.parseFile(confFile)
.withFallback(ConfigFactory.defaultReference());

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
common/src/main/java/org/tron/core/config/args/StorageConfig.java (1)

115-123: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

DbSettingsConfig and TxCacheConfig bean defaults diverge from config.conf production values

Following the same pattern as NodeConfig, several StorageConfig field defaults don't match the values that config.conf establishes. Operators using custom partial configs will silently receive suboptimal LevelDB tuning and incorrect cache initialization behavior:

Location Field Bean default config.conf value
Line 117 DbSettingsConfig.blocksize 16 64
Line 120 DbSettingsConfig.level0FileNumCompactionTrigger 2 4
Line 121 DbSettingsConfig.targetFileSizeBase 64 256
Line 182 TxCacheConfig.initOptimization false true

The LevelDB tuning mismatches (blocksize, level0FileNumCompactionTrigger, targetFileSizeBase) can significantly degrade storage performance. initOptimization = false makes transaction cache initialization slower on startup.

🛠️ Proposed fix
-   private int blocksize = 16;
+   private int blocksize = 64;
-   private int level0FileNumCompactionTrigger = 2;
+   private int level0FileNumCompactionTrigger = 4;
-   private long targetFileSizeBase = 64;
+   private long targetFileSizeBase = 256;
-   private boolean initOptimization = false;
+   private boolean initOptimization = true;

Also applies to: 180-183

🤖 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/main/java/org/tron/core/config/args/StorageConfig.java` around
lines 115 - 123, StorageConfig's LevelDB tuning defaults and TxCacheConfig's
initOptimization need to match production config.conf values: update
StorageConfig fields blocksize to 64, level0FileNumCompactionTrigger to 4, and
targetFileSizeBase to 256, and set TxCacheConfig.initOptimization to true so
partial/bean-based configs behave like the shipped config; locate and change the
default field initializers in the StorageConfig (blocksize,
level0FileNumCompactionTrigger, targetFileSizeBase) and the TxCacheConfig class
(initOptimization) accordingly.
common/src/main/java/org/tron/core/config/args/NodeConfig.java (1)

35-35: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Bean defaults diverge from config.conf values — behavioral regressions for custom configs

With reference.conf removed, the bean field initializers now define the effective defaults for any deployment that doesn't explicitly set a key. Several of these defaults contradict the values that config.conf (and implicitly the old reference.conf) established:

Location Field Bean default config.conf value
Line 35 minParticipationRate 0 15
Line 69 blockProducedTimeOut 50 documented as 75 (line 322 comment)
Line 135 DiscoveryConfig.enable false true
Line 136 DiscoveryConfig.persist false true
Line 261 RpcConfig.maxConnectionIdleInMillis Long.MAX_VALUE 60000

The most impactful regressions for operators running custom configs:

  • minParticipationRate = 0 disables the participation-rate guard on block production entirely.
  • discovery.enable = false and discovery.persist = false silently disable peer discovery.
  • maxConnectionIdleInMillis = Long.MAX_VALUE means idle gRPC connections are never terminated.

Align the bean field initializers with the intended production defaults:

🛠️ Proposed fix
-  private int minParticipationRate = 0;
+  private int minParticipationRate = 15;
-  private int blockProducedTimeOut = 50;
+  private int blockProducedTimeOut = 75;
  public static class DiscoveryConfig {
-   private boolean enable = false;
-   private boolean persist = false;
+   private boolean enable = true;
+   private boolean persist = true;
-  private long maxConnectionIdleInMillis = Long.MAX_VALUE;
+  private long maxConnectionIdleInMillis = 60000;

Also applies to: 69-69, 135-136, 261-261

🤖 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/main/java/org/tron/core/config/args/NodeConfig.java` at line 35,
The bean field initializers in NodeConfig and nested configs no longer match the
intended production defaults in config.conf; update the default values so
minParticipationRate = 15 (not 0), blockProducedTimeOut = 75 (not 50),
DiscoveryConfig.enable = true and DiscoveryConfig.persist = true (not false),
and RpcConfig.maxConnectionIdleInMillis = 60000 (not Long.MAX_VALUE) by changing
the field initializers for minParticipationRate, blockProducedTimeOut,
DiscoveryConfig.enable, DiscoveryConfig.persist, and
RpcConfig.maxConnectionIdleInMillis to those values so runtime defaults match
the documented config.conf behavior.
🤖 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/main/java/org/tron/core/config/BeanDefaults.java`:
- Around line 48-72: The current outer try-catch around
Introspector.getBeanInfo(...) and the PropertyDescriptor loop swallows any
Exception (in BeanDefaults.java) so a single getter.invoke(bean) failure aborts
the rest of the loop; move the per-property error handling inside the
for(PropertyDescriptor pd : info.getPropertyDescriptors()) loop by wrapping only
the getter.invoke(bean)/map.put(key, toValue(value)) lines in a try-catch that
handles and ignores/logs per-property invocation exceptions, and reduce the
outer catch to only handle IntrospectionException from Introspector.getBeanInfo;
keep references to Introspector.getBeanInfo, PropertyDescriptor,
pd.getReadMethod()/getWriteMethod(), getter.invoke(bean), map.put(key,
toValue(value)) when making the change.

---

Outside diff comments:
In `@common/src/main/java/org/tron/core/config/args/NodeConfig.java`:
- Line 35: The bean field initializers in NodeConfig and nested configs no
longer match the intended production defaults in config.conf; update the default
values so minParticipationRate = 15 (not 0), blockProducedTimeOut = 75 (not 50),
DiscoveryConfig.enable = true and DiscoveryConfig.persist = true (not false),
and RpcConfig.maxConnectionIdleInMillis = 60000 (not Long.MAX_VALUE) by changing
the field initializers for minParticipationRate, blockProducedTimeOut,
DiscoveryConfig.enable, DiscoveryConfig.persist, and
RpcConfig.maxConnectionIdleInMillis to those values so runtime defaults match
the documented config.conf behavior.

In `@common/src/main/java/org/tron/core/config/args/StorageConfig.java`:
- Around line 115-123: StorageConfig's LevelDB tuning defaults and
TxCacheConfig's initOptimization need to match production config.conf values:
update StorageConfig fields blocksize to 64, level0FileNumCompactionTrigger to
4, and targetFileSizeBase to 256, and set TxCacheConfig.initOptimization to true
so partial/bean-based configs behave like the shipped config; locate and change
the default field initializers in the StorageConfig (blocksize,
level0FileNumCompactionTrigger, targetFileSizeBase) and the TxCacheConfig class
(initOptimization) accordingly.
🪄 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: b8081123-e5d7-4bd1-b04d-84076b781203

📥 Commits

Reviewing files that changed from the base of the PR and between 22e0aa3 and c8b53b6.

📒 Files selected for processing (15)
  • common/src/main/java/org/tron/core/config/BeanDefaults.java
  • common/src/main/java/org/tron/core/config/Configuration.java
  • common/src/main/java/org/tron/core/config/args/BlockConfig.java
  • common/src/main/java/org/tron/core/config/args/CommitteeConfig.java
  • common/src/main/java/org/tron/core/config/args/EventConfig.java
  • common/src/main/java/org/tron/core/config/args/GenesisConfig.java
  • common/src/main/java/org/tron/core/config/args/MetricsConfig.java
  • common/src/main/java/org/tron/core/config/args/NodeConfig.java
  • common/src/main/java/org/tron/core/config/args/RateLimiterConfig.java
  • common/src/main/java/org/tron/core/config/args/StorageConfig.java
  • common/src/main/java/org/tron/core/config/args/VmConfig.java
  • common/src/main/resources/reference.conf
  • common/src/test/java/org/tron/core/config/BeanDefaultsTest.java
  • framework/src/main/resources/config.conf
  • framework/src/test/java/org/tron/core/config/args/ArgsTest.java
💤 Files with no reviewable changes (1)
  • common/src/main/resources/reference.conf

Comment thread common/src/main/java/org/tron/core/config/BeanDefaults.java
@317787106 317787106 changed the title refactor(config): eliminate reference.conf with BeanDefaults fallback refactor(config): merge config files with BeanDefaults fallback May 7, 2026
317787106 and others added 3 commits May 7, 2026 21:56
Resolve conflict by keeping deletion of common/src/main/resources/reference.conf,
which is intentional — BeanDefaults replaces its role in this branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rible; fix the bug of allowShieldedTransactionApi
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 20 files (changes from recent commits).

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/BeanDefaults.java">

<violation number="1" location="common/src/main/java/org/tron/core/config/BeanDefaults.java:72">
P2: remapKey should not overwrite an already-present canonical key; legacy key remapping currently changes user precedence when both keys are set.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

if (!config.hasPath(fromKey)) {
return config;
}
return config.withValue(toKey, config.getValue(fromKey)).withoutPath(fromKey);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: remapKey should not overwrite an already-present canonical key; legacy key remapping currently changes user precedence when both keys are set.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At common/src/main/java/org/tron/core/config/BeanDefaults.java, line 72:

<comment>remapKey should not overwrite an already-present canonical key; legacy key remapping currently changes user precedence when both keys are set.</comment>

<file context>
@@ -43,6 +46,45 @@ public static Config toConfig(Object bean) {
+    if (!config.hasPath(fromKey)) {
+      return config;
+    }
+    return config.withValue(toKey, config.getValue(fromKey)).withoutPath(fromKey);
+  }
+
</file context>

Tip: Review your code locally with the cubic CLI to iterate faster.

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

🤖 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/main/java/org/tron/core/config/args/MetricsConfig.java`:
- Around line 29-36: MetricsConfig currently doesn’t expose the nested
InfluxDbConfig so defaults and bindings are ignored; add a field of type
InfluxDbConfig with getter/setter (and initialize it to new InfluxDbConfig())
inside the MetricsConfig class so BeanDefaults.toConfig(new MetricsConfig()) and
ConfigBeanFactory.create(...) can pick up defaults and user values; refer to the
nested class name InfluxDbConfig and the outer class MetricsConfig when adding
the private InfluxDbConfig influxDb = new InfluxDbConfig() plus corresponding
getInfluxDb()/setInfluxDb() methods.
🪄 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: 01466168-62f3-4d53-9b90-e424317c6d22

📥 Commits

Reviewing files that changed from the base of the PR and between 650e8e1 and 627b85d.

📒 Files selected for processing (12)
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
  • common/src/main/java/org/tron/core/config/BeanDefaults.java
  • common/src/main/java/org/tron/core/config/args/CommitteeConfig.java
  • common/src/main/java/org/tron/core/config/args/MetricsConfig.java
  • common/src/main/java/org/tron/core/config/args/NodeConfig.java
  • common/src/main/java/org/tron/core/config/args/StorageConfig.java
  • common/src/main/java/org/tron/core/config/args/VmConfig.java
  • 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
💤 Files with no reviewable changes (3)
  • common/src/main/java/org/tron/common/parameter/CommonParameter.java
  • framework/src/main/java/org/tron/core/config/args/Args.java
  • framework/src/test/java/org/tron/common/ParameterTest.java
🚧 Files skipped from review as they are similar to previous changes (6)
  • common/src/main/java/org/tron/core/config/args/CommitteeConfig.java
  • common/src/main/java/org/tron/core/config/args/VmConfig.java
  • common/src/test/java/org/tron/core/config/args/NodeConfigTest.java
  • common/src/main/java/org/tron/core/config/BeanDefaults.java
  • framework/src/test/java/org/tron/core/config/args/ArgsTest.java
  • common/src/main/java/org/tron/core/config/args/NodeConfig.java

Comment on lines +29 to +36
@Getter
@Setter
public static class InfluxDbConfig {
private String ip = "";
private int port = 8086;
private String database = "metrics";
private int metricsReportInterval = 10;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Wire InfluxDbConfig into MetricsConfig so it can actually bind.

InfluxDbConfig is declared, but MetricsConfig has no corresponding field/getter. As a result, Line 39 (BeanDefaults.toConfig(new MetricsConfig())) and Line 44 (ConfigBeanFactory.create(...)) will ignore these defaults and user values.

Suggested fix
 public class MetricsConfig {

   private PrometheusConfig prometheus = new PrometheusConfig();
+  private InfluxDbConfig influxDb = new InfluxDbConfig();

   `@Getter`
   `@Setter`
   public static class PrometheusConfig {
🤖 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/main/java/org/tron/core/config/args/MetricsConfig.java` around
lines 29 - 36, MetricsConfig currently doesn’t expose the nested InfluxDbConfig
so defaults and bindings are ignored; add a field of type InfluxDbConfig with
getter/setter (and initialize it to new InfluxDbConfig()) inside the
MetricsConfig class so BeanDefaults.toConfig(new MetricsConfig()) and
ConfigBeanFactory.create(...) can pick up defaults and user values; refer to the
nested class name InfluxDbConfig and the outer class MetricsConfig when adding
the private InfluxDbConfig influxDb = new InfluxDbConfig() plus corresponding
getInfluxDb()/setInfluxDb() methods.

@317787106 317787106 changed the base branch from develop to hotfix/restrict_jsonrpc_size May 9, 2026 15:18
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