Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ private boolean checkPermission(Permission permission) throws ContractValidateEx
long weightSum = 0;
List<ByteString> addressList = permission.getKeysList()
.stream()
.map(x -> x.getAddress())
.map(Key::getAddress)
.distinct()
.collect(toList());
if (addressList.size() != permission.getKeysList().size()) {
throw new ContractValidateException(
"address should be distinct in permission " + permission.getType());
}

for (Key key : permission.getKeysList()) {
if (!DecodeUtil.addressValid(key.getAddress().toByteArray())) {
throw new ContractValidateException("key is not a validate address");
Expand Down Expand Up @@ -237,4 +238,5 @@ public ByteString getOwnerAddress() throws InvalidProtocolBufferException {
public long calcFee() {
return chainBaseManager.getDynamicPropertiesStore().getUpdateAccountPermissionFee();
}

}
20 changes: 19 additions & 1 deletion actuator/src/main/java/org/tron/core/utils/ProposalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,22 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
}
break;
}
case ALLOW_FN_DSA_512: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_2)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_FN_DSA_512]");
}
if (value != 0 && value != 1) {
throw new ContractValidateException(
"This value[ALLOW_FN_DSA_512] is only allowed to be 0 or 1");
}
if (dynamicPropertiesStore.getAllowFnDsa512() == value) {
throw new ContractValidateException(
"[ALLOW_FN_DSA_512] has been set to " + value
+ ", no need to propose again");
}
break;
}
default:
break;
}
Expand Down Expand Up @@ -1029,7 +1045,9 @@ public enum ProposalType { // current value, value range
ALLOW_TVM_PRAGUE(95), // 0, 1
ALLOW_TVM_OSAKA(96), // 0, 1
ALLOW_HARDEN_RESOURCE_CALCULATION(97), // 0, 1
ALLOW_HARDEN_EXCHANGE_CALCULATION(98); // 0, 1
ALLOW_HARDEN_EXCHANGE_CALCULATION(98), // 0, 1
ALLOW_FN_DSA_512(99); // 0, 1

private long code;

ProposalType(long code) {
Expand Down
22 changes: 18 additions & 4 deletions actuator/src/main/java/org/tron/core/utils/TransactionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.tron.api.GrpcAPI.TransactionExtention;
import org.tron.api.GrpcAPI.TransactionSignWeight;
import org.tron.api.GrpcAPI.TransactionSignWeight.Result;
import org.tron.common.math.StrictMathWrapper;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.ChainBaseManager;
Expand Down Expand Up @@ -221,11 +222,24 @@ public TransactionSignWeight getTransactionSignWeight(Transaction trx) {
}
}
tswBuilder.setPermission(permission);
if (trx.getSignatureCount() > 0) {
if (trx.getSignatureCount() > 0 || trx.getPqAuthSigCount() > 0) {
List<ByteString> approveList = new ArrayList<>();
long currentWeight = TransactionCapsule.checkWeight(permission, trx.getSignatureList(),
Sha256Hash.hash(CommonParameter.getInstance()
.isECKeyCryptoEngine(), trx.getRawData().toByteArray()), approveList);
long currentWeight = 0L;
if (trx.getSignatureCount() > 0) {
currentWeight = TransactionCapsule.checkWeight(permission, trx.getSignatureList(),
Sha256Hash.hash(CommonParameter.getInstance()
.isECKeyCryptoEngine(), trx.getRawData().toByteArray()), approveList);
}
if (trx.getPqAuthSigCount() > 0) {
java.util.Set<ByteString> signedAddresses = new java.util.HashSet<>(approveList);
try {
currentWeight = StrictMathWrapper.addExact(currentWeight,
TransactionCapsule.validatePQSignature(trx, permission, signedAddresses,
chainBaseManager.getDynamicPropertiesStore(), approveList));
} catch (ArithmeticException e) {
throw new PermissionException("weight overflow");
}
}
tswBuilder.addAllApprovedList(approveList);
tswBuilder.setCurrentWeight(currentWeight);
}
Expand Down
Loading
Loading