Skip to content

Commit 19c6674

Browse files
committed
Merge upstream/develop into feat/request_size
Resolves conflicts from upstream's ConfigBeanFactory refactor (c977f82) by adapting maxMessageSize logic to the new model: - Add maxMessageSize fields to NodeConfig.HttpConfig/JsonRpcConfig. - Add reference.conf defaults for the two new keys, using human-readable 4M form (consistent with the human-readable input the parsing layer already accepts; numeric byte form would require operators to do mental math). - Inside NodeConfig.fromConfig, pre-normalize the three maxMessageSize paths (rpc/http/jsonrpc): parse via Config.getMemorySize so values like "4m" / "128MB" become numeric bytes before ConfigBeanFactory's primitive int/long binding, and validate non-negative and <= Integer.MAX_VALUE so failures point at the user-facing config path. This matches BlockConfig.fromConfig's validation-in-fromConfig convention and keeps Args.applyNodeConfig as a pure bean-to-PARAMETER bridge. - Drop ConfigKey.java (deleted upstream); the two NODE_*_MAX_MESSAGE_SIZE constants are no longer needed since keys are derived from bean field names. Tests: ArgsTest (18), NodeConfigTest (29), SizeLimitHandlerTest, UtilTest, JsonrpcServiceTest all pass under the merged tree; framework checkstyleMain and checkstyleTest pass.
2 parents 5cdcebd + 980c707 commit 19c6674

147 files changed

Lines changed: 11268 additions & 3884 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr-build.yml

Lines changed: 93 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,68 @@ jobs:
279279
echo "base_xmls=$BASE_XMLS" >> "$GITHUB_OUTPUT"
280280
echo "pr_xmls=$PR_XMLS" >> "$GITHUB_OUTPUT"
281281
282+
- name: Set up Python
283+
uses: actions/setup-python@v5
284+
with:
285+
python-version: '3.11'
286+
287+
- name: Changed-line coverage (diff-cover)
288+
id: diff-cover
289+
env:
290+
BASE_REF: ${{ github.event.pull_request.base.ref }}
291+
run: |
292+
set -euo pipefail
293+
pip install --quiet 'diff-cover==9.2.0'
294+
295+
# Ensure the base branch ref is available locally for diff-cover.
296+
git fetch --no-tags origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
297+
298+
PR_XMLS=$(find coverage/pr -name "jacocoTestReport.xml" | sort)
299+
SRC_ROOTS=$(find . -type d -path '*/src/main/java' \
300+
-not -path './coverage/*' -not -path './.git/*' | sort)
301+
if [ -z "$SRC_ROOTS" ]; then
302+
echo "No src/main/java directories found; cannot run diff-cover." >&2
303+
exit 1
304+
fi
305+
306+
set +e
307+
diff-cover $PR_XMLS \
308+
--compare-branch="origin/${BASE_REF}" \
309+
--src-roots $SRC_ROOTS \
310+
--fail-under=0 \
311+
--json-report=diff-cover.json \
312+
--markdown-report=diff-cover.md
313+
DIFF_RC=$?
314+
set -e
315+
316+
if [ ! -f diff-cover.json ]; then
317+
echo "diff-cover did not produce JSON report (exit=${DIFF_RC})." >&2
318+
exit 1
319+
fi
320+
321+
TOTAL_NUM_LINES=$(jq -r '.total_num_lines // 0' diff-cover.json)
322+
if [ "${TOTAL_NUM_LINES}" = "0" ]; then
323+
echo "No changed Java source lines; skipping changed-line gate."
324+
echo "changed_line_coverage=NA" >> "$GITHUB_OUTPUT"
325+
else
326+
CHANGED_LINE_COVERAGE=$(jq -r '.total_percent_covered // empty' diff-cover.json)
327+
if [ -z "$CHANGED_LINE_COVERAGE" ]; then
328+
echo "Unable to parse changed-line coverage from diff-cover.json."
329+
exit 1
330+
fi
331+
echo "changed_line_coverage=${CHANGED_LINE_COVERAGE}" >> "$GITHUB_OUTPUT"
332+
fi
333+
334+
{
335+
echo "### Changed-line Coverage (diff-cover)"
336+
echo ""
337+
if [ -f diff-cover.md ] && [ -s diff-cover.md ]; then
338+
cat diff-cover.md
339+
else
340+
echo "_diff-cover produced no report._"
341+
fi
342+
} >> "$GITHUB_STEP_SUMMARY"
343+
282344
- name: Aggregate base coverage
283345
id: jacoco-base
284346
uses: madrapps/jacoco-report@v1.7.2
@@ -288,6 +350,7 @@ jobs:
288350
min-coverage-overall: 0
289351
min-coverage-changed-files: 0
290352
skip-if-no-changes: true
353+
comment-type: summary
291354
title: '## Base Coverage Snapshot'
292355
update-comment: false
293356

@@ -300,14 +363,15 @@ jobs:
300363
min-coverage-overall: 0
301364
min-coverage-changed-files: 0
302365
skip-if-no-changes: true
366+
comment-type: summary
303367
title: '## PR Code Coverage Report'
304368
update-comment: false
305369

306370
- name: Enforce coverage gates
307371
env:
308372
BASE_OVERALL_RAW: ${{ steps.jacoco-base.outputs.coverage-overall }}
309373
PR_OVERALL_RAW: ${{ steps.jacoco-pr.outputs.coverage-overall }}
310-
PR_CHANGED_RAW: ${{ steps.jacoco-pr.outputs.coverage-changed-files }}
374+
CHANGED_LINE_RAW: ${{ steps.diff-cover.outputs.changed_line_coverage }}
311375
run: |
312376
set -euo pipefail
313377
@@ -329,7 +393,7 @@ jobs:
329393
# 1) Parse metrics from jacoco-report outputs
330394
BASE_OVERALL="$(sanitize "$BASE_OVERALL_RAW")"
331395
PR_OVERALL="$(sanitize "$PR_OVERALL_RAW")"
332-
PR_CHANGED="$(sanitize "$PR_CHANGED_RAW")"
396+
CHANGED_LINE="$(sanitize "$CHANGED_LINE_RAW")"
333397
334398
if ! is_number "$BASE_OVERALL" || ! is_number "$PR_OVERALL"; then
335399
echo "Failed to parse coverage values: base='${BASE_OVERALL}', pr='${PR_OVERALL}'."
@@ -340,18 +404,18 @@ jobs:
340404
DELTA=$(awk -v pr="$PR_OVERALL" -v base="$BASE_OVERALL" 'BEGIN { printf "%.4f", pr - base }')
341405
DELTA_OK=$(compare_float "${DELTA} >= ${MAX_DROP}")
342406
343-
CHANGED_STATUS="SKIPPED (no changed coverage value)"
344-
CHANGED_OK=1
345-
if [ -n "$PR_CHANGED" ] && [ "$PR_CHANGED" != "NaN" ]; then
346-
if ! is_number "$PR_CHANGED"; then
347-
echo "Failed to parse changed-files coverage: changed='${PR_CHANGED}'."
348-
exit 1
349-
fi
350-
CHANGED_OK=$(compare_float "${PR_CHANGED} > ${MIN_CHANGED}")
351-
if [ "$CHANGED_OK" -eq 1 ]; then
352-
CHANGED_STATUS="PASS (> ${MIN_CHANGED}%)"
407+
if [ "$CHANGED_LINE" = "NA" ]; then
408+
CHANGED_LINE_OK=1
409+
CHANGED_LINE_STATUS="SKIPPED (no changed Java source lines)"
410+
elif [ -z "$CHANGED_LINE" ] || [ "$CHANGED_LINE" = "NaN" ] || ! is_number "$CHANGED_LINE"; then
411+
echo "Failed to parse changed-line coverage: changed-line='${CHANGED_LINE}'."
412+
exit 1
413+
else
414+
CHANGED_LINE_OK=$(compare_float "${CHANGED_LINE} > ${MIN_CHANGED}")
415+
if [ "$CHANGED_LINE_OK" -eq 1 ]; then
416+
CHANGED_LINE_STATUS="PASS (> ${MIN_CHANGED}%)"
353417
else
354-
CHANGED_STATUS="FAIL (<= ${MIN_CHANGED}%)"
418+
CHANGED_LINE_STATUS="FAIL (<= ${MIN_CHANGED}%)"
355419
fi
356420
fi
357421
@@ -361,13 +425,20 @@ jobs:
361425
OVERALL_STATUS="FAIL (< ${MAX_DROP}%)"
362426
fi
363427
428+
if [ "$CHANGED_LINE" = "NA" ]; then
429+
CHANGED_LINE_DISPLAY="NA"
430+
else
431+
CHANGED_LINE_DISPLAY="${CHANGED_LINE}%"
432+
fi
433+
364434
METRICS_TEXT=$(cat <<EOF
365-
Changed Files Coverage: ${PR_CHANGED}%
435+
Changed-line Coverage: ${CHANGED_LINE_DISPLAY}
366436
PR Overall Coverage: ${PR_OVERALL}%
367437
Base Overall Coverage: ${BASE_OVERALL}%
368438
Delta (PR - Base): ${DELTA}%
369-
Changed Files Gate: ${CHANGED_STATUS}
439+
Changed-line Gate: ${CHANGED_LINE_STATUS}
370440
Overall Delta Gate: ${OVERALL_STATUS}
441+
Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable.
371442
EOF
372443
)
373444
@@ -376,12 +447,14 @@ jobs:
376447
{
377448
echo "### Coverage Gate Metrics"
378449
echo ""
379-
echo "- Changed Files Coverage: ${PR_CHANGED}%"
450+
echo "- Changed-line Coverage: ${CHANGED_LINE_DISPLAY}"
380451
echo "- PR Overall Coverage: ${PR_OVERALL}%"
381452
echo "- Base Overall Coverage: ${BASE_OVERALL}%"
382453
echo "- Delta (PR - Base): ${DELTA}%"
383-
echo "- Changed Files Gate: ${CHANGED_STATUS}"
454+
echo "- Changed-line Gate: ${CHANGED_LINE_STATUS}"
384455
echo "- Overall Delta Gate: ${OVERALL_STATUS}"
456+
echo ""
457+
echo "_Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable._"
385458
} >> "$GITHUB_STEP_SUMMARY"
386459
387460
# 4) Decide CI pass/fail
@@ -391,14 +464,9 @@ jobs:
391464
exit 1
392465
fi
393466
394-
if [ -z "$PR_CHANGED" ] || [ "$PR_CHANGED" = "NaN" ]; then
395-
echo "No changed-files coverage value detected, skip changed-files gate."
396-
exit 0
397-
fi
398-
399-
if [ "$CHANGED_OK" -ne 1 ]; then
400-
echo "Coverage gate failed: changed files coverage must be > 60%."
401-
echo "changed=${PR_CHANGED}%"
467+
if [ "$CHANGED_LINE_OK" -ne 1 ]; then
468+
echo "Coverage gate failed: changed-line coverage must be > 60%."
469+
echo "changed-line=${CHANGED_LINE}%"
402470
exit 1
403471
fi
404472

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ We would like all developers to follow a standard development flow and coding st
147147
2. Review the code before submission.
148148
3. Run standardized tests.
149149
150-
`Sonar`-scanner and `Travis CI` continuous integration scanner will be automatically triggered when a pull request has been submitted. When a PR passes all the checks, the **java-tron** maintainers will then review the PR and offer feedback and modifications when necessary. Once adopted, the PR will be closed and merged into the `develop` branch.
150+
`Sonar`-scanner and CI checks (GitHub Actions) will be automatically triggered when a pull request has been submitted. When a PR passes all the checks, the **java-tron** maintainers will then review the PR and offer feedback and modifications when necessary. Once adopted, the PR will be closed and merged into the `develop` branch.
151151
152152
We are glad to receive your pull requests and will try our best to review them as soon as we can. Any pull request is welcome, even if it is for a typo.
153153
@@ -161,7 +161,7 @@ Please make sure your submission meets the following code style:
161161
- The code must have passed the Sonar scanner test.
162162
- The code has to be pulled from the `develop` branch.
163163
- The commit message should start with a verb, whose initial should not be capitalized.
164-
- The commit message should be less than 50 characters in length.
164+
- The commit message title should be between 10 and 72 characters in length.
165165
166166
167167
@@ -196,7 +196,7 @@ The message header is a single line that contains succinct description of the ch
196196
The `scope` can be anything specifying place of the commit change. For example: `framework`, `api`, `tvm`, `db`, `net`. For a full list of scopes, see [Type and Scope Reference](#type-and-scope-reference). You can use `*` if there isn't a more fitting scope.
197197
198198
The subject contains a succinct description of the change:
199-
1. Limit the subject line, which briefly describes the purpose of the commit, to 50 characters.
199+
1. Limit the subject line, which briefly describes the purpose of the commit, to 72 characters (minimum 10).
200200
2. Start with a verb and use first-person present-tense (e.g., use "change" instead of "changed" or "changes").
201201
3. Do not capitalize the first letter.
202202
4. Do not end the subject line with a period.

build.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

chainbase/src/main/java/org/tron/core/db/TronDatabase.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,25 @@ public void reset() {
7676
@Override
7777
public void close() {
7878
logger.info("******** Begin to close {}. ********", getName());
79+
doClose();
80+
logger.info("******** End to close {}. ********", getName());
81+
}
82+
83+
/**
84+
* Releases writeOptions and dbSource (best-effort, exceptions logged at WARN).
85+
* Subclasses with extra resources should override {@link #close()} and call
86+
* {@code doClose()} directly — not {@code super.close()} — to avoid duplicated logs.
87+
*/
88+
protected void doClose() {
7989
try {
8090
writeOptions.close();
91+
} catch (Exception e) {
92+
logger.warn("Failed to close writeOptions in {}.", getName(), e);
93+
}
94+
try {
8195
dbSource.closeDB();
8296
} catch (Exception e) {
83-
logger.warn("Failed to close {}.", getName(), e);
84-
} finally {
85-
logger.info("******** End to close {}. ********", getName());
97+
logger.warn("Failed to close dbSource in {}.", getName(), e);
8698
}
8799
}
88100

chainbase/src/main/java/org/tron/core/store/CheckPointV2Store.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,16 @@ public void updateByBatch(Map<byte[], byte[]> rows) {
6262
this.dbSource.updateByBatch(rows, writeOptions);
6363
}
6464

65-
/**
66-
* close the database.
67-
*/
6865
@Override
6966
public void close() {
7067
logger.debug("******** Begin to close {}. ********", getName());
7168
try {
7269
writeOptions.close();
73-
dbSource.closeDB();
7470
} catch (Exception e) {
75-
logger.warn("Failed to close {}.", getName(), e);
76-
} finally {
77-
logger.debug("******** End to close {}. ********", getName());
71+
logger.warn("Failed to close writeOptions in {}.", getName(), e);
7872
}
73+
doClose();
74+
logger.debug("******** End to close {}. ********", getName());
7975
}
8076

8177
}

common/src/main/java/org/tron/common/parameter/RateLimiterInitialization.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ public HttpRateLimiterItem(ConfigObject asset) {
7474
strategy = asset.get("strategy").unwrapped().toString();
7575
params = asset.get("paramString").unwrapped().toString();
7676
}
77+
78+
public HttpRateLimiterItem(String component, String strategy, String params) {
79+
this.component = component;
80+
this.strategy = strategy;
81+
this.params = params;
82+
}
7783
}
7884

7985

@@ -93,5 +99,11 @@ public RpcRateLimiterItem(ConfigObject asset) {
9399
strategy = asset.get("strategy").unwrapped().toString();
94100
params = asset.get("paramString").unwrapped().toString();
95101
}
102+
103+
public RpcRateLimiterItem(String component, String strategy, String params) {
104+
this.component = component;
105+
this.strategy = strategy;
106+
this.params = params;
107+
}
96108
}
97109
}

common/src/main/java/org/tron/core/config/Configuration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public static com.typesafe.config.Config getByFileName(
4848

4949
private static void resolveConfigFile(String fileName, File confFile) {
5050
if (confFile.exists()) {
51-
config = ConfigFactory.parseFile(confFile);
51+
config = ConfigFactory.parseFile(confFile)
52+
.withFallback(ConfigFactory.defaultReference());
5253
} else if (Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)
5354
!= null) {
5455
config = ConfigFactory.load(fileName);

0 commit comments

Comments
 (0)