Skip to content

fix(doc): optimze README.md and reference.conf comment#6804

Open
317787106 wants to merge 3 commits into
tronprotocol:release_v4.8.2from
317787106:hotfix/fix_reference
Open

fix(doc): optimze README.md and reference.conf comment#6804
317787106 wants to merge 3 commits into
tronprotocol:release_v4.8.2from
317787106:hotfix/fix_reference

Conversation

@317787106
Copy link
Copy Markdown
Collaborator

@317787106 317787106 commented May 29, 2026

What does this PR do?

  1. TronNetDelegate — wrap LockSupport.park() in a while (!hitDown && !Thread.currentThread().isInterrupted()) loop so that spurious unparks (e.g. from Thread.interrupt() in close()) cannot trigger the System.exit(0) path prematurely, and so the hit-thread exits cleanly when the Spring context is destroyed.

  2. SolidityNode — fix a shutdown race in getBlockByNum(): when a gRPC exception is thrown while the node is shutting down (!flag || isHitDown()), break out immediately instead of sleeping exceptionSleepTime (1 s) and retrying.

  3. ShieldedReceiveTest.pushSameSkAndScanAndSpend — fix a test isolation bug and a performance regression:

    • The test relied on the genesis bypass in validBlock() (latestBlockHeaderNumber == 0 → return true) to skip DPoS schedule validation. When prior tests cause the consensus background task to produce blocks, this bypass no longer applies and the block push fails with ValidateScheduleException.
    • Replace hardcoded System.currentTimeMillis() timestamps with nextScheduledTime(), which looks up the nearest slot where the witness is actually scheduled according to DposSlot.
    • Stop ConsensusService before manual block pushes: DposTask shares the same localwitness key and would race to produce blocks at the same slot, triggering switchFork and making the test slow.
  4. reference.conf — remove the stale "Keys that cannot auto-bind" comment block; those implementation details belong in the source classes, not in the config template.

  5. README.md — surface reference.conf alongside config.conf in the configuration-file list so users know a built-in defaults template exists (added in v4.8.2).

Why are these changes required?

  • The single LockSupport.park() call could be woken by Thread.interrupt() from close(), causing the process to reach System.exit(0) before hitDown was ever set. With the while-loop fix, close() calling interrupt() caused a busy-spin because park() returns immediately when interrupted but the loop never exited — adding the isInterrupted() guard lets the thread exit cleanly.
  • During shutdown, a transient gRPC exception in getBlockByNum() triggered a 1-second sleep and an unnecessary retry loop, delaying clean exit and producing noisy error logs.
  • pushSameSkAndScanAndSpend passed in isolation because the chain started at genesis (block 0), bypassing DPoS validation. In a full test run, the consensus background task produces blocks before this test runs, advancing the head past 0 and exposing the missing schedule-aware timestamp logic.
  • The reference.conf comment described internal normalisation details that have since been refactored into the Java classes.
  • reference.conf was introduced in v4.8.2 but not mentioned in the README.

This PR has been tested by:

  • Unit Tests
    • testGetBlockByNumNoErrorOnExceptionDuringShutdown: verifies the shutdown race fix — method breaks in < 500 ms; without the fix a 1-second sleep fires first.
    • pushSameSkAndScanAndSpend: now stable in both single-test and full-suite runs.
  • Manual Testing

Follow up

Extra details

@github-actions github-actions Bot requested review from 3for and kuny0707 May 29, 2026 11:02
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