Skip to content

fix(config): reject negative rpc connection idle/age at startup - #7113

Merged
kuny0707 merged 3 commits into
tronprotocol:release_v4.8.3from
warku123:fix/jt-939-rpc-idle-negative
Nov 20, 2026
Merged

kuny0707 merged 3 commits into
tronprotocol:release_v4.8.3from
warku123:fix/jt-939-rpc-idle-negative

Conversation

@warku123

@warku123 warku123 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Rejects negative node.rpc.maxConnectionIdleInMillis / node.rpc.maxConnectionAgeInMillis at config parsing time in NodeConfig.postProcess(), throwing TronError(PARAMETER_INIT) — the same handling already applied to maxRstStream, secondsPerWindow and maxConcurrentCallsPerConnection in the same method.

Updates common/build.gradle so the common JaCoCo report includes execution data from both common and framework tests.

Why are these changes required?

A negative value is currently passed through to NettyServerBuilder.maxConnectionIdle / maxConnectionAge, which throws IllegalArgumentException("max connection idle must be positive") on the main thread when the RPC service starts. ExitManager's uncaught handler only exits on TronError, so the main thread dies, no port listens, but the non-daemon threads started earlier (pbft-timer, rewardViCalService, hit-thread) keep the JVM alive — the process hangs in a dead state until killed manually.

With this change the value is rejected during Args.setParam, before the database and any services are created. ExitManager.initExceptionHandler() is already installed at that point (FullNode.java), so the node fails fast with a clear config error and exits cleanly.

Notes for reviewers: 0 = no limit semantics are unchanged, positive values are unchanged, and a negative value has never been a working configuration (it always crashed at RPC init), so no previously-valid setup is affected and no fork gate is needed.

The report previously used setFrom(...) with only the framework execution data, so it omitted coverage from NodeConfigTest even though the test ran. Including both inputs restores that coverage and keeps credit for common code exercised by framework tests.

This PR has been tested by:

  • Unit Tests: new NodeConfigTest.testRpcNegativeConnectionIdleAndAgeRejected; the full class (42 tests) and the whole :common:test module suite pass.
  • Coverage Gate: changed-line coverage went from 33% to 100% without changing the CI thresholds.

Follow up

Validate flowControlWindow and maxHeaderListSize at startup, and handle config validation failures in DynamicArgs so a rejected reload does not stop future reloads.

@warku123

Copy link
Copy Markdown
Contributor Author

The Coverage Gate failure on the first push was caused by a pre-existing jacoco wiring bug in common/build.gradle, not by missing tests.

common's jacocoTestReport configured its execution data like this:

getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))

setFrom replaces the default execution data, so common's own build/jacoco/test.exec was never read — coverage contributed by common's own tests was silently dropped from the report. Only framework's tests (which load common classes through Args / NodeConfig) were counted.

This predates this PR. In the base artifact (jacoco-coverage-base), the maxConnectionIdleInMillis == 0 → Long.MAX_VALUE assignment line shows as missed too, even though NodeConfigTest.testRpcExplicitZeroIdleAndAgeMeansUnlimited covers it — that test's execution data was excluded the same way. This PR just happened to be the first change whose new lines are only reachable from common's own tests (the two negative-value throws), so the changed-line gate dropped to 33% (the if lines were still covered via framework's tests loading fromConfig).

The second commit (9e5ee40a67) fixes the wiring by including both sources:

getExecutionData().setFrom(
    fileTree("$buildDir/jacoco").include("**.exec"),
    fileTree('../framework/build/jacoco').include("**.exec"))

common's own tests now count toward its report, and the original intent — crediting common classes exercised by framework's tests — is preserved. All other modules use the Gradle default (their own exec data only), so this affects only common's report and only by adding coverage. Verified locally: with the fix, both new throw lines are covered by NodeConfigTest and the changed-line gate clears.

@SeriousCoding789

Copy link
Copy Markdown
Contributor

The fix looks right to me: a negative value never worked, and rejecting it in NodeConfig.postProcess exits cleanly through ExitManager before any service starts. The jacoco change also matches the explanation above.

One observation: three other node.rpc values go from the config to NettyServerBuilder in RpcService.initServerBuilder without a check, and grpc-netty 1.85.0 rejects them the same way, so they would leave the same hung process:

  • flowControlWindow ≤ 0 (flowControlWindow must be positive)
  • maxHeaderListSize ≤ 0 (goes through maxInboundMetadataSize, which must be positive)
  • maxMessageSize < 0 (bytes must be non-negative)

Rejecting them in postProcess next to these two would cover this class of config errors. Turning an exception from initServerBuilder into a TronError would also cover values added later.

A smaller note, outside this PR: DynamicArgs reloads through NodeConfig.fromConfig but catches only Exception, so a TronError from postProcess during a reload ends the reload task for the rest of the run. That already applies to maxRstStream and the others, and these two checks add two more cases. The PR description does not mention the common/build.gradle change yet, which matters if the commits are squashed.

@warku123

Copy link
Copy Markdown
Contributor Author

@SeriousCoding789 I confirmed that flowControlWindow and maxHeaderListSize still reach gRPC without a positivity check. Negative maxMessageSize values are already rejected in NodeConfig.postProcess(). I'd keep this PR focused on idle/age and validate the other two in postProcess() as a follow-up so they fail before RPC initialization.

The reload issue is separate: DynamicArgs catches Exception, but TronError extends Error, so a validation failure can stop future reloads. I've noted that as a follow-up too.

I added the common/build.gradle change and the Coverage Gate result to the PR description for the squash merge. One correction to my earlier coverage comment: other modules also customize their JaCoCo inputs. This change only affects common's report, which now reads both its own execution data and framework's.

rpc.secondsPerWindow = RpcConfig.DEFAULT_SECONDS_PER_WINDOW;
}
if (rpc.maxConnectionIdleInMillis < 0) {
throw new TronError("node.rpc.maxConnectionIdleInMillis must be non-negative, got: "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The startup validation looks reasonable, but these checks also affect DynamicArgs.reload(), which calls NodeConfig.fromConfig().

If either value becomes negative during a config reload, TronError bypasses the existing catch (Exception) because it extends Error. The scheduled task then fails, and scheduleWithFixedDelay suppresses subsequent executions. The node keeps running, but peer configuration updates stop permanently, even after the file is corrected.

For context, #7015 introduced this failure path for maxRstStream and secondsPerWindow; those checks were absent in v4.8.2. This PR adds two more triggers for idle/age. The underlying reload issue predates #7015, though, since v4.8.2 already had TronError checks for negative maxMessageSize values in the same parsing path.

Could we isolate dynamic peer reload from startup-wide validation? DynamicArgs only applies node.active and node.passive, so a small change in DynamicArgs.java should be sufficient:

Config config = Configuration.getByFileName(Args.getConfigFilePath());

List<InetSocketAddress> active = Args.filterInetSocketAddress(
    config.getStringList("node.active"), true);
List<InetSocketAddress> passive = Args.filterInetSocketAddress(
    config.getStringList("node.passive"), false);

updateActiveNodes(active);
updateTrustNodes(passive);

The two private update methods would accept the parsed lists and retain their existing update logic. Parsing both lists before modifying state prevents a malformed passive list from leaving the active list partially updated. Configuration.getByFileName() already applies the reference configuration fallback.

This preserves strict startup validation while keeping unrelated settings out of peer reload. Please add regression tests covering:

  • Invalid RPC values do not block peer updates.
  • Malformed peer lists preserve the current state, and a subsequent corrected reload succeeds.

Parse both peer lists before updating runtime state. Avoid validating unrelated startup settings during reload and keep the previous peer configuration if either list cannot be parsed.
@kuny0707
kuny0707 merged commit 0912b58 into tronprotocol:release_v4.8.3 Nov 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants