Skip to content

Commit 954125e

Browse files
authored
Merge pull request #5022 from halibobo1205/release_v4.7.1
Release v4.7.1
2 parents 1a212fa + f8bab83 commit 954125e

File tree

7 files changed

+46
-6
lines changed

7 files changed

+46
-6
lines changed

actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262
import org.tron.core.exception.ZksnarkException;
6363
import org.tron.core.vm.config.VMConfig;
6464
import org.tron.core.vm.program.Program;
65+
import org.tron.core.vm.program.Program.OutOfTimeException;
6566
import org.tron.core.vm.repository.Repository;
6667
import org.tron.core.vm.utils.FreezeV2Util;
68+
import org.tron.core.vm.utils.MUtil;
6769
import org.tron.core.vm.utils.VoteRewardUtil;
6870
import org.tron.protos.Protocol;
6971
import org.tron.protos.Protocol.Permission;
@@ -944,24 +946,33 @@ public Pair<Boolean, byte[]> execute(byte[] rawData) {
944946
long totalWeight = 0L;
945947
List<byte[]> executedSignList = new ArrayList<>();
946948
for (byte[] sign : signatures) {
947-
if (ByteArray.matrixContains(executedSignList, sign)) {
948-
continue;
949-
}
950949
byte[] recoveredAddr = recoverAddrBySign(sign, hash);
950+
951+
sign = merge(recoveredAddr, sign);
952+
if (ByteArray.matrixContains(executedSignList, recoveredAddr)) {
953+
if (ByteArray.matrixContains(executedSignList, sign)) {
954+
continue;
955+
}
956+
MUtil.checkCPUTime();
957+
}
951958
long weight = TransactionCapsule.getWeight(permission, recoveredAddr);
952959
if (weight == 0) {
953960
//incorrect sign
954961
return Pair.of(true, DATA_FALSE);
955962
}
956963
totalWeight += weight;
957964
executedSignList.add(sign);
965+
executedSignList.add(recoveredAddr);
958966
}
959967

960968
if (totalWeight >= permission.getThreshold()) {
961969
return Pair.of(true, dataOne());
962970
}
963971
}
964972
} catch (Throwable t) {
973+
if (t instanceof OutOfTimeException) {
974+
throw t;
975+
}
965976
logger.info("ValidateMultiSign error:{}", t.getMessage());
966977
}
967978
}

actuator/src/main/java/org/tron/core/vm/utils/MUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.tron.core.vm.utils;
22

3+
import org.tron.common.utils.ForkController;
34
import org.tron.core.capsule.AccountCapsule;
5+
import org.tron.core.config.Parameter;
46
import org.tron.core.exception.ContractValidateException;
57
import org.tron.core.vm.VMUtils;
8+
import org.tron.core.vm.program.Program.OutOfTimeException;
69
import org.tron.core.vm.repository.Repository;
710
import org.tron.protos.Protocol;
811

@@ -55,4 +58,10 @@ public static boolean isNullOrEmpty(String str) {
5558
public static boolean isNotNullOrEmpty(String str) {
5659
return !isNullOrEmpty(str);
5760
}
61+
62+
public static void checkCPUTime() {
63+
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
64+
throw new OutOfTimeException("CPU timeout for 0x0a executing");
65+
}
66+
}
5867
}

chainbase/src/main/java/org/tron/common/utils/ForkController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public boolean pass(ForkBlockVersionEnum forkBlockVersionEnum) {
4444
}
4545

4646
public synchronized boolean pass(int version) {
47+
if (manager == null) {
48+
throw new IllegalStateException("not inited");
49+
}
4750
if (version > ForkBlockVersionEnum.VERSION_4_0.getValue()) {
4851
return passNew(version);
4952
} else {

chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
import org.tron.common.overlay.message.Message;
4747
import org.tron.common.parameter.CommonParameter;
4848
import org.tron.common.utils.ByteArray;
49+
import org.tron.common.utils.ForkController;
4950
import org.tron.common.utils.ReflectUtils;
5051
import org.tron.common.utils.Sha256Hash;
5152
import org.tron.core.actuator.TransactionFactory;
53+
import org.tron.core.config.Parameter;
5254
import org.tron.core.db.TransactionContext;
5355
import org.tron.core.db.TransactionTrace;
5456
import org.tron.core.exception.BadItemException;
@@ -213,6 +215,11 @@ public static long getWeight(Permission permission, byte[] address) {
213215
return 0;
214216
}
215217

218+
/**
219+
* make sure ForkController.init(ChainBaseManager) is invoked before invoke this method.
220+
*
221+
* @see ForkController#init(org.tron.core.ChainBaseManager)
222+
*/
216223
public static long checkWeight(Permission permission, List<ByteString> sigs, byte[] hash,
217224
List<ByteString> approveList)
218225
throws SignatureException, PermissionException, SignatureFormatException {
@@ -237,6 +244,9 @@ public static long checkWeight(Permission permission, List<ByteString> sigs, byt
237244
ByteArray.toHexString(sig.toByteArray()) + " is signed by " + encode58Check(address)
238245
+ " but it is not contained of permission.");
239246
}
247+
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
248+
base64 = encode58Check(address);
249+
}
240250
if (addMap.containsKey(base64)) {
241251
throw new PermissionException(encode58Check(address) + " has signed twice!");
242252
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public enum ForkBlockVersionEnum {
2020
VERSION_4_4(23, 1596780000000L, 80),
2121
VERSION_4_5(24, 1596780000000L, 80),
2222
VERSION_4_6(25, 1596780000000L, 80),
23-
VERSION_4_7(26, 1596780000000L, 80);
23+
VERSION_4_7(26, 1596780000000L, 80),
24+
VERSION_4_7_1(27, 1596780000000L, 80);
2425
// if add a version, modify BLOCK_VERSION simultaneously
2526

2627
@Getter
@@ -69,7 +70,7 @@ public class ChainConstant {
6970
public static final int SINGLE_REPEAT = 1;
7071
public static final int BLOCK_FILLED_SLOTS_NUMBER = 128;
7172
public static final int MAX_FROZEN_NUMBER = 1;
72-
public static final int BLOCK_VERSION = 26;
73+
public static final int BLOCK_VERSION = 27;
7374
public static final long FROZEN_PERIOD = 86_400_000L;
7475
public static final long DELEGATE_PERIOD = 3 * 86_400_000L;
7576
public static final long TRX_PRECISION = 1000_000L;

framework/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies {
4848

4949
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
5050

51-
compile group: 'io.github.tronprotocol', name: 'libp2p', version: '0.1.3'
51+
compile group: 'io.github.tronprotocol', name: 'libp2p', version: '0.1.4'
5252

5353
compile group: 'com.typesafe', name: 'config', version: '1.3.2'
5454

framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ public long calcCanDelegatedEnergyMaxSize(ByteString ownerAddress) {
913913
}
914914

915915
public DelegatedResourceAccountIndex getDelegatedResourceAccountIndex(ByteString address) {
916+
if (address == null || address.size() != DecodeUtil.ADDRESS_SIZE / 2) {
917+
return DelegatedResourceAccountIndex.getDefaultInstance();
918+
}
916919
DelegatedResourceAccountIndexCapsule accountIndexCapsule =
917920
chainBaseManager.getDelegatedResourceAccountIndexStore().getIndex(address.toByteArray());
918921
if (accountIndexCapsule != null) {
@@ -923,6 +926,9 @@ public DelegatedResourceAccountIndex getDelegatedResourceAccountIndex(ByteString
923926
}
924927

925928
public DelegatedResourceAccountIndex getDelegatedResourceAccountIndexV2(ByteString address) {
929+
if (address == null || address.size() != DecodeUtil.ADDRESS_SIZE / 2) {
930+
return DelegatedResourceAccountIndex.getDefaultInstance();
931+
}
926932
DelegatedResourceAccountIndexCapsule accountIndexCapsule = chainBaseManager
927933
.getDelegatedResourceAccountIndexStore().getV2Index(address.toByteArray());
928934
if (accountIndexCapsule != null) {

0 commit comments

Comments
 (0)