Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
5c53c3b
chore: fix some typos in comment
InventiveCoder Dec 10, 2024
973a0af
opt(framework): optimization Help Instruction
imalasong Feb 18, 2025
2cc57bd
Merge pull request #6197 from imalasong/feature/pr2
CodeNinjaEvan Apr 1, 2025
aa682c9
feat(net):P2P message rate limit
jwrct May 6, 2025
0cd0eef
Merge branch 'master' into develop
May 8, 2025
a1fb8f9
Merge pull request #6118 from InventiveCoder/develop
CodeNinjaEvan May 8, 2025
1e35f79
Merge pull request #6315 from raymondliu0711/feature/merge_master_to_…
CodeNinjaEvan May 12, 2025
e50e11f
feat(net):test for P2P message rate limit
jwrct May 15, 2025
618b352
feat(net):fix for ambiguous reason code in disconnect messages
jwrct May 26, 2025
436ab69
optimize the log for configuration without Blackhole account
zeusoo001 Jun 20, 2025
b8702a5
solve sonar problem
zeusoo001 Jun 24, 2025
5304d55
feat(net): add volatile modifier to peer attribute variables
zeusoo001 Jun 24, 2025
23543e6
update readme for telegram groups and doc link
vivian1912 Jun 27, 2025
5910b51
feat(doc): update expired information for readme
halibobo1205 Jun 4, 2025
15e8c0e
Merge pull request #6340 from halibobo1205/doc/read_me
kuny0707 Jun 30, 2025
b0cf0d4
feat(net): optimize the log of synchronization failure
zeusoo001 Jul 3, 2025
017207e
feat(net): adjust the order of field assignment to solve concurrency …
zeusoo001 Jul 3, 2025
c2adb7d
fix(net):fix P2P message rate limit issue
jwrct Jul 8, 2025
3b3ddac
fix(net):delete unused import
jwrct Jul 8, 2025
5c8f032
fix(CheckStyle): only fix CheckStyle
bladehan1 Jul 8, 2025
2454a92
feat(net):optimize rate limit logic
jwrct Jul 8, 2025
07dec0d
Merge pull request #6392 from bladehan1/fix/only_checkstyle
kuny0707 Jul 8, 2025
d7715c7
resolve code conflicts
zeusoo001 Jul 10, 2025
bae51b0
Merge branch 'release_v4.8.1' of github.com:tronprotocol/java-tron in…
zeusoo001 Jul 11, 2025
f85de4a
Merge branch 'release_v4.8.1' of github.com:tronprotocol/java-tron in…
zeusoo001 Jul 11, 2025
81c6528
feat(net):Optimize rate limiting logic and add tests
jwrct Jul 11, 2025
44dcce3
feat(dependencies): update dependencies
halibobo1205 Jul 3, 2025
e9403b0
feat(approving): convert the approving window configuration to chain …
lxcmyf Jul 7, 2025
399d159
Merge remote-tracking branch 'upstream/release_v4.8.1' into feature/v…
lxcmyf Jul 14, 2025
3f280c9
Merge pull request #6364 from vivian1912/doc-update-readme
kuny0707 Jul 16, 2025
26d5fe4
feat(net): add configuration for p2p message rate limit
jwrct Jul 22, 2025
12e2faf
feat(config): sync config with tron-deployment
halibobo1205 May 22, 2025
46b1c09
fix(log): fix log issue
jwrct Aug 5, 2025
e3f9b52
feat(conf): make compatible with old configurations
lxcmyf Aug 1, 2025
f8bd7cf
refactor(crypto,api): improve code quality
halibobo1205 Aug 6, 2025
ff2a507
Merge remote-tracking branch 'upstream/release_v4.8.1' into feature/v…
lxcmyf Aug 7, 2025
7e26460
Merge pull request #6400 from halibobo1205/481/update_dependencies
kuny0707 Aug 7, 2025
23a3f42
Merge pull request #6332 from halibobo1205/feat/update_config
kuny0707 Aug 7, 2025
5a487dc
Merge pull request #6381 from zeusoo001/sync-problem
kuny0707 Aug 7, 2025
5b2bb67
Merge pull request #6360 from zeusoo001/volatile-modifier
kuny0707 Aug 7, 2025
b730030
Merge pull request #6356 from zeusoo001/blackhole-log-opt
kuny0707 Aug 7, 2025
2c06f4f
Merge pull request #6417 from halibobo1205/fix/code-scanning
kuny0707 Aug 11, 2025
ae6222c
Merge pull request #6399 from lxcmyf/feature/voting_window_period
kuny0707 Aug 12, 2025
21f98b4
feat(db): merge related tools into FullNode/Toolkit
halibobo1205 Jun 30, 2025
6c29cb2
Merge pull request #6394 from jwrct/fix_reason_code
kuny0707 Aug 13, 2025
c1f3956
Merge pull request #6393 from fyyhtx/rate_limit
kuny0707 Aug 13, 2025
9247853
Merge pull request #6397 from halibobo1205/feat/command_opt
kuny0707 Aug 13, 2025
50d6f69
feat(architecture): support arm64 based on JDK17 (#6327)
halibobo1205 Aug 14, 2025
d2d49bb
feat(crypto): optimize zksnark config (#6371)
Federico2014 Aug 14, 2025
6a75d50
feat(section-bloom): write section-bloom and block.bloom (#6372)
bladehan1 Aug 14, 2025
c7f133d
feat(jsonrpc): jsonrpc set error resolver (#6369)
0xbigapple Aug 15, 2025
2dcdb45
feat(jsonrpc): optimize event log query (#6370)
0xbigapple Aug 15, 2025
456b4eb
fix(net): optimize disconnect reason for light node (#6375)
317787106 Aug 18, 2025
00d6b77
feat(jsonrpc): implement eth_getBlockReceipts (#6379)
0xbigapple Aug 18, 2025
f7a6748
fix(crypto): resolve the invalid witness (#6368)
Federico2014 Aug 19, 2025
cfaf4c0
feat(API): return witness list with latest vote count in desc order (…
Sunny6889 Aug 20, 2025
7620271
feat(gradle): upgrade the maven publishing (#6367)
Federico2014 Aug 20, 2025
b3ffa43
fix(ReasonCode): change BELOW_THAN_ME from 0X24 to 0x24 (#6426)
halibobo1205 Aug 20, 2025
d6ad738
refactor(db): unify database engine initialization (#6421)
halibobo1205 Aug 21, 2025
9e456c3
fix(test): fix the ZksnarkInitTest (#6427)
Federico2014 Aug 21, 2025
af0e59f
feat(tvm): implement TIP-6780 (#6383)
raymondliu0711 Aug 21, 2025
f22c8ae
feat(net): optimize fetch inventory message processing logic (#5895)
zeusoo001 Aug 21, 2025
8481e81
feat(dependencies): update grpc (#6429)
halibobo1205 Aug 26, 2025
6d4e244
feat(gradle): update verification metadata (#6431)
halibobo1205 Aug 26, 2025
b1bf6aa
feat(config): fill whole config items (#6430)
317787106 Aug 29, 2025
560200f
fix(jsonrpc): support blockHash param and genesis block process for e…
0xbigapple Aug 29, 2025
02f81c6
fix(test): release resource of testcases gracefully (#6437)
317787106 Sep 5, 2025
3a1a5d0
feat(db): update to rocksdb 9 for arm (#6440)
halibobo1205 Sep 9, 2025
7015fa3
fix(test): remove all junit dir and add timeout for gRPC call (#6441)
317787106 Sep 9, 2025
ba5f70e
update version to 4.8.1 (#6445)
317787106 Sep 10, 2025
68773e3
feat(cli): change newly added "--keystore" parameter to "--keystore-f…
halibobo1205 Sep 15, 2025
40cc590
feat(tvm): remove deprecated config in TIP-6780 implementation (#6448)
aiden3885 Sep 15, 2025
e0d167f
fet(event): optimize event service to obtain transaction information …
zeusoo001 Sep 15, 2025
732e7bc
fix(API): get now witness count (#6451)
Sunny6889 Sep 17, 2025
316de9a
log(http): revert workaround for CodeQL java/error-message-exposure (…
halibobo1205 Sep 18, 2025
ac6bc5f
fix(command): add missing help message for '--keystore-factory' (#6450)
halibobo1205 Sep 18, 2025
7f237fd
feat(exit): throw TronError if the JDK does not support (#6455)
halibobo1205 Sep 24, 2025
04f7991
feat(db): optimize the compatibility of obtaining transaction info (#…
zeusoo001 Sep 25, 2025
b9753ce
feat(jvm): Optimize JVM GC logging for arm64 (#6457)
halibobo1205 Sep 25, 2025
b5a7fcd
fix(exception): wrap parameter check exceptions with TronError (#6454)
lxcmyf Sep 28, 2025
6e5eda8
test(grpc): mitigate GRPC test hangs with timeout rule (#6460)
halibobo1205 Sep 29, 2025
a86947c
feat(runtime): enforce Java 17 for ARM64 (#6459)
halibobo1205 Sep 29, 2025
e19b2a1
fix(config): replace the Exception with TronError (#6452)
Federico2014 Sep 29, 2025
9429b82
feat(event): optimize event service thread close logic (#6463)
zeusoo001 Oct 13, 2025
d72cbf3
fix(CodeQL): revert implicit narrowing conversion (#6466)
halibobo1205 Oct 15, 2025
640b198
remove the clearParam (#6471)
Federico2014 Oct 23, 2025
48cad61
test(auto-stop): prevent test hang by ensuring proper auto-stop (#6469)
halibobo1205 Oct 23, 2025
a4fbb0c
feat(db/rocksdb): improve resource management with try-with-resources…
halibobo1205 Oct 29, 2025
30f6fee
fix(log): restore logger context after test to prevent pollution (#6476)
halibobo1205 Nov 5, 2025
35b1c4f
feat(dependencies): bump libp2p from 2.2.6 to 2.2.7 (#6481)
317787106 Nov 20, 2025
1b637fd
fix(doc): update x86 java start params (#6478)
Sunny6889 Nov 25, 2025
8aed63c
fix rpc close leakage (#6483)
Sunny6889 Nov 27, 2025
0779184
fix(testcase): remove peer from PeerManager after testcase (#6486)
317787106 Nov 27, 2025
114bbec
Optimize memory allocation for the filter interface of JSON-RPC, eth_…
317787106 Dec 24, 2025
d7b976f
feat(*): disable market transaction
halibobo1205 Dec 25, 2025
6518122
test(proposal): reactor market proposal test
halibobo1205 Dec 26, 2025
9f932ec
test(proposal): reactor activateFork
halibobo1205 Dec 26, 2025
def125e
Merge pull request #6499 from halibobo1205/fea/market
lvs0075 Dec 29, 2025
709b645
func(vm): optimize selfdestruct restriction
yanghang8612 Dec 24, 2025
d975f65
func(vm): add unit test cases
yanghang8612 Dec 30, 2025
c34f2b5
Merge pull request #6501 from yanghang8612/optimize_selfdestruct_rest…
lvs0075 Dec 30, 2025
cdd720a
feat(protocol): support macOS ARM64 with Universal Binary (#6502)
halibobo1205 Dec 30, 2025
d0923d1
feat(db): optimize the logic for obtaining transactions that require …
jakamobiii Jan 9, 2026
28ce436
feat(net): optimize transaction processing logic
jakamobiii Jan 12, 2026
09d2199
optimize getVerifyTxsTest unit test
jakamobiii Jan 12, 2026
68220a4
Merge pull request #6505 from jakamobiii/opt-getVerifyTxs
lvs0075 Jan 13, 2026
5551cfe
Merge pull request #6506 from jakamobiii/opt-trx-process-logic
lvs0075 Jan 13, 2026
6ffedb4
merge master to 4.8.1 (#6509)
halibobo1205 Jan 13, 2026
bebc5b3
fix(crypto): throw exception if system shielded tx is not supported. …
Federico2014 Jan 21, 2026
eed14d7
fix(doc): update readme to be more user friendly (#6512)
Sunny6889 Jan 21, 2026
b5e40ee
fix(doc): remove wrong texts (#6516)
Sunny6889 Jan 21, 2026
02b28c4
fix(script): update script to comply with regulations (#6521)
Sunny6889 Jan 23, 2026
7251c60
fix(acurator): add more check for AssetIssueActuator (#6525)
317787106 Jan 28, 2026
26baac4
feat(event): optimize concurrent write issues for contract events (#6…
zeusoo001 Jan 28, 2026
34f25e0
fix(script): update install dependency script (#6528)
Sunny6889 Jan 28, 2026
97f1f6f
feat(event): optimize the event cache solid block ID update logic (#6…
zeusoo001 Jan 30, 2026
3d9eee7
feat(http): replace getRequestURI() with getServletPath() (#6534)
halibobo1205 Jan 30, 2026
1359fd6
Merge branch 'master' into release_v4.8.1
kuny0707 Feb 3, 2026
6b85652
remove reduant exchange exclusion (#6539)
317787106 Feb 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
243 changes: 131 additions & 112 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.math.StrictMathWrapper;
import org.tron.common.utils.DecodeUtil;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.AssetIssueCapsule;
import org.tron.core.capsule.TransactionResultCapsule;
import org.tron.core.config.Parameter.ForkBlockVersionEnum;
import org.tron.core.exception.BalanceInsufficientException;
import org.tron.core.exception.ContractExeException;
import org.tron.core.exception.ContractValidateException;
Expand Down Expand Up @@ -263,6 +265,16 @@ public boolean validate() throws ContractValidateException {
"frozenDuration must be less than " + maxFrozenSupplyTime + " days "
+ "and more than " + minFrozenSupplyTime + " days");
}
// make sure FrozenSupply.expireTime not overflow
if (chainBaseManager.getForkController().pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
long frozenPeriod = next.getFrozenDays() * FROZEN_PERIOD;
try {
StrictMathWrapper.addExact(assetIssueContract.getStartTime(), frozenPeriod);
} catch (ArithmeticException e) {
throw new ContractValidateException(
"Start time and frozen days would cause expire time overflow");
}
}
remainSupply -= next.getFrozenAmount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.DecodeUtil;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.ProposalCapsule;
Expand Down Expand Up @@ -53,7 +52,7 @@ public boolean execute(Object result) throws ContractExeException {

long currentMaintenanceTime =
chainBaseManager.getDynamicPropertiesStore().getNextMaintenanceTime();
long now3 = now + CommonParameter.getInstance().getProposalExpireTime();
long now3 = now + chainBaseManager.getDynamicPropertiesStore().getProposalExpireTime();
long round = (now3 - currentMaintenanceTime) / maintenanceTimeInterval;
long expirationTime =
currentMaintenanceTime + (round + 1) * maintenanceTimeInterval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,27 @@ private void executeShielded(List<SpendDescription> spends, List<ReceiveDescript
}
nullifierStore.put(new BytesCapsule(spend.getNullifier().toByteArray()));
}
if (CommonParameter.getInstance().isFullNodeAllowShieldedTransactionArgs()) {
IncrementalMerkleTreeContainer currentMerkle = merkleContainer.getCurrentMerkle();

IncrementalMerkleTreeContainer currentMerkle = merkleContainer.getCurrentMerkle();
try {
currentMerkle.wfcheck();
} catch (ZksnarkException e) {
ret.setStatus(fee, code.FAILED);
ret.setShieldedTransactionFee(fee);
throw new ContractExeException(e.getMessage());
}
//handle receives
for (ReceiveDescription receive : receives) {
try {
currentMerkle.wfcheck();
merkleContainer
.saveCmIntoMerkleTree(currentMerkle, receive.getNoteCommitment().toByteArray());
} catch (ZksnarkException e) {
ret.setStatus(fee, code.FAILED);
ret.setStatus(0, code.FAILED);
ret.setShieldedTransactionFee(fee);
throw new ContractExeException(e.getMessage());
}
//handle receives
for (ReceiveDescription receive : receives) {
try {
merkleContainer
.saveCmIntoMerkleTree(currentMerkle, receive.getNoteCommitment().toByteArray());
} catch (ZksnarkException e) {
ret.setStatus(0, code.FAILED);
ret.setShieldedTransactionFee(fee);
throw new ContractExeException(e.getMessage());
}
}
merkleContainer.setCurrentMerkle(currentMerkle);
}
merkleContainer.setCurrentMerkle(currentMerkle);
}

@Override
Expand Down Expand Up @@ -236,8 +235,7 @@ public boolean validate() throws ContractValidateException {
throw new ContractValidateException("duplicate sapling nullifiers in this transaction");
}
nfSet.add(spendDescription.getNullifier());
if (CommonParameter.getInstance().isFullNodeAllowShieldedTransactionArgs()
&& !merkleContainer.merkleRootExist(spendDescription.getAnchor().toByteArray())) {
if (!merkleContainer.merkleRootExist(spendDescription.getAnchor().toByteArray())) {
throw new ContractValidateException("Rt is invalid.");
}
if (nullifierStore.has(spendDescription.getNullifier().toByteArray())) {
Expand Down
38 changes: 36 additions & 2 deletions actuator/src/main/java/org/tron/core/utils/ProposalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE;
import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE;
import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE;
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
import static org.tron.core.config.Parameter.ChainConstant.ONE_YEAR_BLOCK_NUMBERS;

import org.tron.common.utils.ForkController;
Expand Down Expand Up @@ -354,7 +356,8 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
break;
}
case ALLOW_MARKET_TRANSACTION: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)) {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)
|| forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_MARKET_TRANSACTION]");
}
Expand Down Expand Up @@ -839,6 +842,35 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
}
break;
}
case ALLOW_TVM_SELFDESTRUCT_RESTRICTION: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_TVM_SELFDESTRUCT_RESTRICTION]");
}
if (dynamicPropertiesStore.allowTvmSelfdestructRestriction()) {
throw new ContractValidateException(
"[ALLOW_TVM_SELFDESTRUCT_RESTRICTION] has been valid, no need to propose again");
}
if (value != 1) {
throw new ContractValidateException(
"This value[ALLOW_TVM_SELFDESTRUCT_RESTRICTION] is only allowed to be 1");
}
break;
}
case PROPOSAL_EXPIRE_TIME: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
throw new ContractValidateException(
"Bad chain parameter id [PROPOSAL_EXPIRE_TIME]");
}
if (value <= MIN_PROPOSAL_EXPIRE_TIME
|| value >= MAX_PROPOSAL_EXPIRE_TIME) {
throw new ContractValidateException(
"This value[PROPOSAL_EXPIRE_TIME] is only allowed to be greater than "
+ MIN_PROPOSAL_EXPIRE_TIME + " and less than "
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
}
break;
}
default:
break;
}
Expand Down Expand Up @@ -921,7 +953,9 @@ public enum ProposalType { // current value, value range
ALLOW_TVM_CANCUN(83), // 0, 1
ALLOW_STRICT_MATH(87), // 0, 1
CONSENSUS_LOGIC_OPTIMIZATION(88), // 0, 1
ALLOW_TVM_BLOB(89); // 0, 1
ALLOW_TVM_BLOB(89), // 0, 1
PROPOSAL_EXPIRE_TIME(92), // (0, 31536003000)
ALLOW_TVM_SELFDESTRUCT_RESTRICTION(94); // 0, 1

private long code;

Expand Down
9 changes: 9 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/EnergyCost.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class EnergyCost {
private static final long EXT_CODE_SIZE = 20;
private static final long EXT_CODE_HASH = 400;
private static final long SUICIDE = 0;
private static final long SUICIDE_V2 = 5000;
private static final long STOP = 0;
private static final long CREATE_DATA = 200;
private static final long TLOAD = 100;
Expand Down Expand Up @@ -289,6 +290,14 @@ public static long getSuicideCost2(Program program) {
return getSuicideCost(program);
}

public static long getSuicideCost3(Program program) {
DataWord inheritorAddress = program.getStack().peek();
if (isDeadAccount(program, inheritorAddress)) {
return SUICIDE_V2 + NEW_ACCT_CALL;
}
return SUICIDE_V2;
}

public static long getBalanceCost(Program ignored) {
return BALANCE;
}
Expand Down
15 changes: 15 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/OperationActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1072,4 +1072,19 @@ public static void suicideAction(Program program) {
program.stop();
}

public static void suicideAction2(Program program) {
if (program.isStaticCall()) {
throw new Program.StaticCallModificationException();
}

if (!program.canSuicide2()) {
program.getResult().setRevert();
} else {
DataWord address = program.stackPop();
program.suicide2(address);
}

program.stop();
}

}
11 changes: 11 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/OperationRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public static JumpTable getTable() {
adjustForFairEnergy(table);
}

if (VMConfig.allowTvmSelfdestructRestriction()) {
adjustSelfdestruct(table);
}

return table;
}

Expand Down Expand Up @@ -695,4 +699,11 @@ public static void appendCancunOperations(JumpTable table) {
OperationActions::blobBaseFeeAction,
tvmBlobProposal));
}

public static void adjustSelfdestruct(JumpTable table) {
table.set(new Operation(
Op.SUICIDE, 1, 0,
EnergyCost::getSuicideCost3,
OperationActions::suicideAction2));
}
}
56 changes: 40 additions & 16 deletions actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.tron.common.utils.ByteUtil.parseWord;
import static org.tron.common.utils.ByteUtil.stripLeadingZeroes;
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
import static org.tron.core.vm.VMConstant.SIG_LENGTH;

import com.google.protobuf.ByteString;

Expand All @@ -41,6 +42,7 @@
import org.apache.commons.lang3.tuple.Triple;
import org.tron.common.crypto.Blake2bfMessageDigest;
import org.tron.common.crypto.Hash;
import org.tron.common.crypto.Rsv;
import org.tron.common.crypto.SignUtils;
import org.tron.common.crypto.SignatureInterface;
import org.tron.common.crypto.zksnark.BN128;
Expand Down Expand Up @@ -201,7 +203,7 @@ public class PrecompiledContracts {
public static PrecompiledContract getOptimizedContractForConstant(PrecompiledContract contract) {
try {
Constructor<?> constructor = contract.getClass().getDeclaredConstructor();
return (PrecompiledContracts.PrecompiledContract) constructor.newInstance();
return (PrecompiledContracts.PrecompiledContract) constructor.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -352,22 +354,13 @@ private static byte[] encodeMultiRes(byte[]... words) {
}

private static byte[] recoverAddrBySign(byte[] sign, byte[] hash) {
byte v;
byte[] r;
byte[] s;
byte[] out = null;
if (ArrayUtils.isEmpty(sign) || sign.length < 65) {
return new byte[0];
}
try {
r = Arrays.copyOfRange(sign, 0, 32);
s = Arrays.copyOfRange(sign, 32, 64);
v = sign[64];
if (v < 27) {
v += 27;
}

SignatureInterface signature = SignUtils.fromComponents(r, s, v,
Rsv rsv = Rsv.fromSignature(sign);
SignatureInterface signature = SignUtils.fromComponents(rsv.getR(), rsv.getS(), rsv.getV(),
CommonParameter.getInstance().isECKeyCryptoEngine());
if (signature.validateComponents()) {
out = SignUtils.signatureToAddress(hash, signature,
Expand Down Expand Up @@ -403,6 +396,20 @@ private static byte[][] extractBytesArray(DataWord[] words, int offset, byte[] d
return bytesArray;
}

private static byte[][] extractSigArray(DataWord[] words, int offset, byte[] data) {
if (offset > words.length - 1) {
return new byte[0][];
}
int len = words[offset].intValueSafe();
byte[][] bytesArray = new byte[len][];
for (int i = 0; i < len; i++) {
int bytesOffset = words[offset + i + 1].intValueSafe() / WORD_SIZE;
bytesArray[i] = extractBytes(data, (bytesOffset + offset + 2) * WORD_SIZE,
SIG_LENGTH);
}
return bytesArray;
}

private static byte[] extractBytes(byte[] data, int offset, int len) {
return Arrays.copyOfRange(data, offset, offset + len);
}
Expand Down Expand Up @@ -944,8 +951,15 @@ public Pair<Boolean, byte[]> execute(byte[] rawData) {
byte[] hash = Sha256Hash.hash(CommonParameter
.getInstance().isECKeyCryptoEngine(), combine);

byte[][] signatures = extractBytesArray(
words, words[3].intValueSafe() / WORD_SIZE, rawData);
if (VMConfig.allowTvmSelfdestructRestriction()) {
int sigArraySize = words[words[3].intValueSafe() / WORD_SIZE].intValueSafe();
if (sigArraySize > MAX_SIZE) {
return Pair.of(true, DATA_FALSE);
}
}
byte[][] signatures = VMConfig.allowTvmSelfdestructRestriction() ?
extractSigArray(words, words[3].intValueSafe() / WORD_SIZE, rawData) :
extractBytesArray(words, words[3].intValueSafe() / WORD_SIZE, rawData);

if (signatures.length == 0 || signatures.length > MAX_SIZE) {
return Pair.of(true, DATA_FALSE);
Expand Down Expand Up @@ -1029,8 +1043,18 @@ private Pair<Boolean, byte[]> doExecute(byte[] data)
throws InterruptedException, ExecutionException {
DataWord[] words = DataWord.parseArray(data);
byte[] hash = words[0].getData();
byte[][] signatures = extractBytesArray(
words, words[1].intValueSafe() / WORD_SIZE, data);

if (VMConfig.allowTvmSelfdestructRestriction()) {
int sigArraySize = words[words[1].intValueSafe() / WORD_SIZE].intValueSafe();
int addrArraySize = words[words[2].intValueSafe() / WORD_SIZE].intValueSafe();
if (sigArraySize > MAX_SIZE || addrArraySize > MAX_SIZE) {
return Pair.of(true, DATA_FALSE);
}
}

byte[][] signatures = VMConfig.allowTvmSelfdestructRestriction() ?
extractSigArray(words, words[1].intValueSafe() / WORD_SIZE, data) :
extractBytesArray(words, words[1].intValueSafe() / WORD_SIZE, data);
byte[][] addresses = extractBytes32Array(
words, words[2].intValueSafe() / WORD_SIZE);
int cnt = signatures.length;
Expand Down
5 changes: 4 additions & 1 deletion actuator/src/main/java/org/tron/core/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public static void play(Program program, JumpTable jumpTable) {
} catch (JVMStackOverFlowException | OutOfTimeException e) {
throw e;
} catch (RuntimeException e) {
if (StringUtils.isEmpty(e.getMessage())) {
// https://openjdk.org/jeps/358
// https://bugs.openjdk.org/browse/JDK-8220715
// since jdk 14, the NullPointerExceptions message is not empty
if (e instanceof NullPointerException || StringUtils.isEmpty(e.getMessage())) {
logger.warn("Unknown Exception occurred, tx id: {}",
Hex.toHexString(program.getRootTransactionId()), e);
program.setRuntimeFailure(new RuntimeException("Unknown Exception"));
Expand Down
1 change: 1 addition & 0 deletions actuator/src/main/java/org/tron/core/vm/VMConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class VMConstant {

public static final int CONTRACT_NAME_LENGTH = 32;
public static final int MIN_TOKEN_ID = 1_000_000;
public static final int SIG_LENGTH = 65;

// Numbers
public static final int ONE_HUNDRED = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static void load(StoreFactory storeFactory) {
VMConfig.initAllowTvmCancun(ds.getAllowTvmCancun());
VMConfig.initDisableJavaLangMath(ds.getConsensusLogicOptimization());
VMConfig.initAllowTvmBlob(ds.getAllowTvmBlob());
VMConfig.initAllowTvmSelfdestructRestriction(ds.getAllowTvmSelfdestructRestriction());
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/program/ContractState.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ public void updateContractState(byte[] address, ContractStateCapsule contractSta
repository.updateContractState(address, contractStateCapsule);
}

@Override
public void putNewContract(byte[] address) {
repository.putNewContract(address);
}

@Override
public boolean isNewContract(byte[] address) {
return repository.isNewContract(address);
}

@Override
public void updateAccount(byte[] address, AccountCapsule accountCapsule) {
repository.updateAccount(address, accountCapsule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void write(int address, byte[] data, int dataSize, boolean limited) {

public void extendAndWrite(int address, int allocSize, byte[] data) {
extend(address, allocSize);
write(address, data, data.length, false);
write(address, data, allocSize, false);
}

public void extend(int address, int size) {
Expand Down
Loading
Loading