Skip to content

Commit d099bf3

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feat/tip-2935-historical-blockhash
# Conflicts: # actuator/src/main/java/org/tron/core/utils/ProposalUtil.java # chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java # framework/src/main/java/org/tron/core/Wallet.java # framework/src/main/java/org/tron/core/consensus/ProposalService.java # framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java
2 parents 36510cb + 5ef7de6 commit d099bf3

221 files changed

Lines changed: 16981 additions & 4723 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: 129 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ jobs:
5454
- name: Build
5555
run: ./gradlew clean build --no-daemon
5656

57+
- name: Toolkit jar smoke test
58+
run: |
59+
set -e
60+
JAR=plugins/build/libs/Toolkit.jar
61+
java -jar "$JAR" help
62+
java -jar "$JAR" db --help
63+
java -jar "$JAR" db archive -h
64+
java -jar "$JAR" keystore --help
65+
5766
build-ubuntu:
5867
name: Build ubuntu24 (JDK 17 / aarch64)
5968
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'ubuntu' }}
@@ -84,6 +93,15 @@ jobs:
8493
- name: Build
8594
run: ./gradlew clean build --no-daemon
8695

96+
- name: Toolkit jar smoke test
97+
run: |
98+
set -e
99+
JAR=plugins/build/libs/Toolkit.jar
100+
java -jar "$JAR" help
101+
java -jar "$JAR" db --help
102+
java -jar "$JAR" db archive -h
103+
java -jar "$JAR" keystore --help
104+
87105
docker-build-rockylinux:
88106
name: Build rockylinux (JDK 8 / x86_64)
89107
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'rockylinux' }}
@@ -127,6 +145,15 @@ jobs:
127145
- name: Build
128146
run: ./gradlew clean build --no-daemon
129147

148+
- name: Toolkit jar smoke test
149+
run: |
150+
set -e
151+
JAR=plugins/build/libs/Toolkit.jar
152+
java -jar "$JAR" help
153+
java -jar "$JAR" db --help
154+
java -jar "$JAR" db archive -h
155+
java -jar "$JAR" keystore --help
156+
130157
- name: Test with RocksDB engine
131158
run: ./gradlew :framework:testWithRocksDb --no-daemon
132159

@@ -172,6 +199,15 @@ jobs:
172199
- name: Build
173200
run: ./gradlew clean build --no-daemon --no-build-cache
174201

202+
- name: Toolkit jar smoke test
203+
run: |
204+
set -e
205+
JAR=plugins/build/libs/Toolkit.jar
206+
java -jar "$JAR" help
207+
java -jar "$JAR" db --help
208+
java -jar "$JAR" db archive -h
209+
java -jar "$JAR" keystore --help
210+
175211
- name: Test with RocksDB engine
176212
run: ./gradlew :framework:testWithRocksDb --no-daemon --no-build-cache
177213

@@ -279,6 +315,68 @@ jobs:
279315
echo "base_xmls=$BASE_XMLS" >> "$GITHUB_OUTPUT"
280316
echo "pr_xmls=$PR_XMLS" >> "$GITHUB_OUTPUT"
281317
318+
- name: Set up Python
319+
uses: actions/setup-python@v5
320+
with:
321+
python-version: '3.11'
322+
323+
- name: Changed-line coverage (diff-cover)
324+
id: diff-cover
325+
env:
326+
BASE_REF: ${{ github.event.pull_request.base.ref }}
327+
run: |
328+
set -euo pipefail
329+
pip install --quiet 'diff-cover==9.2.0'
330+
331+
# Ensure the base branch ref is available locally for diff-cover.
332+
git fetch --no-tags origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
333+
334+
PR_XMLS=$(find coverage/pr -name "jacocoTestReport.xml" | sort)
335+
SRC_ROOTS=$(find . -type d -path '*/src/main/java' \
336+
-not -path './coverage/*' -not -path './.git/*' | sort)
337+
if [ -z "$SRC_ROOTS" ]; then
338+
echo "No src/main/java directories found; cannot run diff-cover." >&2
339+
exit 1
340+
fi
341+
342+
set +e
343+
diff-cover $PR_XMLS \
344+
--compare-branch="origin/${BASE_REF}" \
345+
--src-roots $SRC_ROOTS \
346+
--fail-under=0 \
347+
--json-report=diff-cover.json \
348+
--markdown-report=diff-cover.md
349+
DIFF_RC=$?
350+
set -e
351+
352+
if [ ! -f diff-cover.json ]; then
353+
echo "diff-cover did not produce JSON report (exit=${DIFF_RC})." >&2
354+
exit 1
355+
fi
356+
357+
TOTAL_NUM_LINES=$(jq -r '.total_num_lines // 0' diff-cover.json)
358+
if [ "${TOTAL_NUM_LINES}" = "0" ]; then
359+
echo "No changed Java source lines; skipping changed-line gate."
360+
echo "changed_line_coverage=NA" >> "$GITHUB_OUTPUT"
361+
else
362+
CHANGED_LINE_COVERAGE=$(jq -r '.total_percent_covered // empty' diff-cover.json)
363+
if [ -z "$CHANGED_LINE_COVERAGE" ]; then
364+
echo "Unable to parse changed-line coverage from diff-cover.json."
365+
exit 1
366+
fi
367+
echo "changed_line_coverage=${CHANGED_LINE_COVERAGE}" >> "$GITHUB_OUTPUT"
368+
fi
369+
370+
{
371+
echo "### Changed-line Coverage (diff-cover)"
372+
echo ""
373+
if [ -f diff-cover.md ] && [ -s diff-cover.md ]; then
374+
cat diff-cover.md
375+
else
376+
echo "_diff-cover produced no report._"
377+
fi
378+
} >> "$GITHUB_STEP_SUMMARY"
379+
282380
- name: Aggregate base coverage
283381
id: jacoco-base
284382
uses: madrapps/jacoco-report@v1.7.2
@@ -288,6 +386,7 @@ jobs:
288386
min-coverage-overall: 0
289387
min-coverage-changed-files: 0
290388
skip-if-no-changes: true
389+
comment-type: summary
291390
title: '## Base Coverage Snapshot'
292391
update-comment: false
293392

@@ -300,14 +399,15 @@ jobs:
300399
min-coverage-overall: 0
301400
min-coverage-changed-files: 0
302401
skip-if-no-changes: true
402+
comment-type: summary
303403
title: '## PR Code Coverage Report'
304404
update-comment: false
305405

306406
- name: Enforce coverage gates
307407
env:
308408
BASE_OVERALL_RAW: ${{ steps.jacoco-base.outputs.coverage-overall }}
309409
PR_OVERALL_RAW: ${{ steps.jacoco-pr.outputs.coverage-overall }}
310-
PR_CHANGED_RAW: ${{ steps.jacoco-pr.outputs.coverage-changed-files }}
410+
CHANGED_LINE_RAW: ${{ steps.diff-cover.outputs.changed_line_coverage }}
311411
run: |
312412
set -euo pipefail
313413
@@ -329,7 +429,7 @@ jobs:
329429
# 1) Parse metrics from jacoco-report outputs
330430
BASE_OVERALL="$(sanitize "$BASE_OVERALL_RAW")"
331431
PR_OVERALL="$(sanitize "$PR_OVERALL_RAW")"
332-
PR_CHANGED="$(sanitize "$PR_CHANGED_RAW")"
432+
CHANGED_LINE="$(sanitize "$CHANGED_LINE_RAW")"
333433
334434
if ! is_number "$BASE_OVERALL" || ! is_number "$PR_OVERALL"; then
335435
echo "Failed to parse coverage values: base='${BASE_OVERALL}', pr='${PR_OVERALL}'."
@@ -340,18 +440,18 @@ jobs:
340440
DELTA=$(awk -v pr="$PR_OVERALL" -v base="$BASE_OVERALL" 'BEGIN { printf "%.4f", pr - base }')
341441
DELTA_OK=$(compare_float "${DELTA} >= ${MAX_DROP}")
342442
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}%)"
443+
if [ "$CHANGED_LINE" = "NA" ]; then
444+
CHANGED_LINE_OK=1
445+
CHANGED_LINE_STATUS="SKIPPED (no changed Java source lines)"
446+
elif [ -z "$CHANGED_LINE" ] || [ "$CHANGED_LINE" = "NaN" ] || ! is_number "$CHANGED_LINE"; then
447+
echo "Failed to parse changed-line coverage: changed-line='${CHANGED_LINE}'."
448+
exit 1
449+
else
450+
CHANGED_LINE_OK=$(compare_float "${CHANGED_LINE} > ${MIN_CHANGED}")
451+
if [ "$CHANGED_LINE_OK" -eq 1 ]; then
452+
CHANGED_LINE_STATUS="PASS (> ${MIN_CHANGED}%)"
353453
else
354-
CHANGED_STATUS="FAIL (<= ${MIN_CHANGED}%)"
454+
CHANGED_LINE_STATUS="FAIL (<= ${MIN_CHANGED}%)"
355455
fi
356456
fi
357457
@@ -361,13 +461,20 @@ jobs:
361461
OVERALL_STATUS="FAIL (< ${MAX_DROP}%)"
362462
fi
363463
464+
if [ "$CHANGED_LINE" = "NA" ]; then
465+
CHANGED_LINE_DISPLAY="NA"
466+
else
467+
CHANGED_LINE_DISPLAY="${CHANGED_LINE}%"
468+
fi
469+
364470
METRICS_TEXT=$(cat <<EOF
365-
Changed Files Coverage: ${PR_CHANGED}%
471+
Changed-line Coverage: ${CHANGED_LINE_DISPLAY}
366472
PR Overall Coverage: ${PR_OVERALL}%
367473
Base Overall Coverage: ${BASE_OVERALL}%
368474
Delta (PR - Base): ${DELTA}%
369-
Changed Files Gate: ${CHANGED_STATUS}
475+
Changed-line Gate: ${CHANGED_LINE_STATUS}
370476
Overall Delta Gate: ${OVERALL_STATUS}
477+
Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable.
371478
EOF
372479
)
373480
@@ -376,12 +483,14 @@ jobs:
376483
{
377484
echo "### Coverage Gate Metrics"
378485
echo ""
379-
echo "- Changed Files Coverage: ${PR_CHANGED}%"
486+
echo "- Changed-line Coverage: ${CHANGED_LINE_DISPLAY}"
380487
echo "- PR Overall Coverage: ${PR_OVERALL}%"
381488
echo "- Base Overall Coverage: ${BASE_OVERALL}%"
382489
echo "- Delta (PR - Base): ${DELTA}%"
383-
echo "- Changed Files Gate: ${CHANGED_STATUS}"
490+
echo "- Changed-line Gate: ${CHANGED_LINE_STATUS}"
384491
echo "- Overall Delta Gate: ${OVERALL_STATUS}"
492+
echo ""
493+
echo "_Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable._"
385494
} >> "$GITHUB_STEP_SUMMARY"
386495
387496
# 4) Decide CI pass/fail
@@ -391,14 +500,9 @@ jobs:
391500
exit 1
392501
fi
393502
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}%"
503+
if [ "$CHANGED_LINE_OK" -ne 1 ]; then
504+
echo "Coverage gate failed: changed-line coverage must be > 60%."
505+
echo "changed-line=${CHANGED_LINE}%"
402506
exit 1
403507
fi
404508

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.

actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,22 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
901901
}
902902
break;
903903
}
904+
case ALLOW_HARDEN_RESOURCE_CALCULATION: {
905+
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_2)) {
906+
throw new ContractValidateException(
907+
"Bad chain parameter id [ALLOW_HARDEN_RESOURCE_CALCULATION]");
908+
}
909+
if (dynamicPropertiesStore.getAllowHardenResourceCalculation() == 1) {
910+
throw new ContractValidateException(
911+
"[ALLOW_HARDEN_RESOURCE_CALCULATION] has been valid, "
912+
+ "no need to propose again");
913+
}
914+
if (value != 1) {
915+
throw new ContractValidateException(
916+
"This value[ALLOW_HARDEN_RESOURCE_CALCULATION] is only allowed to be 1");
917+
}
918+
break;
919+
}
904920
default:
905921
break;
906922
}
@@ -987,7 +1003,8 @@ public enum ProposalType { // current value, value range
9871003
PROPOSAL_EXPIRE_TIME(92), // (0, 31536003000)
9881004
ALLOW_TVM_SELFDESTRUCT_RESTRICTION(94), // 0, 1
9891005
ALLOW_TVM_PRAGUE(95), // 0, 1
990-
ALLOW_TVM_OSAKA(96); // 0, 1
1006+
ALLOW_TVM_OSAKA(96), // 0, 1
1007+
ALLOW_HARDEN_RESOURCE_CALCULATION(97); // 0, 1
9911008

9921009
private long code;
9931010

actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static void load(StoreFactory storeFactory) {
4646
VMConfig.initAllowTvmBlob(ds.getAllowTvmBlob());
4747
VMConfig.initAllowTvmSelfdestructRestriction(ds.getAllowTvmSelfdestructRestriction());
4848
VMConfig.initAllowTvmOsaka(ds.getAllowTvmOsaka());
49+
VMConfig.initAllowHardenResourceCalculation(ds.getAllowHardenResourceCalculation());
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)