Skip to content

Merge master into develop #6308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
8b7ca9f
chore(vm): adjust inappropriate log content
yanghang8612 Jul 4, 2024
2a3d5ca
impr(test): optimize some unit tests
yanghang8612 Jul 4, 2024
1555a01
func(vm): support for CANCELALLUNFREEZEV2 details
yanghang8612 Jul 12, 2024
82d52d9
func(vm): change some json format
yanghang8612 Jul 18, 2024
930362b
feat(net): discard block inventory below the solidified block
zeusoo001 Aug 14, 2024
bd7b3d1
feat(jsonrpc): ethGetBlockByNumber supports finalized
waynercheung Sep 18, 2024
4e65c21
feat(jsonrpc): make other jsonrpc apis process finalized parameter
waynercheung Nov 13, 2024
a8ea721
initial commit
317787106 Nov 13, 2024
a31763e
revise if sensitiveCache is empty
317787106 Nov 13, 2024
a154dcb
ignore / of address
317787106 Nov 13, 2024
7bd057d
replace unknown ip with string IP
317787106 Nov 14, 2024
3da676e
fix the bug of eth_getLogs
317787106 Nov 15, 2024
86ab5ad
checkout payment in checkShieldedTRC20NoteValue
317787106 Nov 15, 2024
4717f87
add test case testCreateShieldedContractParameters2 without payment_a…
317787106 Nov 19, 2024
b70078c
feat(net): reduce the interval between batch request blocks to 100ms
jwrct Dec 24, 2024
c36118f
fix(net): add check for the number of contracts in the transaction
jwrct Dec 24, 2024
7f0b184
impr(test): revert changes and optimize those tests in a safer way
yanghang8612 Jan 7, 2025
659db96
move DesensitizedConverter to package common
317787106 Jan 8, 2025
6a32bb1
typo
waynercheung Jan 9, 2025
eb8e59a
feat(jsonrpc): add test cases for jsonrpc finalized
waynercheung Jan 13, 2025
a0e3dfa
Merge branch 'feat/jsonrpc_finalized' into feat/ethGetBlockByNumber_f…
waynercheung Jan 13, 2025
afd9540
Merge branch 'develop' into feat/ethGetBlockByNumber_finalized
waynercheung Jan 14, 2025
4e4881f
feat(witness): sort witness from address hashcode to address
halibobo1205 Jan 22, 2025
c3686aa
feat(*): optimize sensitive information
lxcmyf Jan 1, 2025
0642903
feat(exception): add TronError
halibobo1205 Jan 8, 2025
b57411f
feat(transaction): optimize transactions during the consensus phase
lxcmyf Feb 6, 2025
2c4b8d8
Merge branch 'release_v4.8.0' into hotfix/verify_payment
317787106 Feb 13, 2025
a84ae97
Merge branch 'release_v4.8.0' into feature/sensitive_ip
317787106 Feb 13, 2025
1f434d3
Merge branch 'release_v4.8.0' into hotfix/eth_getLogs
317787106 Feb 13, 2025
409c420
Merge pull request #6170 from halibobo1205/feat/add_tron_error
CodeNinjaEvan Feb 13, 2025
5619441
feat(api): optimize api service startup
halibobo1205 May 13, 2024
b1ac699
Merge pull request #6173 from halibobo1205/feat/sr_sort_opt
CodeNinjaEvan Feb 13, 2025
31016d3
Merge pull request #5857 from halibobo1205/feat/api_service_init_opt
CodeNinjaEvan Feb 13, 2025
a86d0ed
feat(*): reactor system.exit
halibobo1205 Jan 3, 2025
941959a
Merge branch 'develop' of github.com:tronprotocol/java-tron into disc…
zeusoo001 Feb 14, 2025
b5a53af
feat(tvm): cancun opcodes TLOAD, TSORE, MCOPY
Jun 26, 2024
1365aff
Merge remote-tracking branch 'upstream/release_v4.8.0' into fix_trans…
jwrct Feb 14, 2025
2d2195c
fix(test): update test case
jwrct Feb 14, 2025
794c098
Merge remote-tracking branch 'upstream/release_v4.8.0' into sync_update
jwrct Feb 14, 2025
60364ab
feat(tvm): update comments and tests
Jun 27, 2024
2d2200c
feat(consensus): check block header time is an integer multiple of 3s
zeusoo001 Feb 14, 2025
584e93a
Merge branch 'release_v4.8.0' of github.com:tronprotocol/java-tron in…
zeusoo001 Feb 14, 2025
e90c321
feat(consensus): verify the slot to avoid block generation during mai…
zeusoo001 Feb 14, 2025
bdea53f
feat(net): change the MAX_PEER_COUNT_PER_ADDRESS value to 5
zeusoo001 Feb 14, 2025
9c03624
Merge remote-tracking branch 'upstream/release_v4.8.0' into feature/c…
lxcmyf Feb 14, 2025
8738da4
Merge remote-tracking branch 'upstream/release_v4.8.0' into feature/s…
lxcmyf Feb 14, 2025
00d994b
test(vm): enable saving details for cancelcallunfreeze opcode test
yanghang8612 Feb 14, 2025
878dffc
fix(test): update test case
jwrct Feb 14, 2025
0640dd6
feat(event): optimize the event service
zeusoo001 Feb 5, 2025
fb2f371
Merge branch 'release_v4.8.0' of github.com:tronprotocol/java-tron in…
zeusoo001 Feb 14, 2025
fadc1a4
Merge pull request #6186 from zeusoo001/block-time-check
CodeNinjaEvan Feb 14, 2025
791ee6c
Merge pull request #6184 from zeusoo001/discard-inv-below-solid-block-1
CodeNinjaEvan Feb 14, 2025
bbc51c6
Merge branch 'release_v4.8.0' of github.com:tronprotocol/java-tron in…
zeusoo001 Feb 14, 2025
9f42782
Merge pull request #6177 from halibobo1205/feat/exit_opt
CodeNinjaEvan Feb 14, 2025
c155f13
feat(consensus): resolve code conflicts
zeusoo001 Feb 14, 2025
f7a3711
bump jcommander from 1.72 to 1.78
halibobo1205 Feb 13, 2025
7149763
bump pf4j from 2.5.0 to 3.10.0
halibobo1205 Feb 13, 2025
f9f592e
bump grpc from 1.52.1 to 1.60.0
halibobo1205 Feb 13, 2025
f500778
bump libp2p from 2.2.4 to 2.2.5
halibobo1205 Feb 13, 2025
6de76fb
Merge pull request #6185 from raymondliu0711/feature/vm_cancun_opcodes
CodeNinjaEvan Feb 14, 2025
e3ab041
Merge pull request #6181 from fyyhtx/fix_transaction_handle
CodeNinjaEvan Feb 14, 2025
9485e85
add test case ApiUtilTest
317787106 Feb 14, 2025
ef01fa3
Merge branch 'release_v4.8.0' into feature/sensitive_ip
317787106 Feb 14, 2025
ed2a721
Merge branch 'release_v4.8.0' into hotfix/verify_payment
317787106 Feb 14, 2025
61eb746
feat(math): migrate all operations from java.lang.Math to java.lang.S…
halibobo1205 Feb 8, 2025
25b1a69
Merge pull request #6007 from waynercheung/feat/ethGetBlockByNumber_f…
CodeNinjaEvan Feb 14, 2025
b84c4f6
add test case of empty Payment Address in SpendNote
317787106 Feb 14, 2025
e30abd6
Merge branch 'release_v4.8.0' into hotfix/eth_getLogs
317787106 Feb 14, 2025
b9a4912
add test case of generateFilterId
317787106 Feb 14, 2025
17283bf
Merge pull request #6183 from fyyhtx/sync_update
CodeNinjaEvan Feb 14, 2025
e72dbc4
format style of ApiUtilTest
317787106 Feb 14, 2025
54cff73
Merge pull request #6188 from zeusoo001/modify-default-value
CodeNinjaEvan Feb 14, 2025
3886068
Merge pull request #6187 from zeusoo001/witness-slot-verify
CodeNinjaEvan Feb 14, 2025
55cd17f
Merge pull request #6182 from halibobo1205/480/Math_full_to_strictMath
CodeNinjaEvan Feb 15, 2025
6b0aed7
Merge pull request #6176 from 317787106/hotfix/eth_getLogs
CodeNinjaEvan Feb 15, 2025
f402360
Merge pull request #6171 from lxcmyf/feature/sensitive_information_op…
CodeNinjaEvan Feb 15, 2025
a6b2142
modify test case of isShieldedTRC20ContractNoteSpent
317787106 Feb 15, 2025
9a44b0b
Merge branch 'release_v4.8.0' into feat/optimize_tests_and_logs
yanghang8612 Feb 15, 2025
a3109e5
Merge branch 'release_v4.8.0' into feature/support_cancel_details
yanghang8612 Feb 15, 2025
3c856c8
Merge pull request #6180 from halibobo1205/feature/dependency_upgrade
CodeNinjaEvan Feb 15, 2025
0c27569
Merge pull request #6175 from 317787106/feature/sensitive_ip
CodeNinjaEvan Feb 15, 2025
2ce580d
Merge pull request #6172 from lxcmyf/feature/consensus_optimize_tx
CodeNinjaEvan Feb 15, 2025
068eb3a
Merge pull request #6190 from yanghang8612/feat/optimize_tests_and_logs
CodeNinjaEvan Feb 15, 2025
3938504
Merge pull request #6174 from 317787106/hotfix/verify_payment
CodeNinjaEvan Feb 15, 2025
6660adb
Merge pull request #6191 from yanghang8612/feature/support_cancel_det…
CodeNinjaEvan Feb 15, 2025
70a7979
Merge branch 'release_v4.8.0' of github.com:tronprotocol/java-tron in…
zeusoo001 Feb 17, 2025
ff44e09
solve the sonar problem
zeusoo001 Feb 17, 2025
8249971
feat(build): enable dependency checksum sha256 verification
halibobo1205 Jul 8, 2024
e12adb2
Merge pull request #5903 from halibobo1205/feat/dependency_verification
CodeNinjaEvan Feb 17, 2025
a464aa8
feat(tvm): compare dataword in mcopy energy cost
Feb 17, 2025
d4f44a7
Merge pull request #6194 from raymondliu0711/feature/compare_dataword
CodeNinjaEvan Feb 17, 2025
01dd7e1
fix(tvm): clone tload value
Feb 17, 2025
a82baeb
Merge pull request #6195 from raymondliu0711/feature/clone_tload_value
CodeNinjaEvan Feb 17, 2025
d70cb52
Merge pull request #6192 from zeusoo001/event-22
CodeNinjaEvan Feb 17, 2025
41f751f
feat(net): optimize handshake log information
zeusoo001 Feb 18, 2025
4a20239
Merge pull request #6198 from zeusoo001/log_optimize
CodeNinjaEvan Feb 19, 2025
5f39d97
don't use prefix 41 when add address to sensitiveCache map
317787106 Feb 19, 2025
964daeb
fix(cfg): the setParam method overrides the internal tx switches init…
yanghang8612 Feb 19, 2025
f1a01e1
Merge pull request #6203 from 317787106/hotfix/remove_head41
CodeNinjaEvan Feb 20, 2025
1168426
Merge pull request #6201 from yanghang8612/fix/internal_tx_switch_cov…
CodeNinjaEvan Feb 20, 2025
ca28553
feat(system.exit): adapt TronError for ExecutorService
halibobo1205 Feb 20, 2025
89b53e6
Merge pull request #6205 from halibobo1205/480/adapt-TronError-for-th…
CodeNinjaEvan Feb 21, 2025
6a4f7a0
feat(log): optimize event service logs
zeusoo001 Feb 21, 2025
128b5d3
feat(dependencies): bump logback from 1.2.9 to 1.2.13
halibobo1205 Feb 21, 2025
e5af636
Merge pull request #6206 from zeusoo001/log_optimize
CodeNinjaEvan Feb 24, 2025
698f895
reactor(actuator):rename allowStrictMath2 to disableJavaLangMath
halibobo1205 Feb 24, 2025
8769536
feat(config): modify fastForward configuration
zeusoo001 Feb 24, 2025
5460d12
clear ch.qos.logback:1.2.9
halibobo1205 Feb 24, 2025
8791a2c
Merge pull request #6210 from halibobo1205/feat/rename_use_strictMath2
CodeNinjaEvan Feb 24, 2025
fbaa09b
feat(workflows): upgrade CodeQL Action to v3
halibobo1205 Feb 24, 2025
ff69ffb
Merge pull request #6207 from halibobo1205/feat/update_logback
CodeNinjaEvan Feb 24, 2025
04b7275
Merge pull request #6211 from zeusoo001/modify-config
CodeNinjaEvan Feb 24, 2025
5158b2f
Merge pull request #6212 from halibobo1205/feat/update-CodeQL-Action-v3
CodeNinjaEvan Feb 24, 2025
f187e10
fix(tvm): revert tstore in staticcall
Feb 25, 2025
adab9dd
feat(start): adjust consensusService start before tronNetService
halibobo1205 Feb 26, 2025
7a15f50
Merge pull request #6216 from halibobo1205/feat/start_opt
CodeNinjaEvan Feb 26, 2025
34393f6
feat(test): optimize unit testing configuration
lxcmyf Feb 26, 2025
af3a002
feat(validate): strengthen transaction result verification
lxcmyf Feb 27, 2025
93dfc33
Merge pull request #6221 from lxcmyf/feature/consensus_optimize_tx
CodeNinjaEvan Feb 27, 2025
f9a4544
Merge pull request #6219 from lxcmyf/feature/sensitive_information_op…
CodeNinjaEvan Feb 27, 2025
f653cfd
feat(event): optimize event service log
zeusoo001 Mar 3, 2025
ae24ba8
fix BlockEventCacheTest unit test issue
zeusoo001 Mar 4, 2025
a75e41d
add SolidEventServiceTest unit test
zeusoo001 Mar 4, 2025
7a5ae39
func(cfg): parameters should have a higher priority on the command li…
yanghang8612 Mar 4, 2025
9a70395
Merge pull request #6223 from zeusoo001/log-opt-1
CodeNinjaEvan Mar 4, 2025
658a4e2
feat(event): optimize transaction trigger acquisition
zeusoo001 Mar 4, 2025
67c4a09
feat(service): exit when services init failed
halibobo1205 Mar 4, 2025
7e374ec
Merge pull request #6214 from raymondliu0711/fix/tstore_revert
CodeNinjaEvan Mar 6, 2025
f82d152
Merge pull request #6224 from yanghang8612/feat/reprioritize_internal…
CodeNinjaEvan Mar 6, 2025
f6e4168
Merge pull request #6228 from halibobo1205/feat/services_init_opt
CodeNinjaEvan Mar 6, 2025
300d3ac
feat(build): add implicit_dependency for build
halibobo1205 Mar 6, 2025
09c803f
add getTransactionTriggers unit test
zeusoo001 Mar 7, 2025
e649699
Merge pull request #6229 from halibobo1205/feat/add_explicit_dependency
CodeNinjaEvan Mar 7, 2025
bfb1197
optimize event service close logic
zeusoo001 Mar 7, 2025
c8195ca
fix EventServiceTest unit test
zeusoo001 Mar 7, 2025
d56502f
fix unit test when process exit
zeusoo001 Mar 7, 2025
a30a3b7
feat(tvm): add blob opcodes
Mar 10, 2025
0a2fb53
feat(tvm): add allowTvmBlob proposal for TVM blob related ops and pre…
textml Mar 10, 2025
d442c93
feat(crypto): add setup file
Mar 10, 2025
a6c44c5
feat(crypto): change ckzg4844 path
textml Mar 10, 2025
a25c302
feat(crypto): add ckzg jni files and tests
Mar 10, 2025
ca57630
feat(crypto): add linux jni file
Mar 10, 2025
b168067
opt(crypto): opt blob precompiled return value
Mar 10, 2025
fa23379
Merge pull request #6227 from zeusoo001/event-907
CodeNinjaEvan Mar 11, 2025
c9b7fbc
feat(service): exit when params init failed
halibobo1205 Mar 9, 2025
a6bf35c
feat(test): refactor codes
Mar 11, 2025
0570b60
feat(event): optimize history event service close logic
zeusoo001 Mar 11, 2025
2519294
feat(event): improve HistoryEventService unit test
zeusoo001 Mar 11, 2025
979567e
Merge pull request #6232 from raymondliu0711/feature/add_blob_opcodes
CodeNinjaEvan Mar 11, 2025
da05a19
Merge pull request #6234 from zeusoo001/event-his
CodeNinjaEvan Mar 11, 2025
8ca7085
Merge pull request #6233 from halibobo1205/feat/services_init_opt
CodeNinjaEvan Mar 12, 2025
b753741
feat(jsonrpc): eth_newFilter not supports finalized as block parameter
waynercheung Mar 13, 2025
4e404ec
refactor(jsonrpc): check finalized in newFilter, not as a function
waynercheung Mar 14, 2025
70aa382
Merge pull request #6238 from waynercheung/feat/disable_finalized
CodeNinjaEvan Mar 14, 2025
8841b5e
feat(jsonrpc): keep old version err_msg when block range is invalid(f…
waynercheung Mar 14, 2025
406274d
Merge pull request #6239 from waynercheung/feat/opt_err_msg
CodeNinjaEvan Mar 14, 2025
97213d9
feat(version): update version to 4.8.0
halibobo1205 Mar 14, 2025
5d1ff37
Merge pull request #6240 from halibobo1205/version/update_version
CodeNinjaEvan Mar 14, 2025
4aa4a98
feat(event): set internalTransactionList to null in the new event ser…
zeusoo001 Mar 19, 2025
b414f7d
Merge pull request #6245 from zeusoo001/modify-internalTransactionList
CodeNinjaEvan Mar 19, 2025
716af38
opt(tvm): kzg precompile contract log
Mar 20, 2025
80b9cad
Merge pull request #6247 from raymondliu0711/feature/opt_kzg_log
CodeNinjaEvan Mar 20, 2025
c1ecb3c
feat(event): limite block loading speed
zeusoo001 Mar 21, 2025
f22c18a
use if instead of math methods
zeusoo001 Mar 24, 2025
04952bc
Merge pull request #6256 from zeusoo001/event-limit-speed
CodeNinjaEvan Mar 24, 2025
ab4b70b
feat(dependencies): remove org.quartz-scheduler:quartz
halibobo1205 Mar 24, 2025
3e1ab7f
Merge pull request #6257 from halibobo1205/feat/remove_quartz
CodeNinjaEvan Mar 24, 2025
ee58884
feat(CI): fix Sonar Check & CheckStyle
halibobo1205 Mar 25, 2025
25e10c7
fix(config): restore maxFastForwardNum to correct default value
jwrct Mar 26, 2025
29bb7bc
Merge pull request #6260 from halibobo1205/feat/CI_check
CodeNinjaEvan Mar 26, 2025
45c656e
Merge branch 'release_v4.8.0' into sync_update
jwrct Mar 26, 2025
44967fb
feat(log): optimize log information
zeusoo001 Mar 27, 2025
e3ad0ca
reactor(*): rename allowStrictMath2 to disableJavaLangMath
halibobo1205 Mar 26, 2025
6a7465a
Merge pull request #6261 from fyyhtx/sync_update
CodeNinjaEvan Mar 27, 2025
ed324ea
Merge branch 'release_v4.8.0' of github.com:tronprotocol/java-tron in…
zeusoo001 Mar 27, 2025
e74ce69
Merge pull request #6262 from halibobo1205/feat/rename_use_strictMath2
CodeNinjaEvan Mar 27, 2025
1e8d839
Merge pull request #6265 from zeusoo001/opt-log
CodeNinjaEvan Mar 27, 2025
0eaf62e
opt(tvm): opt kzg jni links
Mar 30, 2025
0e4652d
func(cfg): revert reprioritize for old internal tx switches
yanghang8612 Mar 31, 2025
4d3ff56
Merge pull request #6270 from raymondliu0711/feat/opt_kzg_methods
CodeNinjaEvan Mar 31, 2025
10186b0
Merge pull request #6269 from yanghang8612/revert_reprioritize_old_in…
CodeNinjaEvan Mar 31, 2025
9965edc
feat(jsonrpc): check maxSubTopics and maxBlockRange to be consistent …
waynercheung Apr 1, 2025
fd89088
feat(jsonrpc): refactor to set min and max section
waynercheung Apr 1, 2025
c2383f7
Merge pull request #6271 from waynercheung/feat/harden_filters
CodeNinjaEvan Apr 1, 2025
cb18372
func(event): optimize energy price querying method
yanghang8612 Apr 2, 2025
95082c2
fix(jsonrpc): use min(to, currentMaxBlock) to compare with maxBlockRange
waynercheung Apr 2, 2025
3780088
func(cfg): add saveCancelAllUnfreezeV2Details switch description to t…
yanghang8612 Apr 2, 2025
8201860
Merge pull request #6275 from waynercheung/feat/harden_filters
CodeNinjaEvan Apr 2, 2025
6474c7d
Merge pull request #6274 from yanghang8612/feat/optimize_energyprice_…
CodeNinjaEvan Apr 2, 2025
4fff540
feat(tvm): remove kzg precompile
Apr 10, 2025
212a4ec
Merge pull request #6283 from raymondliu0711/feature/remove_precompile
CodeNinjaEvan Apr 10, 2025
b3555dd
Merge pull request #6277 from tronprotocol/release_v4.8.0
CodeNinjaEvan Apr 29, 2025
d393930
update a new version. version name:GreatVoyage-v4.7.7-243-gb3555dd655…
Apr 29, 2025
72e31d9
Merge pull request #6300 from raymondliu0711/version/GreatVoyage-v4.7…
CodeNinjaEvan Apr 29, 2025
12e5085
Merge branch 'master' into mergre_from_master
yanghang8612 May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -46,7 +46,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -59,6 +59,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
93 changes: 93 additions & 0 deletions .github/workflows/math-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Check Math Usage

on:
push:
branches: [ 'master', 'release_**' ]
pull_request:
branches: [ 'develop', 'release_**' ]
workflow_dispatch:

jobs:
check-math:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check for java.lang.Math usage
id: check-math
shell: bash
run: |
echo "Checking for java.lang.Math usage..."

touch math_usage.txt

while IFS= read -r file; do
filename=$(basename "$file")
if [[ "$filename" == "StrictMathWrapper.java" || "$filename" == "MathWrapper.java" ]]; then
continue
fi

perl -0777 -ne '
s/"([^"\\]|\\.)*"//g;
s/'\''([^'\''\\]|\\.)*'\''//g;
s!/\*([^*]|\*[^/])*\*/!!g;
s!//[^\n]*!!g;
$hasMath = 0;
$hasMath = 1 if /^[\s]*import[\s]+java\.lang\.Math\b/m;
$hasMath = 1 if /\bjava\s*\.\s*lang\s*\.\s*Math\s*\./;
$hasMath = 1 if /(?<![\w\.])(?<!Strict)Math\s*\./;
print "$ARGV\n" if $hasMath;
' "$file" >> math_usage.txt
done < <(find . -type f -name "*.java")

sort -u math_usage.txt -o math_usage.txt

if [ -s math_usage.txt ]; then
echo "❌ Error: Forbidden Math usage found in the following files:"
cat math_usage.txt
echo "math_found=true" >> $GITHUB_OUTPUT
echo "Please use org.tron.common.math.StrictMathWrapper instead of direct Math usage."
else
echo "✅ No forbidden Math usage found"
echo "math_found=false" >> $GITHUB_OUTPUT
fi

- name: Upload findings
if: steps.check-math.outputs.math_found == 'true'
uses: actions/upload-artifact@v4
with:
name: math-usage-report
path: math_usage.txt

- name: Create comment
if: github.event_name == 'pull_request' && steps.check-math.outputs.math_found == 'true'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const findings = fs.readFileSync('math_usage.txt', 'utf8');
const body = `### ❌ Math Usage Detection Results

Found forbidden usage of \`java.lang.Math\` in the following files:

\`\`\`
${findings}
\`\`\`

**Please review if this usage is intended.**
> [!CAUTION]
> Note: You should use \`org.tron.common.math.StrictMathWrapper\`.
> If you need to use \`java.lang.Math\`, please provide a justification.
`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});

- name: Fail if Math usage found
if: steps.check-math.outputs.math_found == 'true'
run: exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import com.google.protobuf.Any;
import com.google.protobuf.GeneratedMessageV3;
import org.tron.common.math.Maths;
import org.tron.common.utils.Commons;
import org.tron.common.utils.ForkController;
import org.tron.core.ChainBaseManager;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.TransactionCapsule;
import org.tron.core.exception.BalanceInsufficientException;
import org.tron.core.store.AccountStore;
import org.tron.protos.Protocol.Transaction.Contract;
import org.tron.protos.Protocol.Transaction.Contract.ContractType;

Expand Down Expand Up @@ -63,4 +68,61 @@ public AbstractActuator setForkUtils(ForkController forkController) {
return this;
}

public long addExact(long x, long y) {
return Maths.addExact(x, y, this.disableJavaLangMath());
}

public long addExact(int x, int y) {
return Maths.addExact(x, y, this.disableJavaLangMath());
}

public long floorDiv(long x, long y) {
return Maths.floorDiv(x, y, this.disableJavaLangMath());
}

public long floorDiv(long x, int y) {
return this.floorDiv(x, (long) y);
}

public long multiplyExact(long x, long y) {
return Maths.multiplyExact(x, y, this.disableJavaLangMath());
}

public long multiplyExact(long x, int y) {
return this.multiplyExact(x, (long) y);
}

public int multiplyExact(int x, int y) {
return Maths.multiplyExact(x, y, this.disableJavaLangMath());
}

public long subtractExact(long x, long y) {
return Maths.subtractExact(x, y, this.disableJavaLangMath());
}

public int min(int a, int b) {
return Maths.min(a, b, this.disableJavaLangMath());
}

public long min(long a, long b) {
return Maths.min(a, b, this.disableJavaLangMath());
}

public void adjustBalance(AccountStore accountStore, byte[] accountAddress, long amount)
throws BalanceInsufficientException {
AccountCapsule account = accountStore.getUnchecked(accountAddress);
this.adjustBalance(accountStore, account, amount);
}

/**
* judge balance.
*/
public void adjustBalance(AccountStore accountStore, AccountCapsule account, long amount)
throws BalanceInsufficientException {
Commons.adjustBalance(accountStore, account, amount, this.disableJavaLangMath());
}

boolean disableJavaLangMath() {
return chainBaseManager.getDynamicPropertiesStore().disableJavaLangMath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.TransactionResultCapsule;
Expand Down Expand Up @@ -52,11 +51,11 @@ public boolean execute(Object object) throws ContractExeException {
accountPermissionUpdateContract.getActivesList());
accountStore.put(ownerAddress, account);

Commons.adjustBalance(accountStore, ownerAddress, -fee);
adjustBalance(accountStore, ownerAddress, -fee);
if (chainBaseManager.getDynamicPropertiesStore().supportBlackHoleOptimization()) {
chainBaseManager.getDynamicPropertiesStore().burnTrx(fee);
} else {
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
adjustBalance(accountStore, accountStore.getBlackhole(), fee);
}

result.setStatus(fee, code.SUCESS);
Expand Down Expand Up @@ -111,7 +110,7 @@ private boolean checkPermission(Permission permission) throws ContractValidateEx
throw new ContractValidateException("key's weight should be greater than 0");
}
try {
weightSum = Math.addExact(weightSum, key.getWeight());
weightSum = addExact(weightSum, key.getWeight());
} catch (ArithmeticException e) {
throw new ContractValidateException(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.AssetIssueCapsule;
Expand Down Expand Up @@ -84,11 +83,11 @@ public boolean execute(Object result) throws ContractExeException {
.put(assetIssueCapsuleV2.createDbV2Key(), assetIssueCapsuleV2);
}

Commons.adjustBalance(accountStore, ownerAddress, -fee);
adjustBalance(accountStore, ownerAddress, -fee);
if (dynamicStore.supportBlackHoleOptimization()) {
dynamicStore.burnTrx(fee);
} else {
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);//send to blackhole
adjustBalance(accountStore, accountStore.getBlackhole(), fee);//send to blackhole
}
AccountCapsule accountCapsule = accountStore.get(ownerAddress);
List<FrozenSupply> frozenSupplyList = assetIssueContract.getFrozenSupplyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down Expand Up @@ -48,13 +47,12 @@ public boolean execute(Object result)
accountStore
.put(accountCreateContract.getAccountAddress().toByteArray(), accountCapsule);

Commons
.adjustBalance(accountStore, accountCreateContract.getOwnerAddress().toByteArray(), -fee);
adjustBalance(accountStore, accountCreateContract.getOwnerAddress().toByteArray(), -fee);
// Add to blackhole address
if (dynamicStore.supportBlackHoleOptimization()) {
dynamicStore.burnTrx(fee);
} else {
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
adjustBalance(accountStore, accountStore.getBlackhole(), fee);
}
ret.setStatus(fee, code.SUCESS);
} catch (BalanceInsufficientException | InvalidProtocolBufferException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.Arrays;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down Expand Up @@ -162,7 +161,8 @@ public boolean validate() throws ContractValidateException {
}
long netUsage = (long) (accountNetUsage * TRX_PRECISION * ((double)
(dynamicStore.getTotalNetWeight()) / dynamicStore.getTotalNetLimit()));
long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage);
long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage,
this.disableJavaLangMath());
if (ownerCapsule.getFrozenV2BalanceForBandwidth() - v2NetUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than or equal to available FreezeBandwidthV2 balance");
Expand All @@ -175,7 +175,8 @@ public boolean validate() throws ContractValidateException {

long energyUsage = (long) (ownerCapsule.getEnergyUsage() * TRX_PRECISION * ((double)
(dynamicStore.getTotalEnergyWeight()) / dynamicStore.getTotalEnergyCurrentLimit()));
long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage);
long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage,
this.disableJavaLangMath());
if (ownerCapsule.getFrozenV2BalanceForEnergy() - v2EnergyUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than or equal to available FreezeEnergyV2 balance");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Arrays;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AccountCapsule;
Expand Down Expand Up @@ -121,7 +120,7 @@ public boolean execute(Object object) throws ContractExeException {
if (dynamicStore.supportBlackHoleOptimization()) {
dynamicStore.burnTrx(fee);
} else {
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
adjustBalance(accountStore, accountStore.getBlackhole(), fee);
}
ret.setExchangeId(id);
ret.setStatus(fee, code.SUCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public boolean execute(Object object) throws ContractExeException {

if (Arrays.equals(tokenID, firstTokenID)) {
anotherTokenID = secondTokenID;
anotherTokenQuant = Math
.floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance);
anotherTokenQuant = floorDiv(multiplyExact(
secondTokenBalance, tokenQuant), firstTokenBalance);
exchangeCapsule.setBalance(firstTokenBalance + tokenQuant,
secondTokenBalance + anotherTokenQuant);
} else {
anotherTokenID = firstTokenID;
anotherTokenQuant = Math
.floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance);
anotherTokenQuant = floorDiv(multiplyExact(
firstTokenBalance, tokenQuant), secondTokenBalance);
exchangeCapsule.setBalance(firstTokenBalance + anotherTokenQuant,
secondTokenBalance + tokenQuant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,12 @@ public boolean execute(Object object) throws ContractExeException {
BigInteger bigTokenQuant = new BigInteger(String.valueOf(tokenQuant));
if (Arrays.equals(tokenID, firstTokenID)) {
anotherTokenID = secondTokenID;
// anotherTokenQuant = Math
// .floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance);
anotherTokenQuant = bigSecondTokenBalance.multiply(bigTokenQuant)
.divide(bigFirstTokenBalance).longValueExact();
exchangeCapsule.setBalance(firstTokenBalance - tokenQuant,
secondTokenBalance - anotherTokenQuant);
} else {
anotherTokenID = firstTokenID;
// anotherTokenQuant = Math
// .floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance);
anotherTokenQuant = bigFirstTokenBalance.multiply(bigTokenQuant)
.divide(bigSecondTokenBalance).longValueExact();
exchangeCapsule.setBalance(firstTokenBalance - anotherTokenQuant,
Expand Down Expand Up @@ -210,8 +206,6 @@ public boolean validate() throws ContractValidateException {
BigDecimal bigSecondTokenBalance = new BigDecimal(String.valueOf(secondTokenBalance));
BigDecimal bigTokenQuant = new BigDecimal(String.valueOf(tokenQuant));
if (Arrays.equals(tokenID, firstTokenID)) {
// anotherTokenQuant = Math
// .floorDiv(Math.multiplyExact(secondTokenBalance, tokenQuant), firstTokenBalance);
anotherTokenQuant = bigSecondTokenBalance.multiply(bigTokenQuant)
.divideToIntegralValue(bigFirstTokenBalance).longValueExact();
if (firstTokenBalance < tokenQuant || secondTokenBalance < anotherTokenQuant) {
Expand All @@ -230,8 +224,6 @@ public boolean validate() throws ContractValidateException {
}

} else {
// anotherTokenQuant = Math
// .floorDiv(Math.multiplyExact(firstTokenBalance, tokenQuant), secondTokenBalance);
anotherTokenQuant = bigFirstTokenBalance.multiply(bigTokenQuant)
.divideToIntegralValue(bigSecondTokenBalance).longValueExact();
if (secondTokenBalance < tokenQuant || firstTokenBalance < anotherTokenQuant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.Commons;
import org.tron.common.utils.DecodeUtil;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.MarketOrderCapsule;
Expand Down Expand Up @@ -100,7 +99,7 @@ public boolean execute(Object object) throws ContractExeException {
if (dynamicStore.supportBlackHoleOptimization()) {
dynamicStore.burnTrx(fee);
} else {
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
adjustBalance(accountStore, accountStore.getBlackhole(), fee);
}
// 1. return balance and token
MarketUtils
Expand Down
Loading