Skip to content

feat(ci,config): add comment coverage gate for reference.conf#32

Open
bladehan1 wants to merge 15 commits into
release_v4.8.2from
feat/ci_reference_comment
Open

feat(ci,config): add comment coverage gate for reference.conf#32
bladehan1 wants to merge 15 commits into
release_v4.8.2from
feat/ci_reference_comment

Conversation

@bladehan1
Copy link
Copy Markdown
Owner

@bladehan1 bladehan1 commented Jun 1, 2026

What does this PR do?

Adds a comment-coverage CI gate for `reference.conf` and annotates all previously undocumented configuration keys.

Changes

  1. `.github/scripts/check_reference_comments.py` (new, 358 lines, zero runtime dependencies)

    • Line-oriented Python 3 scanner — pyhocon is intentionally avoided because it discards comments.
    • Enforces that every key carries either an inline (`#` / `//`) comment or a non-blank comment on the immediately preceding line.
    • Array-element keys are deduplicated: only the first occurrence in a homogeneous array is checked (handles `rate.limiter` entries).
    • `--list` flag prints every key with its status (`commented` / `dedup` / `missing`) for local debugging.
    • On failure: human-readable violation list + GHA `::error` annotations with `line N: key`.
    • Docstring documents known HOCON edge-case limitations (quoted keys, `+=`, triple-quoted strings, bare URLs) and explains why each is low-risk for `reference.conf`.
  2. `.github/workflows/pr-check.yml` (+6 lines)

    • New step runs immediately after the existing `check_reference_conf.py` (key-format / depth / port-uniqueness) gate.
    • Any non-zero exit code fails the step and blocks the job; no `continue-on-error`.
  3. `common/src/main/resources/reference.conf`

    • All previously undocumented keys now carry inline comments. The `committee` block includes the `/wallet/getchainparameters` API key name and `ProposalType` ID for each governance parameter.

Why are these changes required?

`reference.conf` is the primary configuration reference for node operators. Before this change most keys had no explanation, forcing operators to read source code. There was no CI enforcement either, so new keys could be merged without documentation.

This PR has been tested by:

  • Manual Testing: `python3 .github/scripts/check_reference_comments.py common/src/main/resources/reference.conf` → `OK` (exit 0)
  • Manual Testing: `python3 .github/scripts/check_reference_conf.py common/src/main/resources/reference.conf` → `OK: 290 keys, all lowerCamelCase, depth <= 5, service ports unique` (exit 0)
  • Manual Testing: `check_reference_comments.py --list` output verified: 252 commented, 118 dedup, 0 missing
  • `committee` block comments cross-checked against live mainnet `/wallet/getchainparameters` API response and `ProposalUtil.ProposalType` enum in source — all 42 ProposalType IDs and API key names confirmed correct
  • Unit Tests: local test suite `.helper/test_reference_conf/run.sh` — 41/41 passed (14 comment-coverage fixtures + 17 key-format fixtures + real `reference.conf` smoke tests)
  • CI: PR Lint ✅, check-math ✅, Checkstyle ✅, System Test ✅, Build debian11 ✅, Build rockylinux ✅, Build macos26 ✅

Extra details

  • HOCON comments (`#` / `//`) are fully transparent to Typesafe Config and pyhocon — no runtime behaviour is affected.
  • The gate is intentionally a basic coverage check, not a full HOCON parser. Constructs not used in `reference.conf` (quoted keys, `+=`, triple-quoted strings) are documented as known limitations in the script docstring.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 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: dd7198b6-c79d-44a7-9bf0-7676603c389a

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ci_reference_comment

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.

2 issues found across 3 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=".github/scripts/check_reference_comments.py">

<violation number="1" location=".github/scripts/check_reference_comments.py:20">
P2: The key-line regex is too narrow for valid HOCON key syntax (e.g., hyphenated/quoted keys and `+=`), which can create false negatives in the coverage gate.</violation>

<violation number="2" location=".github/scripts/check_reference_comments.py:107">
P2: The genesis exemption misses equivalent nested HOCON syntax (`genesis { block { ... } }`), causing false comment-coverage failures for exempt keys.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .github/scripts/check_reference_comments.py
Comment thread .github/scripts/check_reference_comments.py Outdated
@bladehan1 bladehan1 force-pushed the feat/ci_reference_comment branch from cf4f06b to 74d4ceb Compare June 1, 2026 09:51
@bladehan1 bladehan1 changed the title ci: add comment coverage gate for reference.conf feat(ci,config): add comment coverage gate for reference.conf Jun 1, 2026
@bladehan1 bladehan1 force-pushed the feat/ci_reference_comment branch 2 times, most recently from 668bf63 to 55696dc Compare June 2, 2026 08:22
Add check_reference_comments.py, a line-oriented Python script that
enforces every key in reference.conf carries an inline or immediately-
preceding comment. Wire it into pr-check.yml as a new CI step directly
after the existing key-format gate.

Annotate all previously undocumented keys in reference.conf with inline
# / // comments. The committee block now includes the
/wallet/getchainparameters API key name and ProposalType ID for each
governance parameter. genesis.block array elements (assets, witnesses)
carry field-level inline comments derived from the existing block
descriptions; there is no genesis.block exemption.
@bladehan1 bladehan1 force-pushed the feat/ci_reference_comment branch from 55696dc to 0b9c4ca Compare June 2, 2026 08:29
317787106 and others added 12 commits June 2, 2026 18:16
…onprotocol#6816)

MerkleTree was a shared volatile singleton holding per-build mutable state (leaves/hashList/root). When merkle validation runs concurrently (e.g. pre-broadcast validation on the P2P handler threads alongside the apply path), concurrent calls mutated the shared leaves list and threw ArrayIndexOutOfBoundsException (surfaced on an ARM SR due to its weaker memory model), which escaped the BadBlockException catch and dropped peers.

- MerkleTree: replace the getInstance() singleton with a static build() factory returning a thread-confined instance; drop the now-inaccurate @NotThreadSafe.
- BlockCapsule.calcMerkleRoot: use MerkleTree.build(ids); keeps the config-driven hash engine, so no consensus behavior change.
- MerkleTreeTest: switch call sites to build(); un-ignore testConcurrent and turn it into a regression test asserting 1000 concurrent builds succeed.
* feat(*): disable exchange transaction (tronprotocol#6507)

* update a new version. version name:GreatVoyage-v4.8.0-1-g45e3bf88ca,version code:18634 (tronprotocol#6508)

* Merge release_v4.8.1 to master (tronprotocol#6541)

* update a new version. version name:GreatVoyage-v4.8.0.1-1-g44a4bc8263,version code:18636 (tronprotocol#6542)

* feat(vm): optimize the check for create2

* feat(vm): optimize the check for ModExp

* test(vm): add tests for create2/modExp checks

* feat(version): update version to 4.8.1.1

* feat(ci): add PR pipeline and system-test workflows

New workflows:
- pr-build.yml: multi-OS build matrix (macOS, Ubuntu, RockyLinux, Debian11)
  and changed-line/overall coverage gate
- pr-check.yml: PR title/body lint + Checkstyle
- pr-reviewer.yml: scope-based reviewer auto-assignment
- pr-cancel.yml: cancel in-progress runs when PR is closed unmerged
- system-test.yml: spin up FullNode and run the system-test suite

Existing workflows:
- codeql.yml: bump to v4/v5 actions, switch to manual build-mode with
  JDK 8, add paths-ignore for docs-only changes
- math-check.yml: bump checkout/upload-artifact/github-script versions

* feat(config): fix git.properties NPE

* update a new version. version name:GreatVoyage-v4.8.1-6-g52d7d9d23e,version code:18643

---------

Co-authored-by: YAaron <4241080+kuny0707@users.noreply.github.com>
Co-authored-by: zz <aaa@bb.cc>
…ents

Address review feedback on PR tronprotocol#6810:

- blockCacheTimeout: correct unit from (s) to (min) — both SyncService
  and AdvService pass the value to expireAfterWrite with TimeUnit.MINUTES
- pBFTExpireNum: reword from "maintenance rounds" to block-lag count;
  PbftMsgHandler compares headBlockNum - msg.getNumber() against it
- allowReceiptsMerkleRoot: mark as reserved/no-op; Args.java explicitly
  skips applying it at runtime
- allowTvmBlob: narrow from "blob transaction support" to the actual
  effect: enabling BLOBHASH and BLOBBASEFEE opcodes in TVM
- committee section header: soften — not every entry is a committee
  proposal (allowNewRewardAlgorithm is a startup flag)
- event.subscribe block: move inline comments on { / [ openers to the
  preceding line per style feedback
- contractAddress / contractTopic: remove duplicate element-level
  comments; keep the array-level comment only
StorageConfig.properties is List<PropertyConfig> and is parsed manually
via StorageConfig.readProperties(); ConfigBeanFactory cannot bind
list-of-object fields so the hoconKeysAreBound gate reports it as an
orphan. Add it to STORAGE_HOCON_ORPHANS with the rationale comment.
Merge-order races can leave the base branch with a pre-existing failing
test unrelated to the current PR (e.g. tronprotocol#6803 vs tronprotocol#6806 ordering). The
Coverage Base job only needs jacoco XML for coverage diffing, so a stale
test failure must not block the whole job.

Add continue-on-error: true to the Build (base) and Test with RocksDB
engine (base) steps, and relax if-no-files-found from error to warn so
that a compile-level failure degrades gracefully instead of producing a
misleading second failure.
@bladehan1 bladehan1 force-pushed the feat/ci_reference_comment branch from 9de7f51 to 0041c2b Compare June 5, 2026 04:07
bladehan1 added 2 commits June 5, 2026 14:16
All keys whose value opens with { or [ now carry the comment on the
line immediately above the key rather than on the same line after the
opener. Applies to 16 remaining occurrences:
node.backup, members, node.metrics, prometheus, p2p (version),
active, passive, fastForward, http, rpc, dns, jsonrpc, rate.limiter.p2p,
seed.node, ip.list, localwitness, block, vm.

CI gates: check_reference_comments → OK, check_reference_conf → OK (290 keys).
…passive, maxFastForwardNum)

- db.directory: reference CLI flag --output-directory explicitly
- checkpoint.sync: note it is ignored under checkpoint.version = 1 (default);
  only CheckPointV2Store.java:19 consumes it
- P2P service: add missing space after comma
- maxFastForwardNum: reword to describe SR-forwarding semantics,
  verified via RelayService.java:234 getNextWitnesses()
- passive: note port numbers are configured but ignored;
  Args.java:657 only extracts InetAddress, discarding the port
- check_reference_comments.py: add encoding="utf-8" to read_text()
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.

5 participants