Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
9b3be3f
Merge branch 'tronprotocol:develop' into develop
317787106 Aug 1, 2022
50752f5
Merge remote-tracking branch 'upstream/develop' into develop
317787106 Jan 30, 2023
ef7c388
feat(net): optimize network log
jwrct Jan 31, 2023
1218d3a
Merge pull request #4950 from chengtx01/hotfix/relay_service
jwrct Jan 31, 2023
856c519
Merge pull request #4951 from wubin01/relay_node
jwrct Jan 31, 2023
0b05977
fix(unitTest): optimize unit test
lxcmyf Jan 17, 2023
39d2690
fix(unitTest): replace context with spring test config
lxcmyf Jan 28, 2023
06bd010
fix(unitTest): shutdown thread pools and timers
zhang0125 Feb 2, 2023
3664fff
fix(unitTest): ignore LiteFullNodeToolTest
zhang0125 Feb 2, 2023
d513fd2
support libp2p v0.2
317787106 Feb 13, 2023
e236398
remove ping in KeepAliveService because it exist in libp2p
317787106 Feb 13, 2023
38f6eb0
use libp2p test-v0.2.0; don't add fastForwardNode to activeNodes if a…
317787106 Feb 14, 2023
80e700f
fix(test): add some test cases of utils
lxcmyf Feb 8, 2023
1ee8957
Merge pull request #4972 from lxcmyf/feature/unit_test
zhang0125 Feb 14, 2023
42732b0
Merge branch 'tronprotocol:develop' into develop
317787106 Feb 15, 2023
ced6fce
update PeerConnection
317787106 Feb 15, 2023
1a9ab59
merge release_v4.7.1
317787106 Feb 15, 2023
4413df5
support to read ipv6 address from config file
317787106 Feb 15, 2023
c2b6b80
add some log
317787106 Feb 15, 2023
e3995bf
add some log
317787106 Feb 15, 2023
e3e347e
Merge branch 'release_v4.7.1' into feature/libp2p_v2.0
317787106 Feb 16, 2023
e71b33b
feat(net): remove redundant logic after libp2p upgrade
xxo1shine Feb 22, 2023
cd4ff2c
fix(net): use libp2p test-v0.2.1
317787106 Feb 22, 2023
9f7fd29
Merge branch 'feature/libp2p_v2.0' of https://github.com/tronprotocol…
317787106 Feb 22, 2023
7814317
merge release_v4.7.1
317787106 Feb 23, 2023
6d0fa0e
feat(net): make the node detect function configurable
xxo1shine Feb 24, 2023
17bf1a4
update libp2p version to test-v0.2.2
317787106 Feb 24, 2023
2038efa
merge release_v4.7.1
317787106 Feb 28, 2023
543fbb1
fix(net): fix the bug of missing data in mongo
317787106 Feb 28, 2023
50ceff5
fix(net): use blockNum instead of i
317787106 Mar 1, 2023
833eb0c
update libp2p from test-v0.2.2 to test-v0.2.3
317787106 Mar 1, 2023
a2eff9e
Merge branch 'release_v4.7.1' into hotfix/mongo_miss
317787106 Mar 1, 2023
b33c660
fix(db): update postSolidityTrigger
317787106 Mar 1, 2023
d24d640
fix(db): update postSolidityTrigger
317787106 Mar 1, 2023
8c72efc
fix(net): add paramater node.dns.staticNodes
317787106 Mar 2, 2023
7b00325
style(net): fix checkstyle warning
317787106 Mar 2, 2023
2709f2a
fix(db): rename geContinuousBlockCapsule
317787106 Mar 3, 2023
bec6bc2
fix(db): add some log in geContinuousBlockCapsule
317787106 Mar 3, 2023
2016860
feat(net): recover handshake check logic
xxo1shine Mar 6, 2023
5f66f93
fix(net): update libp2p from test-v0.2.4 to test-v0.2.5
317787106 Mar 6, 2023
0f82f22
fix(net): update libp2p from test-v0.2.5 to test-v0.2.6
317787106 Mar 6, 2023
f39f279
update libp2p from test-v0.2.6 to test-v0.2.7
317787106 Mar 6, 2023
7b4c8f3
update libp2p from test-v0.2.7 to test-v0.2.8
317787106 Mar 6, 2023
a21d46d
add two parametres in dns section of config.conf
317787106 Mar 7, 2023
24f6c28
update libp2p from test-v0.2.10 to test-v0.2.11
317787106 Mar 7, 2023
bd8e07e
fix(net): don't filter address in static nodes
317787106 Mar 8, 2023
36e9ee2
fix(db): remove variable useSolidity
317787106 Mar 8, 2023
daa656d
fix(db): update log of getContinuousBlockCapsule
317787106 Mar 8, 2023
c104e6a
update libp2p from test-v0.2.11 to test-v0.2.12
317787106 Mar 9, 2023
4bb4f24
fix(db): add a config item: node.enableIpv6
317787106 Mar 9, 2023
6f27050
remove local ipv6 from active nodes
317787106 Mar 10, 2023
b909e3b
update libp2p from test-v0.2.13 to test-v0.2.14
317787106 Mar 13, 2023
53b6d6b
fix(net): set ip to null if node doesn't has ipv4 stack
317787106 Mar 13, 2023
cebdb36
fix(net): use [ipv6]:port instead of ipv6:port
317787106 Mar 14, 2023
fcf3366
fix(json-rpc): fix address generation of contract which created by `c…
tomatoishealthy Mar 13, 2023
72fde48
fix(net): update libp2p from test-v0.2.15 to test-v0.2.16
317787106 Mar 14, 2023
9b233e3
feat(interface): optimize TriggerSmartContract and TriggerConstantCon…
yanghang8612 Mar 14, 2023
46ea866
fix(net):update libp2p from test-v0.2.16 to test-v0.2.17
317787106 Mar 14, 2023
437ebb1
fix(net): check seed ip's format in class Args
317787106 Mar 14, 2023
50082a1
feat(net): add global rate limiter function
xxo1shine Mar 16, 2023
dac20fc
fix(net): add some test case
317787106 Mar 16, 2023
248496e
feat(net): add EffectiveService to get effective connection
317787106 Mar 16, 2023
cf37440
Merge branch 'feature/libp2p_v2.0' into feature/isolate
317787106 Mar 16, 2023
83b9741
Merge branch 'release_v4.7.2' into feature/libp2p_v2.0
317787106 Mar 17, 2023
05e4232
fix(net): add ReasonCode BELOW_THAN_ME
317787106 Mar 17, 2023
4e3814a
feat(interface): add block number and block hash to the result of cal…
yanghang8612 Mar 17, 2023
ba8331b
fix(test): fix port unavaliable when running unit test
tomatoishealthy Mar 17, 2023
998d7fb
fix(interface): some conditions not suitable
yanghang8612 Mar 17, 2023
f858b88
Merge pull request #5076 from guoquanwu/hotfix/unit-test-port-unavail…
tomatoishealthy Mar 17, 2023
710b345
Merge branch 'release_v4.7.2' into feature/libp2p_v2.0
317787106 Mar 20, 2023
9c98abf
fix(net): merge 4.7.2 and update libp2p
317787106 Mar 20, 2023
df2840e
feature(net): add config node.enableEffectiveCheck; add one ReasonCode
317787106 Mar 20, 2023
429f2a0
feature(shell): move shell to script directory
forfreeday Mar 20, 2023
c8b970b
Merge pull request #5082 from forfreeday/feature/move_script
forfreeday Mar 20, 2023
4339688
Merge pull request #5071 from tronprotocol/develop
halibobo1205 Mar 21, 2023
5959a1b
feat(config):add support for dynamically loading configuration
jwrct Mar 21, 2023
db678c1
fix(net): simplify EffectiveCheckService; set nodeEffectiveCheckEnabl…
317787106 Mar 21, 2023
73b8809
fix(net): update libp2p to test-callback-v2
317787106 Mar 21, 2023
466cc87
fix(net): merge feature/libp2p_v2.0
317787106 Mar 21, 2023
02d2e9f
feat(net): normalize http urls to prevent attacks
xxo1shine Mar 22, 2023
fdb17bc
fix(net): resolve the bug that Lack size is increasing by time
317787106 Mar 22, 2023
891c15a
fix(net): optimize code
317787106 Mar 22, 2023
f7c93fa
fix(net): optimize EffectiveCheckService
317787106 Mar 22, 2023
bfa2ffe
feat(net): add unit test for url checking
xxo1shine Mar 23, 2023
6db2db9
Merge pull request #5085 from wubin01/normalize_http_url
xxo1shine Mar 23, 2023
d23fbb1
fix(net): change node.effectiveCheckEnable default to false
317787106 Mar 23, 2023
dfbad70
fix(net): merge release_v4.7.2
317787106 Mar 23, 2023
3799c16
feat(config):optimize logs for dynamic loading configuration
jwrct Mar 23, 2023
a88c8d8
Merge branch 'release_v4.7.2' into optimize_intranet
jwrct Mar 23, 2023
ef6b534
feat(config):add dynamic loading configuration test case
jwrct Mar 24, 2023
3fa8c5c
Merge branch 'release_v4.7.2' into rate-limit
xxo1shine Mar 24, 2023
dd56bf0
fix(net): use get,add to replace set list in P2pConfig
317787106 Mar 24, 2023
c1fe7ad
Merge pull request #5031 from 317787106/hotfix/mongo_miss
317787106 Mar 24, 2023
659d80a
fix(net):fix the problem of repeated fetch block in FetchBlockService
jwrct Mar 24, 2023
5b5d01f
Merge branch 'release_v4.7.2' of https://github.com/tronprotocol/java…
xxo1shine Mar 27, 2023
52eaea6
feat(net): add global rate limiter test
xxo1shine Mar 27, 2023
7128fa9
fix(net): don't find new node if executor is closed
317787106 Mar 27, 2023
ae5dd9d
fix(net): remove isClosed, use executor to schedule
317787106 Mar 27, 2023
b417191
fix(net): remove isRunnig
317787106 Mar 27, 2023
dc63ec1
feat(net): modify global rate limiter default value
xxo1shine Mar 28, 2023
6959bd4
fix(net):optimize EffectiveCheckService
317787106 Mar 28, 2023
66f1ea6
fix(net): delete changes in HandshakeService
317787106 Mar 28, 2023
8b23eb7
fix(net):optimize EffectiveCheckService
317787106 Mar 28, 2023
da20e79
Merge branch 'release_v4.7.2' into feature/libp2p_v2.0
317787106 Mar 28, 2023
ec5ac70
feat(config):change the method of getting configuration file changes
jwrct Mar 28, 2023
2b7588c
Merge pull request #5093 from wubin01/rate-limit
xxo1shine Mar 29, 2023
06b814e
fix(net):don't start program if some dns patameter is empty
317787106 Mar 29, 2023
7f8fbfe
merge release_v4.7.2
317787106 Mar 29, 2023
cf3dfd2
fix(net):revert log level of net to info
317787106 Mar 29, 2023
b1d5255
fix(net): optimize EffectiveCheckService
317787106 Mar 29, 2023
2fd5fbe
feat(net): optimize sync block chain message check logic
xxo1shine Mar 29, 2023
c5b27a6
Merge pull request #5017 from tronprotocol/feature/libp2p_v2.0
317787106 Mar 29, 2023
8b0f983
merge feature/libp2p_v2.0
317787106 Mar 29, 2023
6f9f5fc
fix(net): merge release_v4.7.2
317787106 Mar 29, 2023
415dc52
Merge pull request #5097 from wubin01/opt_sync_check
xxo1shine Mar 29, 2023
272a16a
fix(net): update libp2p to test-v0.2.20
317787106 Mar 29, 2023
83ed16c
feat(config):add test case
jwrct Mar 29, 2023
1f61d7f
fix(net): revert PeerConnection
317787106 Mar 29, 2023
bbc9e62
Merge branch 'release_v4.7.2' into feature/isolate
317787106 Mar 29, 2023
8dfe234
Merge branch 'release_v4.7.2' into optimize_intranet
jwrct Mar 29, 2023
d0adfa0
feat(config):fix merge issue
jwrct Mar 29, 2023
8856500
feat(config):change libp2p version
jwrct Mar 29, 2023
a4aaa80
fix(net): add test case EffectiveCheckServiceTest
317787106 Mar 29, 2023
287aa7a
fix(net): add test case for MessageStatistics
317787106 Mar 29, 2023
74c8179
fix(net):add unit test for peer connection
jwrct Mar 30, 2023
1467908
feat(config):add unit test for DynamicArgs
jwrct Mar 30, 2023
e7858ea
Merge pull request #5094 from chengtx01/fix_no_request
jwrct Mar 30, 2023
e0c8ba5
feat(config):resolve code conflicts
jwrct Mar 30, 2023
c7cf0a8
fix(freezeV2): optimize the query return of the interface
lxcmyf Mar 30, 2023
d4c2761
Merge pull request #5090 from chengtx01/optimize_intranet
jwrct Mar 30, 2023
c2dc408
feat(net): optimize processSyncBlock function logic
xxo1shine Mar 30, 2023
0ce3ad3
fix(net): add test case for MessageTest
317787106 Mar 30, 2023
29ac079
Merge branch 'release_v4.7.2' into feature/isolate
317787106 Mar 30, 2023
3889b5a
Merge pull request #5100 from lxcmyf/release_v4.7.2
halibobo1205 Mar 30, 2023
e88bf90
Merge pull request #5088 from 317787106/feature/isolate
317787106 Mar 30, 2023
7bf49f7
feat(api): remove insecure API
halibobo1205 Mar 28, 2023
fee70c2
Merge pull request #5102 from wubin01/sync_block_process_opt
xxo1shine Mar 30, 2023
3f00ebd
update fetchBlockTimeout to 500ms
Vikingzzu Mar 31, 2023
1369924
Merge pull request #5106 from Vikingzzu/update-refetch-block-timeout
Vikingzzu Mar 31, 2023
5c615f7
fix(interface): continue to estimate if runtime exception occurred wh…
yanghang8612 Apr 2, 2023
ad30d13
fix(interface): throw out of time exception in any case
yanghang8612 Apr 2, 2023
6956e37
func(interface): do the same modification for estimate energy
yanghang8612 Apr 3, 2023
7082714
fix(net):fix the issue of block synchronization
jwrct Apr 3, 2023
5643063
style(http,util): fix sonar check problem
yanghang8612 Apr 3, 2023
8a45628
Merge pull request #5096 from halibobo1205/feat/deprecated_api
halibobo1205 Apr 3, 2023
354e1af
Merge pull request #5079 from yanghang8612/feature/optimize_trigger_i…
yanghang8612 Apr 3, 2023
a3afa12
feat(net):add unit test for block synchronization
jwrct Apr 3, 2023
7c1bd7d
fix(net):fix checkstyle issues
jwrct Apr 3, 2023
7af6488
func(http,util): remove rule-3 validation
yanghang8612 Apr 3, 2023
91c0c50
Merge pull request #5109 from chengtx01/optimize_intranet
jwrct Apr 3, 2023
131161e
func(http,util): add new rule-3 validation
yanghang8612 Apr 3, 2023
495f7ac
func(interface): drop rule-3 for trigger contract
yanghang8612 Apr 3, 2023
78b46c3
log(vm): reduce exception log level of featured instructions from err…
yanghang8612 Apr 3, 2023
3ed6a9f
Merge pull request #5110 from yanghang8612/feature/optimize_trigger_i…
yanghang8612 Apr 4, 2023
77700b9
chore(vm): replace `ResourceCode error` with `Unknown ResourceCode`
yanghang8612 Apr 4, 2023
26360b9
test(interface): add http unit tests
yanghang8612 Apr 4, 2023
6ce27a3
Merge pull request #5112 from yanghang8612/feature/optimize_trigger_i…
yanghang8612 Apr 4, 2023
4b12b17
feat(net): update libp2p with latest grpc
317787106 Apr 6, 2023
cfd4fbd
fix(net): update libp2p version
317787106 Apr 6, 2023
42e0ab3
fix(net): update libp2p to test-v0.2.21
317787106 Apr 6, 2023
bb98aeb
Merge branch 'release_v4.7.2' into feature/libp2p_grpc
317787106 Apr 6, 2023
7813063
fix(net):revert DatabaseGrpcClient WalletGrpcClient
317787106 Apr 7, 2023
9c2208b
fix(net): exclude com.google.protobuf from libp2p
317787106 Apr 7, 2023
5fc0c78
fix(net): optimize build.gradle
317787106 Apr 7, 2023
81d31dd
fix(net): try to remove shield in test case
317787106 Apr 9, 2023
3e1298c
feature(test): use random port in unit test
tomatoishealthy Apr 7, 2023
da14f79
feat(net): optimize the acquisition of the ip address of the GRPC int…
xxo1shine Apr 10, 2023
150dd39
fix(net): optimize NodeTest
317787106 Apr 10, 2023
2e38098
fix(net): optimize new test case
317787106 Apr 10, 2023
c0955d7
Merge pull request #5116 from 317787106/feature/libp2p_grpc
317787106 Apr 11, 2023
c64da6e
Merge branch 'release_v4.7.2' of https://github.com/tronprotocol/java…
xxo1shine Apr 11, 2023
722a57a
feature(test): merge release4.7.2
tomatoishealthy Apr 11, 2023
36e9e10
refactor(log):downgrade certain log level in some files
halibobo1205 Apr 10, 2023
b4b1444
Merge pull request #5121 from halibobo1205/feature/log_opt
halibobo1205 Apr 11, 2023
d952be1
Merge pull request #5119 from wubin01/acquisition_ip
xxo1shine Apr 11, 2023
74b34bc
Merge pull request #5061 from guoquanwu/hotfix/json-rpc-get-storage
tomatoishealthy Apr 11, 2023
9a825ec
feat(net): optimize sync block processing logic
xxo1shine Apr 12, 2023
75fba7a
fix(net): stable test case; add parameters in config
317787106 Apr 13, 2023
ab6a65e
feat(net): optimize p2p exception type description
xxo1shine Apr 13, 2023
071a15b
fix(net):modify BaseNet
317787106 Apr 14, 2023
1b2024d
fix(net):format code
317787106 Apr 14, 2023
ebd2142
fix(freezeV2): optimize Stake2.0 code
lxcmyf Apr 13, 2023
999a763
Merge pull request #5117 from guoquanwu/feature/unit-test-port-conflict
tomatoishealthy Apr 14, 2023
fbcbd6e
fix(net):optimize BaseNet
317787106 Apr 14, 2023
de05520
Merge branch 'release_v4.7.2' into hotfix/stable_testcase
317787106 Apr 14, 2023
27f2255
func(interface): remove the added field
yanghang8612 Apr 14, 2023
4b3aeb5
Merge pull request #5138 from yanghang8612/feature/remove_added_field
yanghang8612 Apr 14, 2023
403da93
fix(net):optimize BaseNet
317787106 Apr 14, 2023
54c05e5
Merge pull request #5130 from wubin01/sync_block_prco
xxo1shine Apr 17, 2023
66a646e
feat(db): prune lite node data automatically
Mar 30, 2023
f9ba0e0
Merge remote-tracking branch 'origin/feature/unit_test' into release_…
lxcmyf Apr 17, 2023
80516d7
Merge pull request #5105 from lurais/feature/auto_prune_blockv2
halibobo1205 Apr 17, 2023
0c3dc83
Revert "feat(db): prune lite node data automatically"
halibobo1205 Apr 17, 2023
0a3f2aa
Merge pull request #5150 from tronprotocol/revert-5105-feature/auto_p…
halibobo1205 Apr 17, 2023
b605617
Merge remote-tracking branch 'origin/release_v4.7.2' into release_v4.7.2
lxcmyf Apr 17, 2023
bc2c141
feat(backup): increase the unit test of the backup module
xxo1shine Apr 18, 2023
9d5d0e0
feat(net): optimize validSignature function
xxo1shine Apr 18, 2023
cfbfec5
Merge branch 'tronprotocol:release_v4.7.2' into release_v4.7.2
lxcmyf Apr 17, 2023
3f1b2a5
Merge pull request #5159 from wubin01/optimize_sign
xxo1shine Apr 18, 2023
73b37b2
Merge pull request #5158 from wubin01/backup_nuit_test
xxo1shine Apr 18, 2023
747757b
feat(net): optimize getBlockChainSummary logic
xxo1shine Apr 18, 2023
4e81526
optimize test case
317787106 Apr 18, 2023
ae4587c
Merge branch 'release_v4.7.2' into hotfix/stable_testcase
317787106 Apr 18, 2023
feb946d
Merge branch 'tronprotocol:release_v4.7.2' into release_v4.7.2
lxcmyf Apr 17, 2023
f2e064b
feat(db): check second cache config in unit tests
Mar 10, 2023
43fba01
Merge pull request #5056 from lurais/feature/second_cache_test_check
halibobo1205 Apr 18, 2023
e27c862
Merge remote-tracking branch 'origin/release_v4.7.2' into release_v4.7.2
lxcmyf Apr 19, 2023
d549b86
Merge pull request #5160 from wubin01/optimize_block_summary
xxo1shine Apr 19, 2023
cc9a944
Merge pull request #5148 from lxcmyf/release_v4.7.2
halibobo1205 Apr 19, 2023
cd9e534
fix(net):descrease memory cost of test cases
317787106 Apr 19, 2023
7a8ceee
fix(net):merge 4.7.2
317787106 Apr 19, 2023
c03451d
Merge pull request #5133 from 317787106/hotfix/stable_testcase
317787106 Apr 19, 2023
45f0e01
feat(version): update version
Apr 20, 2023
4fd7b49
Merge pull request #5164 from forfreeday/feature/update_version
forfreeday Apr 20, 2023
73a7419
fix(test): optimize unit test
lxcmyf Apr 20, 2023
58ca710
Merge pull request #5169 from lxcmyf/release_v4.7.2
halibobo1205 Apr 21, 2023
a8fc651
Merge remote-tracking branch 'origin/release_v4.7.2' into feature/opt…
lxcmyf Apr 23, 2023
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
21 changes: 0 additions & 21 deletions DownloadLinks.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_PERIOD;
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
import static org.tron.core.vm.utils.FreezeV2Util.getV2EnergyUsage;
import static org.tron.core.vm.utils.FreezeV2Util.getV2NetUsage;

import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
Expand Down Expand Up @@ -136,7 +138,7 @@ public boolean validate() throws ContractValidateException {

long delegateBalance = delegateResourceContract.getBalance();
if (delegateBalance < TRX_PRECISION) {
throw new ContractValidateException("delegateBalance must be more than 1TRX");
throw new ContractValidateException("delegateBalance must be greater than or equal to 1 TRX");
}

switch (delegateResourceContract.getResource()) {
Expand All @@ -152,16 +154,11 @@ public boolean validate() throws ContractValidateException {
long netUsage = (long) (accountNetUsage * TRX_PRECISION * ((double)
(dynamicStore.getTotalNetWeight()) / dynamicStore.getTotalNetLimit()));

long remainNetUsage = netUsage
- ownerCapsule.getFrozenBalance()
- ownerCapsule.getAcquiredDelegatedFrozenBalanceForBandwidth()
- ownerCapsule.getAcquiredDelegatedFrozenV2BalanceForBandwidth();
long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage);

remainNetUsage = Math.max(0, remainNetUsage);

if (ownerCapsule.getFrozenV2BalanceForBandwidth() - remainNetUsage < delegateBalance) {
if (ownerCapsule.getFrozenV2BalanceForBandwidth() - v2NetUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than available FreezeBandwidthV2 balance");
"delegateBalance must be less than or equal to available FreezeBandwidthV2 balance");
}
}
break;
Expand All @@ -172,16 +169,11 @@ public boolean validate() throws ContractValidateException {
long energyUsage = (long) (ownerCapsule.getEnergyUsage() * TRX_PRECISION * ((double)
(dynamicStore.getTotalEnergyWeight()) / dynamicStore.getTotalEnergyCurrentLimit()));

long remainEnergyUsage = energyUsage
- ownerCapsule.getEnergyFrozenBalance()
- ownerCapsule.getAcquiredDelegatedFrozenBalanceForEnergy()
- ownerCapsule.getAcquiredDelegatedFrozenV2BalanceForEnergy();

remainEnergyUsage = Math.max(0, remainEnergyUsage);
long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage);

if (ownerCapsule.getFrozenV2BalanceForEnergy() - remainEnergyUsage < delegateBalance) {
if (ownerCapsule.getFrozenV2BalanceForEnergy() - v2EnergyUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than available FreezeEnergyV2 balance");
"delegateBalance must be less than or equal to available FreezeEnergyV2 balance");
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ public boolean validate() throws ContractValidateException {
throw new ContractValidateException("frozenBalance must be positive");
}
if (frozenBalance < TRX_PRECISION) {
throw new ContractValidateException("frozenBalance must be more than 1TRX");
throw new ContractValidateException("frozenBalance must be greater than or equal to 1 TRX");
}

int frozenCount = accountCapsule.getFrozenCount();
if (!(frozenCount == 0 || frozenCount == 1)) {
throw new ContractValidateException("frozenCount must be 0 or 1");
}
if (frozenBalance > accountCapsule.getBalance()) {
throw new ContractValidateException("frozenBalance must be less than accountBalance");
throw new ContractValidateException("frozenBalance must be less than or equal to accountBalance");
}

long frozenDuration = freezeBalanceContract.getFrozenDuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public boolean validate() throws ContractValidateException {
throw new ContractValidateException("frozenBalance must be positive");
}
if (frozenBalance < TRX_PRECISION) {
throw new ContractValidateException("frozenBalance must be more than 1TRX");
throw new ContractValidateException("frozenBalance must be greater than or equal to 1 TRX");
}

if (frozenBalance > accountCapsule.getBalance()) {
throw new ContractValidateException("frozenBalance must be less than accountBalance");
throw new ContractValidateException("frozenBalance must be less than or equal to accountBalance");
}

switch (freezeBalanceV2Contract.getResource()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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 @@ -144,9 +143,8 @@ public boolean execute(Object result) throws ContractExeException {

long now = chainBaseManager.getHeadSlot();
if (Objects.nonNull(receiverCapsule) && transferUsage > 0) {
ownerCapsule.setNetUsage(processor.unDelegateIncrease(ownerCapsule, receiverCapsule,
transferUsage, BANDWIDTH, now));
ownerCapsule.setLatestConsumeTime(now);
processor.unDelegateIncrease(ownerCapsule, receiverCapsule,
transferUsage, BANDWIDTH, now);
}
}
break;
Expand All @@ -160,9 +158,7 @@ public boolean execute(Object result) throws ContractExeException {

long now = chainBaseManager.getHeadSlot();
if (Objects.nonNull(receiverCapsule) && transferUsage > 0) {
ownerCapsule.setEnergyUsage(processor.unDelegateIncrease(ownerCapsule, receiverCapsule,
transferUsage, ENERGY, now));
ownerCapsule.setLatestConsumeTimeForEnergy(now);
processor.unDelegateIncrease(ownerCapsule, receiverCapsule, transferUsage, ENERGY, now);
}
}
break;
Expand Down Expand Up @@ -240,7 +236,7 @@ public boolean validate() throws ContractValidateException {
}

byte[] receiverAddress = unDelegateResourceContract.getReceiverAddress().toByteArray();
if (ArrayUtils.isEmpty(receiverAddress) || !DecodeUtil.addressValid(receiverAddress)) {
if (!DecodeUtil.addressValid(receiverAddress)) {
throw new ContractValidateException("Invalid receiverAddress");
}
if (Arrays.equals(receiverAddress, ownerAddress)) {
Expand Down
16 changes: 0 additions & 16 deletions actuator/src/main/java/org/tron/core/utils/TransactionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.tron.protos.Protocol.Transaction;
import org.tron.protos.Protocol.Transaction.Contract;
import org.tron.protos.Protocol.Transaction.Result.contractResult;
import org.tron.protos.Protocol.TransactionSign;
import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract;
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
Expand Down Expand Up @@ -184,21 +183,6 @@ public static String makeUpperCamelMethod(String originName) {
.replace("_", "");
}

public static TransactionCapsule getTransactionSign(TransactionSign transactionSign) {
byte[] privateKey = transactionSign.getPrivateKey().toByteArray();
TransactionCapsule trx = new TransactionCapsule(transactionSign.getTransaction());
trx.sign(privateKey);
return trx;
}

public TransactionCapsule addSign(TransactionSign transactionSign)
throws PermissionException, SignatureException, SignatureFormatException {
byte[] privateKey = transactionSign.getPrivateKey().toByteArray();
TransactionCapsule trx = new TransactionCapsule(transactionSign.getTransaction());
trx.addSign(privateKey, chainBaseManager.getAccountStore());
return trx;
}

public TransactionSignWeight getTransactionSignWeight(Transaction trx) {
TransactionSignWeight.Builder tswBuilder = TransactionSignWeight.newBuilder();
TransactionExtention.Builder trxExBuilder = TransactionExtention.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST;
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
import static org.tron.core.vm.utils.FreezeV2Util.getV2EnergyUsage;
import static org.tron.core.vm.utils.FreezeV2Util.getV2NetUsage;

import com.google.common.primitives.Bytes;
import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -49,7 +51,7 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra
}
long delegateBalance = param.getDelegateBalance();
if (delegateBalance < TRX_PRECISION) {
throw new ContractValidateException("delegateBalance must be more than 1TRX");
throw new ContractValidateException("delegateBalance must be greater than or equal to 1 TRX");
}

switch (param.getResourceType()) {
Expand All @@ -60,16 +62,11 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra
long netUsage = (long) (ownerCapsule.getNetUsage() * TRX_PRECISION * ((double)
(repo.getTotalNetWeight()) / dynamicStore.getTotalNetLimit()));

long remainNetUsage = netUsage
- ownerCapsule.getFrozenBalance()
- ownerCapsule.getAcquiredDelegatedFrozenBalanceForBandwidth()
- ownerCapsule.getAcquiredDelegatedFrozenV2BalanceForBandwidth();
long v2NetUsage = getV2NetUsage(ownerCapsule, netUsage);

remainNetUsage = Math.max(0, remainNetUsage);

if (ownerCapsule.getFrozenV2BalanceForBandwidth() - remainNetUsage < delegateBalance) {
if (ownerCapsule.getFrozenV2BalanceForBandwidth() - v2NetUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than available FreezeBandwidthV2 balance");
"delegateBalance must be less than or equal to available FreezeBandwidthV2 balance");
}
}
break;
Expand All @@ -81,22 +78,17 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra
long energyUsage = (long) (ownerCapsule.getEnergyUsage() * TRX_PRECISION * ((double)
(repo.getTotalEnergyWeight()) / dynamicStore.getTotalEnergyCurrentLimit()));

long remainEnergyUsage = energyUsage
- ownerCapsule.getEnergyFrozenBalance()
- ownerCapsule.getAcquiredDelegatedFrozenBalanceForEnergy()
- ownerCapsule.getAcquiredDelegatedFrozenV2BalanceForEnergy();

remainEnergyUsage = Math.max(0, remainEnergyUsage);
long v2EnergyUsage = getV2EnergyUsage(ownerCapsule, energyUsage);

if (ownerCapsule.getFrozenV2BalanceForEnergy() - remainEnergyUsage < delegateBalance) {
if (ownerCapsule.getFrozenV2BalanceForEnergy() - v2EnergyUsage < delegateBalance) {
throw new ContractValidateException(
"delegateBalance must be less than available FreezeEnergyV2 balance");
"delegateBalance must be less than or equal to available FreezeEnergyV2 balance");
}
}
break;
default:
throw new ContractValidateException(
"ResourceCode error, valid ResourceCode[BANDWIDTH、ENERGY]");
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY]");
}

byte[] receiverAddress = param.getReceiverAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void validate(FreezeBalanceParam param, Repository repo) throws ContractV
if (frozenBalance <= 0) {
throw new ContractValidateException("FrozenBalance must be positive");
} else if (frozenBalance < TRX_PRECISION) {
throw new ContractValidateException("FrozenBalance must be more than 1TRX");
throw new ContractValidateException("FrozenBalance must be greater than or equal to 1 TRX");
} else if (frozenBalance > ownerCapsule.getBalance()) {
throw new ContractValidateException("FrozenBalance must be less than accountBalance");
throw new ContractValidateException("FrozenBalance must be less than or equal to accountBalance");
}

// validate frozen count of owner account
Expand All @@ -48,7 +48,7 @@ public void validate(FreezeBalanceParam param, Repository repo) throws ContractV
break;
default:
throw new ContractValidateException(
"ResourceCode error,valid ResourceCode[BANDWIDTH、ENERGY]");
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY]");
}

// validate for delegating resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package org.tron.core.vm.nativecontract;

import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR;
import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST;
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH;
import static org.tron.protos.contract.Common.ResourceCode.ENERGY;

import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
Expand All @@ -9,12 +15,6 @@
import org.tron.core.vm.nativecontract.param.FreezeBalanceV2Param;
import org.tron.core.vm.repository.Repository;

import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR;
import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST;
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH;
import static org.tron.protos.contract.Common.ResourceCode.ENERGY;

@Slf4j(topic = "VMProcessor")
public class FreezeBalanceV2Processor {

Expand All @@ -37,9 +37,10 @@ public void validate(FreezeBalanceV2Param param, Repository repo) throws Contrac
if (frozenBalance <= 0) {
throw new ContractValidateException("FrozenBalance must be positive");
} else if (frozenBalance < TRX_PRECISION) {
throw new ContractValidateException("FrozenBalance must be more than 1TRX");
throw new ContractValidateException("FrozenBalance must be greater than or equal to 1 TRX");
} else if (frozenBalance > ownerCapsule.getBalance()) {
throw new ContractValidateException("FrozenBalance must be less than accountBalance");
throw new ContractValidateException(
"FrozenBalance must be less than or equal to accountBalance");
}

// validate arg @resourceType
Expand All @@ -50,16 +51,16 @@ public void validate(FreezeBalanceV2Param param, Repository repo) throws Contrac
case TRON_POWER:
if (!repo.getDynamicPropertiesStore().supportAllowNewResourceModel()) {
throw new ContractValidateException(
"ResourceCode error, valid ResourceCode[BANDWIDTH、ENERGY]");
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY]");
}
break;
default:
if (repo.getDynamicPropertiesStore().supportAllowNewResourceModel()) {
throw new ContractValidateException(
"ResourceCode error, valid ResourceCode[BANDWIDTH、ENERGY、TRON_POWER]");
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY、TRON_POWER]");
} else {
throw new ContractValidateException(
"ResourceCode error, valid ResourceCode[BANDWIDTH、ENERGY]");
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY]");
}
}
}
Expand Down
Loading