Skip to content

Commit 8fd659f

Browse files
committed
feature(consensus): optimize signatures
1 parent cb6c15a commit 8fd659f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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;

0 commit comments

Comments
 (0)