From 5be8621950d5cb0b8f49020a013893dd44b96f4f Mon Sep 17 00:00:00 2001 From: liuxincheng Date: Mon, 5 Jun 2023 11:26:11 +0800 Subject: [PATCH] feat(freezeV2): optimize some code logic --- .gitignore | 2 + Tron protobuf protocol document.md | 4 +- ....java => CancelAllUnfreezeV2Actuator.java} | 72 ++------- .../actuator/DelegateResourceActuator.java | 13 +- .../org/tron/core/utils/ProposalUtil.java | 23 +-- .../org/tron/core/utils/TransactionUtil.java | 17 +- .../capsule/TransactionResultCapsule.java | 8 +- .../core/capsule/utils/TransactionUtil.java | 2 +- .../core/store/DynamicPropertiesStore.java | 38 ++--- .../common/parameter/CommonParameter.java | 4 +- .../java/org/tron/core/config/Parameter.java | 1 - .../src/main/java/org/tron/core/Wallet.java | 8 +- .../tron/core/consensus/ProposalService.java | 15 +- .../org/tron/core/services/RpcApiService.java | 6 +- ...t.java => CancelAllUnfreezeV2Servlet.java} | 8 +- .../services/http/FullNodeHttpApiService.java | 6 +- .../http/HttpSelfFormatFieldName.java | 4 +- .../core/services/jsonrpc/JsonRpcApiUtil.java | 6 +- .../common/logsfilter/EventLoaderTest.java | 53 ++++++- .../test/java/org/tron/core/WalletTest.java | 14 +- ...a => CancelAllUnfreezeV2ActuatorTest.java} | 150 ++++-------------- .../DelegateResourceActuatorTest.java | 72 ++++++--- .../actuator/utils/TransactionUtilTest.java | 15 +- .../core/services/http/HttpServletTest.java | 6 +- protocol/src/main/protos/api/api.proto | 2 +- protocol/src/main/protos/core/Tron.proto | 6 +- .../core/contract/balance_contract.proto | 3 +- 27 files changed, 267 insertions(+), 291 deletions(-) rename actuator/src/main/java/org/tron/core/actuator/{CancelUnfreezeV2Actuator.java => CancelAllUnfreezeV2Actuator.java} (69%) rename framework/src/main/java/org/tron/core/services/http/{CancelUnfreezeV2Servlet.java => CancelAllUnfreezeV2Servlet.java} (82%) rename framework/src/test/java/org/tron/core/actuator/{CancelUnfreezeV2ActuatorTest.java => CancelAllUnfreezeV2ActuatorTest.java} (51%) diff --git a/.gitignore b/.gitignore index 9b19aa5de68..6309bbd79a5 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ Wallet # vm_trace /vm_trace/ + +/framework/propPath diff --git a/Tron protobuf protocol document.md b/Tron protobuf protocol document.md index 0c027ea8dd8..852ff313797 100644 --- a/Tron protobuf protocol document.md +++ b/Tron protobuf protocol document.md @@ -627,7 +627,7 @@ Transaction and transaction-related messages. WithdrawExpireUnfreezeContract = 56; DelegateResourceContract = 57; UnDelegateResourceContract = 58; - CancelUnfreezeV2Contract = 59; + CancelAllUnfreezeV2Contract = 59; } ContractType type = 1; google.protobuf.Any parameter = 2; @@ -888,7 +888,7 @@ Contract and contract-related messages. WithdrawExpireUnfreezeContract = 56; DelegateResourceContract = 57; UnDelegateResourceContract = 58; - CancelUnfreezeV2Contract = 59; + CancelAllUnfreezeV2Contract = 59; } ContractType type = 1; google.protobuf.Any parameter = 2; diff --git a/actuator/src/main/java/org/tron/core/actuator/CancelUnfreezeV2Actuator.java b/actuator/src/main/java/org/tron/core/actuator/CancelAllUnfreezeV2Actuator.java similarity index 69% rename from actuator/src/main/java/org/tron/core/actuator/CancelUnfreezeV2Actuator.java rename to actuator/src/main/java/org/tron/core/actuator/CancelAllUnfreezeV2Actuator.java index aa0ff2fe64e..8fd58124b1a 100755 --- a/actuator/src/main/java/org/tron/core/actuator/CancelUnfreezeV2Actuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/CancelAllUnfreezeV2Actuator.java @@ -8,14 +8,10 @@ import com.google.protobuf.ByteString; import com.google.protobuf.InvalidProtocolBufferException; -import java.util.HashSet; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.tuple.Triple; import org.tron.common.utils.DecodeUtil; import org.tron.common.utils.StringUtil; @@ -28,13 +24,13 @@ import org.tron.protos.Protocol.Account.UnFreezeV2; import org.tron.protos.Protocol.Transaction.Contract.ContractType; import org.tron.protos.Protocol.Transaction.Result.code; -import org.tron.protos.contract.BalanceContract.CancelUnfreezeV2Contract; +import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract; @Slf4j(topic = "actuator") -public class CancelUnfreezeV2Actuator extends AbstractActuator { +public class CancelAllUnfreezeV2Actuator extends AbstractActuator { - public CancelUnfreezeV2Actuator() { - super(ContractType.CancelUnfreezeV2Contract, CancelUnfreezeV2Contract.class); + public CancelAllUnfreezeV2Actuator() { + super(ContractType.CancelAllUnfreezeV2Contract, CancelAllUnfreezeV2Contract.class); } @Override @@ -46,18 +42,14 @@ public boolean execute(Object result) throws ContractExeException { long fee = calcFee(); AccountStore accountStore = chainBaseManager.getAccountStore(); DynamicPropertiesStore dynamicStore = chainBaseManager.getDynamicPropertiesStore(); - final CancelUnfreezeV2Contract cancelUnfreezeV2Contract; byte[] ownerAddress; try { - cancelUnfreezeV2Contract = getCancelUnfreezeV2Contract(); ownerAddress = getOwnerAddress().toByteArray(); } catch (InvalidProtocolBufferException e) { logger.debug(e.getMessage(), e); ret.setStatus(fee, code.FAILED); throw new ContractExeException(e.getMessage()); } - List indexList = cancelUnfreezeV2Contract.getIndexList() - .stream().sorted().collect(Collectors.toList()); AccountCapsule ownerCapsule = accountStore.get(ownerAddress); List unfrozenV2List = ownerCapsule.getUnfrozenV2List(); long now = dynamicStore.getLatestBlockHeaderTimestamp(); @@ -65,23 +57,11 @@ public boolean execute(Object result) throws ContractExeException { AtomicLong atomicCancelBalance = new AtomicLong(0L); Triple triple = Triple.of(new AtomicLong(0L), new AtomicLong(0L), new AtomicLong(0L)); - List newUnFreezeV2List = null; - if (indexList.isEmpty()) { - for (UnFreezeV2 unFreezeV2 : unfrozenV2List) { - updateAndCalculate(triple, ownerCapsule, now, atomicWithdrawExpireBalance, - atomicCancelBalance, unFreezeV2); - } - } else { - indexList.forEach(index -> { - UnFreezeV2 unFreezeV2 = unfrozenV2List.get(index); - updateAndCalculate(triple, ownerCapsule, now, atomicWithdrawExpireBalance, - atomicCancelBalance, unFreezeV2); - }); - newUnFreezeV2List = unfrozenV2List.stream() - .filter(o -> !indexList.contains(unfrozenV2List.indexOf(o))).collect(Collectors.toList()); + for (UnFreezeV2 unFreezeV2 : unfrozenV2List) { + updateAndCalculate(triple, ownerCapsule, now, atomicWithdrawExpireBalance, + atomicCancelBalance, unFreezeV2); } ownerCapsule.clearUnfrozenV2(); - ownerCapsule.addAllUnfrozenV2(newUnFreezeV2List); addTotalResourceWeight(dynamicStore, triple); long withdrawExpireBalance = atomicWithdrawExpireBalance.get(); @@ -91,7 +71,7 @@ public boolean execute(Object result) throws ContractExeException { accountStore.put(ownerCapsule.createDbKey(), ownerCapsule); ret.setWithdrawExpireAmount(withdrawExpireBalance); - ret.setCancelUnfreezeV2Amount(atomicCancelBalance.get()); + ret.setCancelAllUnfreezeV2Amount(atomicCancelBalance.get()); ret.setStatus(fee, code.SUCESS); return true; } @@ -127,20 +107,18 @@ public boolean validate() throws ContractValidateException { AccountStore accountStore = chainBaseManager.getAccountStore(); DynamicPropertiesStore dynamicStore = chainBaseManager.getDynamicPropertiesStore(); - if (!this.any.is(CancelUnfreezeV2Contract.class)) { + if (!this.any.is(CancelAllUnfreezeV2Contract.class)) { throw new ContractValidateException("contract type error, expected type " + - "[CancelUnfreezeV2Contract], real type[" + any.getClass() + "]"); + "[CancelAllUnfreezeV2Contract], real type[" + any.getClass() + "]"); } - if (!dynamicStore.supportAllowCancelUnfreezeV2()) { - throw new ContractValidateException("Not support CancelUnfreezeV2 transaction," + if (!dynamicStore.supportAllowCancelAllUnfreezeV2()) { + throw new ContractValidateException("Not support CancelAllUnfreezeV2 transaction," + " need to be opened by the committee"); } - final CancelUnfreezeV2Contract cancelUnfreezeV2Contract; byte[] ownerAddress; try { - cancelUnfreezeV2Contract = getCancelUnfreezeV2Contract(); ownerAddress = getOwnerAddress().toByteArray(); } catch (InvalidProtocolBufferException e) { logger.debug(e.getMessage(), e); @@ -162,37 +140,17 @@ public boolean validate() throws ContractValidateException { throw new ContractValidateException("No unfreezeV2 list to cancel"); } - List indexList = cancelUnfreezeV2Contract.getIndexList(); - if (indexList.size() > unfrozenV2List.size()) { - throw new ContractValidateException( - "The size[" + indexList.size() + "] of the index cannot exceed the size[" - + unfrozenV2List.size() + "] of unfreezeV2!"); - } - - for (Integer i : indexList) { - int maxIndex = unfrozenV2List.size() - 1; - if (i < 0 || i > maxIndex) { - throw new ContractValidateException( - "The input index[" + i + "] cannot be less than 0 and cannot be " - + "greater than the maximum index[" + maxIndex + "] of unfreezeV2!"); - } - } - Set set = new HashSet<>(); - List dps = indexList.stream().filter(n -> !set.add(n)).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(dps)) { - throw new ContractValidateException("The element" + dps + " in the index list is duplicated"); - } return true; } @Override public ByteString getOwnerAddress() throws InvalidProtocolBufferException { - return getCancelUnfreezeV2Contract().getOwnerAddress(); + return getCancelAllUnfreezeV2Contract().getOwnerAddress(); } - private CancelUnfreezeV2Contract getCancelUnfreezeV2Contract() + private CancelAllUnfreezeV2Contract getCancelAllUnfreezeV2Contract() throws InvalidProtocolBufferException { - return any.unpack(CancelUnfreezeV2Contract.class); + return any.unpack(CancelAllUnfreezeV2Contract.class); } @Override diff --git a/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java b/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java index d7dfcd5da14..aab5e076453 100755 --- a/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java +++ b/actuator/src/main/java/org/tron/core/actuator/DelegateResourceActuator.java @@ -2,7 +2,6 @@ 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.MAX_BLOCK_NUM_DELEGATE_PERIOD; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import static org.tron.protos.contract.Common.ResourceCode; import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; @@ -219,11 +218,13 @@ public boolean validate() throws ContractValidateException { } boolean lock = delegateResourceContract.getLock(); - if (lock && dynamicStore.supportAllowOptimizeLockDelegateResource()) { + if (lock && dynamicStore.supportMaxDelegateLockPeriod()) { long lockPeriod = delegateResourceContract.getLockPeriod(); - if (lockPeriod < 0 || lockPeriod > MAX_BLOCK_NUM_DELEGATE_PERIOD) { + long maxDelegateLockPeriod = dynamicStore.getMaxDelegateLockPeriod(); + if (lockPeriod < 0 || lockPeriod > maxDelegateLockPeriod) { throw new ContractValidateException( - "The lock period of delegate resource cannot be less than 0 and cannot exceed 1 year!"); + "The lock period of delegate resource cannot be less than 0 and cannot exceed " + + maxDelegateLockPeriod + "!"); } byte[] key = DelegatedResourceCapsule.createDbKeyV2(ownerAddress, receiverAddress, true); @@ -262,7 +263,7 @@ private void validRemainTime(ResourceCode resourceCode, long lockPeriod, long ex if (lockPeriod * 3 * 1000 < remainTime) { throw new ContractValidateException( "The lock period for " + resourceCode.name() + " this time cannot be less than the " - + "remaining time[" + remainTime + "s] of the last lock period for " + + "remaining time[" + remainTime + "ms] of the last lock period for " + resourceCode.name() + "!"); } } @@ -292,7 +293,7 @@ private void delegateResource(byte[] ownerAddress, byte[] receiverAddress, boole //modify DelegatedResourceStore long expireTime = 0; if (lock) { - if (dynamicPropertiesStore.supportAllowOptimizeLockDelegateResource()) { + if (dynamicPropertiesStore.supportMaxDelegateLockPeriod()) { expireTime = now + (lockPeriod == 0 ? DELEGATE_PERIOD : lockPeriod * 3 * 1000); } else { expireTime = now + DELEGATE_PERIOD; diff --git a/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java b/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java index 7cc45a0021a..24e54c1603b 100644 --- a/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java +++ b/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java @@ -692,35 +692,36 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore, } break; } - case ALLOW_CANCEL_UNFREEZE_V2: { + case ALLOW_CANCEL_ALL_UNFREEZE_V2: { if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_2)) { throw new ContractValidateException( - "Bad chain parameter id [ALLOW_CANCEL_UNFREEZE_V2]"); + "Bad chain parameter id [ALLOW_CANCEL_ALL_UNFREEZE_V2]"); } if (value != 1) { throw new ContractValidateException( - "This value[ALLOW_CANCEL_UNFREEZE_V2] is only allowed to be 1"); + "This value[ALLOW_CANCEL_ALL_UNFREEZE_V2] is only allowed to be 1"); } if (dynamicPropertiesStore.getUnfreezeDelayDays() == 0) { throw new ContractValidateException( "[UNFREEZE_DELAY_DAYS] proposal must be approved " - + "before [ALLOW_CANCEL_UNFREEZE_V2] can be proposed"); + + "before [ALLOW_CANCEL_ALL_UNFREEZE_V2] can be proposed"); } break; } - case ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE: { + case MAX_DELEGATE_LOCK_PERIOD: { if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_2)) { throw new ContractValidateException( - "Bad chain parameter id [ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE]"); + "Bad chain parameter id [MAX_DELEGATE_LOCK_PERIOD]"); } - if (value != 1) { + if (value <= 0) { throw new ContractValidateException( - "This value[ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE] is only allowed to be 1"); + "This value[MAX_DELEGATE_LOCK_PERIOD] is only allowed to be " + + "greater than 0"); } if (dynamicPropertiesStore.getUnfreezeDelayDays() == 0) { throw new ContractValidateException( "[UNFREEZE_DELAY_DAYS] proposal must be approved " - + "before [ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE] can be proposed"); + + "before [MAX_DELEGATE_LOCK_PERIOD] can be proposed"); } break; } @@ -798,8 +799,8 @@ public enum ProposalType { // current value, value range DYNAMIC_ENERGY_INCREASE_FACTOR(74), // 0, [0, 10_000] DYNAMIC_ENERGY_MAX_FACTOR(75), // 0, [0, 100_000] ALLOW_TVM_SHANGHAI(76), // 0, 1 - ALLOW_CANCEL_UNFREEZE_V2(77), // 0, 1 - ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE(78); // 0, 1 + ALLOW_CANCEL_ALL_UNFREEZE_V2(77), // 0, 1 + MAX_DELEGATE_LOCK_PERIOD(78); // 0, 1 private long code; diff --git a/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java b/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java index e8fe963f89b..462a80fa600 100644 --- a/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java +++ b/actuator/src/main/java/org/tron/core/utils/TransactionUtil.java @@ -17,7 +17,6 @@ import static org.tron.common.crypto.Hash.sha3omit12; import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_COST_BASE_SIZE; -import static org.tron.core.config.Parameter.ChainConstant.MAX_BLOCK_NUM_DELEGATE_PERIOD; import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION; import com.google.common.base.CaseFormat; @@ -279,13 +278,19 @@ public static long consumeBandWidthSize( return bytesSize; } - public static long estimateConsumeBandWidthSize(final AccountCapsule ownerCapsule, ChainBaseManager chainBaseManager) { - DelegateResourceContract.Builder builder = DelegateResourceContract.newBuilder() - .setLock(true) - .setLockPeriod(MAX_BLOCK_NUM_DELEGATE_PERIOD) - .setBalance(ownerCapsule.getFrozenV2BalanceForBandwidth()); + DelegateResourceContract.Builder builder; + if (chainBaseManager.getDynamicPropertiesStore().supportMaxDelegateLockPeriod()) { + builder = DelegateResourceContract.newBuilder() + .setLock(true) + .setLockPeriod(chainBaseManager.getDynamicPropertiesStore().getMaxDelegateLockPeriod()) + .setBalance(ownerCapsule.getFrozenV2BalanceForBandwidth()); + } else { + builder = DelegateResourceContract.newBuilder() + .setLock(true) + .setBalance(ownerCapsule.getFrozenV2BalanceForBandwidth()); + } TransactionCapsule fakeTransactionCapsule = new TransactionCapsule(builder.build() , ContractType.DelegateResourceContract); long size1 = consumeBandWidthSize(fakeTransactionCapsule, chainBaseManager); diff --git a/chainbase/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java b/chainbase/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java index 4e93a52d2ac..be86a95f4f6 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java +++ b/chainbase/src/main/java/org/tron/core/capsule/TransactionResultCapsule.java @@ -89,13 +89,13 @@ public void setWithdrawExpireAmount(long amount) { .setWithdrawExpireAmount(amount).build(); } - public long getCancelUnfreezeV2Amount() { - return transactionResult.getCancelUnfreezeV2Amount(); + public long getCancelAllUnfreezeV2Amount() { + return transactionResult.getCancelAllUnfreezeV2Amount(); } - public void setCancelUnfreezeV2Amount(long amount) { + public void setCancelAllUnfreezeV2Amount(long amount) { this.transactionResult = this.transactionResult.toBuilder() - .setCancelUnfreezeV2Amount(amount).build(); + .setCancelAllUnfreezeV2Amount(amount).build(); } public long getExchangeReceivedAmount() { diff --git a/chainbase/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java b/chainbase/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java index ca366a3d8d7..047a21b68cb 100644 --- a/chainbase/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java +++ b/chainbase/src/main/java/org/tron/core/capsule/utils/TransactionUtil.java @@ -100,7 +100,7 @@ public static TransactionInfoCapsule buildTransactionInfoInstance(TransactionCap builder.setExchangeId(programResult.getRet().getExchangeId()); builder.setWithdrawAmount(programResult.getRet().getWithdrawAmount()); builder.setWithdrawExpireAmount(programResult.getRet().getWithdrawExpireAmount()); - builder.setCancelUnfreezeV2Amount(programResult.getRet().getCancelUnfreezeV2Amount()); + builder.setCancelAllUnfreezeV2Amount(programResult.getRet().getCancelAllUnfreezeV2Amount()); builder.setExchangeReceivedAmount(programResult.getRet().getExchangeReceivedAmount()); builder.setExchangeInjectAnotherAmount(programResult.getRet().getExchangeInjectAnotherAmount()); builder.setExchangeWithdrawAnotherAmount( diff --git a/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java b/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java index d1a4140e461..b5a11be1545 100644 --- a/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java +++ b/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java @@ -207,11 +207,11 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking private static final byte[] ALLOW_TVM_SHANGHAI = "ALLOW_TVM_SHANGHAI".getBytes(); - private static final byte[] ALLOW_CANCEL_UNFREEZE_V2 = "ALLOW_CANCEL_UNFREEZE_V2" + private static final byte[] ALLOW_CANCEL_ALL_UNFREEZE_V2 = "ALLOW_CANCEL_ALL_UNFREEZE_V2" .getBytes(); - private static final byte[] ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE = - "ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE".getBytes(); + private static final byte[] MAX_DELEGATE_LOCK_PERIOD = + "MAX_DELEGATE_LOCK_PERIOD".getBytes(); @Autowired private DynamicPropertiesStore(@Value("properties") String dbName) { @@ -2783,36 +2783,36 @@ public long getAllowTvmShangHai() { .orElse(CommonParameter.getInstance().getAllowTvmShangHai()); } - public void saveAllowCancelUnfreezeV2(long allowCancelUnfreezeV2) { - this.put(DynamicPropertiesStore.ALLOW_CANCEL_UNFREEZE_V2, - new BytesCapsule(ByteArray.fromLong(allowCancelUnfreezeV2))); + public void saveAllowCancelAllUnfreezeV2(long allowCancelAllUnfreezeV2) { + this.put(DynamicPropertiesStore.ALLOW_CANCEL_ALL_UNFREEZE_V2, + new BytesCapsule(ByteArray.fromLong(allowCancelAllUnfreezeV2))); } - public long getAllowCancelUnfreezeV2() { - return Optional.ofNullable(getUnchecked(ALLOW_CANCEL_UNFREEZE_V2)) + public long getAllowCancelAllUnfreezeV2() { + return Optional.ofNullable(getUnchecked(ALLOW_CANCEL_ALL_UNFREEZE_V2)) .map(BytesCapsule::getData) .map(ByteArray::toLong) - .orElse(CommonParameter.getInstance().getAllowCancelUnfreezeV2()); + .orElse(CommonParameter.getInstance().getAllowCancelAllUnfreezeV2()); } - public boolean supportAllowCancelUnfreezeV2() { - return getAllowCancelUnfreezeV2() == 1L && getUnfreezeDelayDays() > 0; + public boolean supportAllowCancelAllUnfreezeV2() { + return getAllowCancelAllUnfreezeV2() == 1L && getUnfreezeDelayDays() > 0; } - public void saveAllowOptimizeLockDelegateResource(long allowOptimizeLockDelegateResource) { - this.put(DynamicPropertiesStore.ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE, - new BytesCapsule(ByteArray.fromLong(allowOptimizeLockDelegateResource))); + public void saveMaxDelegateLockPeriod(long maxDelegateLockPeriod) { + this.put(DynamicPropertiesStore.MAX_DELEGATE_LOCK_PERIOD, + new BytesCapsule(ByteArray.fromLong(maxDelegateLockPeriod))); } - public long getAllowOptimizeLockDelegateResource() { - return Optional.ofNullable(getUnchecked(ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE)) + public long getMaxDelegateLockPeriod() { + return Optional.ofNullable(getUnchecked(MAX_DELEGATE_LOCK_PERIOD)) .map(BytesCapsule::getData) .map(ByteArray::toLong) - .orElse(CommonParameter.getInstance().getAllowOptimizeLockDelegateResource()); + .orElse(CommonParameter.getInstance().getMaxDelegateLockPeriod()); } - public boolean supportAllowOptimizeLockDelegateResource() { - return getAllowOptimizeLockDelegateResource() == 1L && getUnfreezeDelayDays() > 0; + public boolean supportMaxDelegateLockPeriod() { + return getMaxDelegateLockPeriod() > 0 && getUnfreezeDelayDays() > 0; } private static class DynamicResourceProperties { diff --git a/common/src/main/java/org/tron/common/parameter/CommonParameter.java b/common/src/main/java/org/tron/common/parameter/CommonParameter.java index c6917d0351a..01c07169c08 100644 --- a/common/src/main/java/org/tron/common/parameter/CommonParameter.java +++ b/common/src/main/java/org/tron/common/parameter/CommonParameter.java @@ -653,11 +653,11 @@ public class CommonParameter { @Getter @Setter - public long allowCancelUnfreezeV2; + public long allowCancelAllUnfreezeV2; @Getter @Setter - public long allowOptimizeLockDelegateResource; + public long maxDelegateLockPeriod; private static double calcMaxTimeRatio() { //return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1))); diff --git a/common/src/main/java/org/tron/core/config/Parameter.java b/common/src/main/java/org/tron/core/config/Parameter.java index 822a79896cc..5a170577b99 100644 --- a/common/src/main/java/org/tron/core/config/Parameter.java +++ b/common/src/main/java/org/tron/core/config/Parameter.java @@ -74,7 +74,6 @@ public class ChainConstant { public static final int BLOCK_VERSION = 28; public static final long FROZEN_PERIOD = 86_400_000L; public static final long DELEGATE_PERIOD = 3 * 86_400_000L; - public static final long MAX_BLOCK_NUM_DELEGATE_PERIOD = 10512000L; public static final long TRX_PRECISION = 1000_000L; public static final long DELEGATE_COST_BASE_SIZE = 275L; } diff --git a/framework/src/main/java/org/tron/core/Wallet.java b/framework/src/main/java/org/tron/core/Wallet.java index cf1bcb7f909..b866ab54001 100755 --- a/framework/src/main/java/org/tron/core/Wallet.java +++ b/framework/src/main/java/org/tron/core/Wallet.java @@ -1326,13 +1326,13 @@ public Protocol.ChainParameters getChainParameters() { .build()); builder.addChainParameter(Protocol.ChainParameters.ChainParameter.newBuilder() - .setKey("getAllowCancelUnfreezeV2") - .setValue(dbManager.getDynamicPropertiesStore().getAllowCancelUnfreezeV2()) + .setKey("getAllowCancelAllUnfreezeV2") + .setValue(dbManager.getDynamicPropertiesStore().getAllowCancelAllUnfreezeV2()) .build()); builder.addChainParameter(Protocol.ChainParameters.ChainParameter.newBuilder() - .setKey("getAllowOptimizeLockDelegateResource") - .setValue(dbManager.getDynamicPropertiesStore().getAllowOptimizeLockDelegateResource()) + .setKey("getMaxDelegateLockPeriod") + .setValue(dbManager.getDynamicPropertiesStore().getMaxDelegateLockPeriod()) .build()); return builder.build(); diff --git a/framework/src/main/java/org/tron/core/consensus/ProposalService.java b/framework/src/main/java/org/tron/core/consensus/ProposalService.java index 813c7a7931b..2cbf0c053d6 100644 --- a/framework/src/main/java/org/tron/core/consensus/ProposalService.java +++ b/framework/src/main/java/org/tron/core/consensus/ProposalService.java @@ -343,19 +343,16 @@ public static boolean process(Manager manager, ProposalCapsule proposalCapsule) manager.getDynamicPropertiesStore().saveAllowTvmShangHai(entry.getValue()); break; } - case ALLOW_CANCEL_UNFREEZE_V2: { - if (manager.getDynamicPropertiesStore().getAllowCancelUnfreezeV2() == 0) { - manager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(entry.getValue()); + case ALLOW_CANCEL_ALL_UNFREEZE_V2: { + if (manager.getDynamicPropertiesStore().getAllowCancelAllUnfreezeV2() == 0) { + manager.getDynamicPropertiesStore().saveAllowCancelAllUnfreezeV2(entry.getValue()); manager.getDynamicPropertiesStore().addSystemContractAndSetPermission( - ContractType.CancelUnfreezeV2Contract_VALUE); + ContractType.CancelAllUnfreezeV2Contract_VALUE); } break; } - case ALLOW_OPTIMIZE_LOCK_DELEGATE_RESOURCE: { - if (manager.getDynamicPropertiesStore().getAllowOptimizeLockDelegateResource() == 0) { - manager.getDynamicPropertiesStore() - .saveAllowOptimizeLockDelegateResource(entry.getValue()); - } + case MAX_DELEGATE_LOCK_PERIOD: { + manager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(entry.getValue()); break; } default: diff --git a/framework/src/main/java/org/tron/core/services/RpcApiService.java b/framework/src/main/java/org/tron/core/services/RpcApiService.java index e99ed96dd46..2a4ebca95b4 100755 --- a/framework/src/main/java/org/tron/core/services/RpcApiService.java +++ b/framework/src/main/java/org/tron/core/services/RpcApiService.java @@ -130,7 +130,7 @@ import org.tron.protos.contract.BalanceContract.AccountBalanceRequest; import org.tron.protos.contract.BalanceContract.AccountBalanceResponse; import org.tron.protos.contract.BalanceContract.BlockBalanceTrace; -import org.tron.protos.contract.BalanceContract.CancelUnfreezeV2Contract; +import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract; import org.tron.protos.contract.BalanceContract.DelegateResourceContract; import org.tron.protos.contract.BalanceContract.FreezeBalanceContract; import org.tron.protos.contract.BalanceContract.TransferContract; @@ -1473,9 +1473,9 @@ public void unDelegateResource(UnDelegateResourceContract request, } @Override - public void cancelUnfreezeV2(CancelUnfreezeV2Contract request, + public void cancelAllUnfreezeV2(CancelAllUnfreezeV2Contract request, StreamObserver responseObserver) { - createTransactionExtention(request, ContractType.CancelUnfreezeV2Contract, + createTransactionExtention(request, ContractType.CancelAllUnfreezeV2Contract, responseObserver); } diff --git a/framework/src/main/java/org/tron/core/services/http/CancelUnfreezeV2Servlet.java b/framework/src/main/java/org/tron/core/services/http/CancelAllUnfreezeV2Servlet.java similarity index 82% rename from framework/src/main/java/org/tron/core/services/http/CancelUnfreezeV2Servlet.java rename to framework/src/main/java/org/tron/core/services/http/CancelAllUnfreezeV2Servlet.java index 601379e5547..894126e50da 100644 --- a/framework/src/main/java/org/tron/core/services/http/CancelUnfreezeV2Servlet.java +++ b/framework/src/main/java/org/tron/core/services/http/CancelAllUnfreezeV2Servlet.java @@ -10,11 +10,11 @@ import org.tron.core.Wallet; import org.tron.protos.Protocol.Transaction; import org.tron.protos.Protocol.Transaction.Contract.ContractType; -import org.tron.protos.contract.BalanceContract.CancelUnfreezeV2Contract; +import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract; @Component @Slf4j(topic = "API") -public class CancelUnfreezeV2Servlet extends RateLimiterServlet { +public class CancelAllUnfreezeV2Servlet extends RateLimiterServlet { @Autowired private Wallet wallet; @@ -23,10 +23,10 @@ public class CancelUnfreezeV2Servlet extends RateLimiterServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) { try { PostParams params = PostParams.getPostParams(request); - CancelUnfreezeV2Contract.Builder build = CancelUnfreezeV2Contract.newBuilder(); + CancelAllUnfreezeV2Contract.Builder build = CancelAllUnfreezeV2Contract.newBuilder(); JsonFormat.merge(params.getParams(), build, params.isVisible()); Transaction tx = wallet - .createTransactionCapsule(build.build(), ContractType.CancelUnfreezeV2Contract) + .createTransactionCapsule(build.build(), ContractType.CancelAllUnfreezeV2Contract) .getInstance(); JSONObject jsonObject = JSON.parseObject(params.getParams()); tx = Util.setTransactionPermissionId(jsonObject, tx); diff --git a/framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java b/framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java index cac81174939..082307fe629 100644 --- a/framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java +++ b/framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java @@ -303,7 +303,7 @@ public class FullNodeHttpApiService implements Service { @Autowired private UnDelegateResourceServlet unDelegateResourceServlet; @Autowired - private CancelUnfreezeV2Servlet cancelUnfreezeV2Servlet; + private CancelAllUnfreezeV2Servlet cancelAllUnfreezeV2Servlet; private static String getParamsFile(String fileName) { InputStream in = Thread.currentThread().getContextClassLoader() @@ -566,8 +566,8 @@ public void start() { "/wallet/delegateresource"); context.addServlet(new ServletHolder(unDelegateResourceServlet), "/wallet/undelegateresource"); - context.addServlet(new ServletHolder(cancelUnfreezeV2Servlet), - "/wallet/cancelunfreezev2"); + context.addServlet(new ServletHolder(cancelAllUnfreezeV2Servlet), + "/wallet/cancelallunfreezev2"); int maxHttpConnectNumber = Args.getInstance().getMaxHttpConnectNumber(); if (maxHttpConnectNumber > 0) { diff --git a/framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java b/framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java index 5445a387278..c551259fb3e 100644 --- a/framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java +++ b/framework/src/main/java/org/tron/core/services/http/HttpSelfFormatFieldName.java @@ -144,8 +144,8 @@ public class HttpSelfFormatFieldName { //UnDelegateResourceContract AddressFieldNameMap.put("protocol.UnDelegateResourceContract.owner_address", 1); AddressFieldNameMap.put("protocol.UnDelegateResourceContract.receiver_address", 1); - //CancelUnfreezeV2Contract - AddressFieldNameMap.put("protocol.CancelUnfreezeV2Contract.owner_address", 1); + //CancelAllUnfreezeV2Contract + AddressFieldNameMap.put("protocol.CancelAllUnfreezeV2Contract.owner_address", 1); AddressFieldNameMap.put("protocol.CanDelegatedMaxSizeRequestMessage.owner_address", 1); AddressFieldNameMap.put("protocol.GetAvailableUnfreezeCountRequestMessage.owner_address", 1); AddressFieldNameMap.put("protocol.CanWithdrawUnfreezeAmountRequestMessage.owner_address", 1); diff --git a/framework/src/main/java/org/tron/core/services/jsonrpc/JsonRpcApiUtil.java b/framework/src/main/java/org/tron/core/services/jsonrpc/JsonRpcApiUtil.java index 7b71f354293..776c74266aa 100644 --- a/framework/src/main/java/org/tron/core/services/jsonrpc/JsonRpcApiUtil.java +++ b/framework/src/main/java/org/tron/core/services/jsonrpc/JsonRpcApiUtil.java @@ -216,6 +216,7 @@ public static long getTransactionAmount(Transaction.Contract contract, String ha case WithdrawBalanceContract: case WithdrawExpireUnfreezeContract: case UnfreezeBalanceV2Contract: + case CancelAllUnfreezeV2Contract: TransactionInfo transactionInfo = wallet .getTransactionInfoById(ByteString.copyFrom(ByteArray.fromHexString(hash))); amount = getAmountFromTransactionInfo(hash, contract.getType(), transactionInfo); @@ -292,6 +293,7 @@ public static long getTransactionAmount(Transaction.Contract contract, String ha case WithdrawBalanceContract: case WithdrawExpireUnfreezeContract: case UnfreezeBalanceV2Contract: + case CancelAllUnfreezeV2Contract: amount = getAmountFromTransactionInfo(hash, contract.getType(), transactionInfo); break; case UnfreezeAssetContract: @@ -334,8 +336,8 @@ public static long getAmountFromTransactionInfo(String hash, ContractType contra case WithdrawExpireUnfreezeContract: amount = transactionInfo.getWithdrawExpireAmount(); break; - case CancelUnfreezeV2Contract: - amount = transactionInfo.getCancelUnfreezeV2Amount(); + case CancelAllUnfreezeV2Contract: + amount = transactionInfo.getCancelAllUnfreezeV2Amount(); break; default: break; diff --git a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java index c2bf24ba383..8ff8167f52e 100644 --- a/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java +++ b/framework/src/test/java/org/tron/common/logsfilter/EventLoaderTest.java @@ -4,6 +4,8 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; +import org.tron.common.logsfilter.trigger.BlockLogTrigger; +import org.tron.common.logsfilter.trigger.TransactionLogTrigger; public class EventLoaderTest { @@ -24,8 +26,57 @@ public void launchNativeQueue() { config.setTriggerConfigList(triggerConfigList); - Assert.assertEquals(true, EventPluginLoader.getInstance().start(config)); + Assert.assertTrue(EventPluginLoader.getInstance().start(config)); EventPluginLoader.getInstance().stopPlugin(); } + + @Test + public void testBlockLogTrigger() { + BlockLogTrigger blt = new BlockLogTrigger(); + blt.setBlockHash(blt.getBlockHash()); + blt.setBlockNumber(blt.getBlockNumber()); + blt.setTransactionSize(blt.getTransactionSize()); + blt.setLatestSolidifiedBlockNumber(blt.getLatestSolidifiedBlockNumber()); + blt.setTriggerName(blt.getTriggerName()); + blt.setTimeStamp(blt.getTimeStamp()); + blt.setTransactionList(blt.getTransactionList()); + Assert.assertNotNull(blt.toString()); + } + + @Test + public void testTransactionLogTrigger() { + TransactionLogTrigger tlt = new TransactionLogTrigger(); + tlt.setBlockHash(tlt.getBlockHash()); + tlt.setBlockNumber(tlt.getBlockNumber()); + tlt.setTransactionId(tlt.getTransactionId()); + tlt.setLatestSolidifiedBlockNumber(tlt.getLatestSolidifiedBlockNumber()); + tlt.setTriggerName(tlt.getTriggerName()); + tlt.setTimeStamp(tlt.getTimeStamp()); + tlt.setEnergyFee(tlt.getEnergyFee()); + tlt.setNetFee(tlt.getNetFee()); + tlt.setEnergyUsage(tlt.getEnergyUsage()); + tlt.setAssetAmount(tlt.getAssetAmount()); + tlt.setContractAddress(tlt.getContractAddress()); + tlt.setResult(tlt.getResult()); + tlt.setContractResult(tlt.getContractResult()); + tlt.setContractType(tlt.getContractType()); + tlt.setContractCallValue(tlt.getContractCallValue()); + tlt.setFromAddress(tlt.getFromAddress()); + tlt.setToAddress(tlt.getToAddress()); + tlt.setTransactionIndex(tlt.getTransactionIndex()); + tlt.setFeeLimit(tlt.getFeeLimit()); + tlt.setCumulativeEnergyUsed(tlt.getCumulativeEnergyUsed()); + tlt.setData(tlt.getData()); + tlt.setOriginEnergyUsage(tlt.getOriginEnergyUsage()); + tlt.setEnergyUsageTotal(tlt.getEnergyUsageTotal()); + tlt.setNetUsage(tlt.getNetUsage()); + tlt.setAssetName(tlt.getAssetName()); + tlt.setInternalTransactionList(tlt.getInternalTransactionList()); + tlt.setPreCumulativeLogCount(tlt.getPreCumulativeLogCount()); + tlt.setLogList(tlt.getLogList()); + tlt.setEnergyUnitPrice(tlt.getEnergyUnitPrice()); + tlt.setTimeStamp(1L); + Assert.assertNotNull(tlt.toString()); + } } diff --git a/framework/src/test/java/org/tron/core/WalletTest.java b/framework/src/test/java/org/tron/core/WalletTest.java index b487a0f8421..97f024dddcb 100644 --- a/framework/src/test/java/org/tron/core/WalletTest.java +++ b/framework/src/test/java/org/tron/core/WalletTest.java @@ -791,8 +791,20 @@ public void testGetCanDelegatedMaxSizeBandWidth() { GrpcAPI.CanDelegatedMaxSizeResponseMessage message = wallet.getCanDelegatedMaxSize( ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), BANDWIDTH.getNumber()); - Assert.assertEquals(initBalance - 285L, message.getMaxSize()); + Assert.assertEquals(initBalance - 280L, message.getMaxSize()); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); + } + @Test + public void testGetCanDelegatedMaxSizeBandWidth2() { + chainBaseManager.getDynamicPropertiesStore().saveUnfreezeDelayDays(14); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(1); + freezeBandwidthForOwner(); + GrpcAPI.CanDelegatedMaxSizeResponseMessage message = wallet.getCanDelegatedMaxSize( + ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), + BANDWIDTH.getNumber()); + Assert.assertEquals(initBalance - 282L, message.getMaxSize()); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); } @Test diff --git a/framework/src/test/java/org/tron/core/actuator/CancelUnfreezeV2ActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/CancelAllUnfreezeV2ActuatorTest.java similarity index 51% rename from framework/src/test/java/org/tron/core/actuator/CancelUnfreezeV2ActuatorTest.java rename to framework/src/test/java/org/tron/core/actuator/CancelAllUnfreezeV2ActuatorTest.java index 9af9c42addf..5b417833c1d 100644 --- a/framework/src/test/java/org/tron/core/actuator/CancelUnfreezeV2ActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/CancelAllUnfreezeV2ActuatorTest.java @@ -7,7 +7,6 @@ import static org.tron.protos.contract.Common.ResourceCode.BANDWIDTH; import static org.tron.protos.contract.Common.ResourceCode.ENERGY; -import com.beust.jcommander.internal.Lists; import com.google.protobuf.Any; import com.google.protobuf.ByteString; import lombok.extern.slf4j.Slf4j; @@ -26,7 +25,7 @@ import org.tron.protos.contract.BalanceContract; @Slf4j -public class CancelUnfreezeV2ActuatorTest extends BaseTest { +public class CancelAllUnfreezeV2ActuatorTest extends BaseTest { private static final String OWNER_ADDRESS; private static final String RECEIVER_ADDRESS; @@ -46,7 +45,7 @@ public class CancelUnfreezeV2ActuatorTest extends BaseTest { @Before public void setUp() { dbManager.getDynamicPropertiesStore().saveUnfreezeDelayDays(1L); - dbManager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(1); + dbManager.getDynamicPropertiesStore().saveAllowCancelAllUnfreezeV2(1); AccountCapsule ownerCapsule = new AccountCapsule(ByteString.copyFromUtf8("owner"), ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS)), Protocol.AccountType.Normal, @@ -59,35 +58,6 @@ public void setUp() { dbManager.getAccountStore().put(receiverCapsule.getAddress().toByteArray(), receiverCapsule); } - @Test - public void testCancelUnfreezeV2() { - long now = System.currentTimeMillis(); - AccountCapsule accountCapsule = dbManager.getAccountStore() - .get(ByteArray.fromHexString(OWNER_ADDRESS)); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 1000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 2000000L, -1); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 3000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 4000000L, 100); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, 100); - dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); - actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2Contract()); - TransactionResultCapsule ret = new TransactionResultCapsule(); - try { - actuator.validate(); - actuator.execute(ret); - assertEquals(SUCESS, ret.getInstance().getRet()); - AccountCapsule owner = dbManager.getAccountStore() - .get(ByteArray.fromHexString(OWNER_ADDRESS)); - assertEquals(2000000L, ret.getInstance().getWithdrawExpireAmount()); - assertEquals(2, owner.getUnfrozenV2List().size()); - } catch (ContractValidateException | ContractExeException e) { - fail(); - } - } - @Test public void testCancelAllUnfreezeV2() { long now = System.currentTimeMillis(); @@ -100,7 +70,7 @@ public void testCancelAllUnfreezeV2() { accountCapsule.addUnfrozenV2List(BANDWIDTH, 4000000L, 100); accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, 100); dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) .setAny(getCancelAllUnfreezeV2Contract()); TransactionResultCapsule ret = new TransactionResultCapsule(); @@ -130,9 +100,9 @@ public void testNullTransactionResultCapsule() { accountCapsule.addUnfrozenV2List(BANDWIDTH, 4000000L, 100); accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, 100); dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2Contract()); + .setAny(getCancelAllUnfreezeV2Contract()); try { actuator.validate(); } catch (ContractValidateException e) { @@ -144,33 +114,33 @@ public void testNullTransactionResultCapsule() { @Test public void testInvalidOwnerAddress() { - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2ContractInvalidAddress()); + .setAny(getCancelAllUnfreezeV2ContractInvalidAddress()); assertThrows("Invalid address", ContractValidateException.class, actuator::validate); } @Test public void testInvalidOwnerAccount() { - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2ContractInvalidAccount()); + .setAny(getCancelAllUnfreezeV2ContractInvalidAccount()); assertThrows("Account[" + OWNER_ACCOUNT_INVALID + "] does not exist", ContractValidateException.class, actuator::validate); } @Test public void testInvalidOwnerUnfreezeV2List() { - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2Contract()); + .setAny(getCancelAllUnfreezeV2Contract()); assertThrows("no unfreezeV2 list to cancel", ContractValidateException.class, actuator::validate); } @Test - public void testInvalidCancelUnfreezeV2Contract() { - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + public void testInvalidCancelAllUnfreezeV2Contract() { + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny(null); assertThrows(ActuatorConstant.CONTRACT_NOT_EXIST, ContractValidateException.class, actuator::validate); @@ -178,100 +148,36 @@ public void testInvalidCancelUnfreezeV2Contract() { @Test public void testInvalidAccountStore() { - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); - actuator.setChainBaseManager(null).setAny(getCancelUnfreezeV2Contract()); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); + actuator.setChainBaseManager(null).setAny(getCancelAllUnfreezeV2Contract()); assertThrows(ActuatorConstant.STORE_NOT_EXIST, ContractValidateException.class, actuator::validate); } @Test - public void testSupportAllowCancelUnfreezeV2() { - dbManager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(0); - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + public void testSupportAllowCancelAllUnfreezeV2() { + dbManager.getDynamicPropertiesStore().saveAllowCancelAllUnfreezeV2(0); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getCancelUnfreezeV2Contract()); + .setAny(getCancelAllUnfreezeV2Contract()); assertThrows( - "Not support CancelUnfreezeV2 transaction, need to be opened by the committee", - ContractValidateException.class, actuator::validate); - } - - @Test - public void testWrongIndex() { - dbManager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(1); - long now = System.currentTimeMillis(); - AccountCapsule accountCapsule = dbManager.getAccountStore() - .get(ByteArray.fromHexString(OWNER_ADDRESS)); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 1000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 2000000L, -1); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 3000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 4000000L, 100); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, 100); - dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); - - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); - actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getWrongIndexCancelUnfreezeV2Contract()); - assertThrows("The input index[-1] cannot be less than 0 and cannot be greater than " - + "the maximum index[5] of unfreezeV2!", - ContractValidateException.class, actuator::validate); - } - - @Test - public void testWrongIndexSize() { - dbManager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(1); - long now = System.currentTimeMillis(); - AccountCapsule accountCapsule = dbManager.getAccountStore() - .get(ByteArray.fromHexString(OWNER_ADDRESS)); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 1000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 2000000L, -1); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 3000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, now + 14 * 24 * 3600 * 1000); - accountCapsule.addUnfrozenV2List(BANDWIDTH, 4000000L, 100); - accountCapsule.addUnfrozenV2List(ENERGY, 4000000L, 100); - dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule); - - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); - actuator.setChainBaseManager(dbManager.getChainBaseManager()) - .setAny(getWrongIndexSizeCancelUnfreezeV2Contract()); - assertThrows("The size of the index cannot exceed the size of unfrozenV2!", + "Not support CancelAllUnfreezeV2 transaction, need to be opened by the committee", ContractValidateException.class, actuator::validate); } @Test public void testErrorContract() { - dbManager.getDynamicPropertiesStore().saveAllowCancelUnfreezeV2(1); - CancelUnfreezeV2Actuator actuator = new CancelUnfreezeV2Actuator(); + dbManager.getDynamicPropertiesStore().saveAllowCancelAllUnfreezeV2(1); + CancelAllUnfreezeV2Actuator actuator = new CancelAllUnfreezeV2Actuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny(getErrorContract()); assertThrows( - "contract type error, expected type [CancelUnfreezeV2Contract], " + "contract type error, expected type [CancelAllUnfreezeV2Contract], " + "real type[WithdrawExpireUnfreezeContract]", ContractValidateException.class, actuator::validate); } - private Any getCancelUnfreezeV2Contract() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder() - .addAllIndex(Lists.newArrayList(0, 1, 2, 3)) - .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))).build() - ); - } - private Any getCancelAllUnfreezeV2Contract() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder() - .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))).build() - ); - } - - private Any getWrongIndexSizeCancelUnfreezeV2Contract() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder() - .addAllIndex(Lists.newArrayList(0, 1, 2, 1, 3, 2, 4)) - .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))).build() - ); - } - - private Any getWrongIndexCancelUnfreezeV2Contract() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder() - .addAllIndex(Lists.newArrayList(-1, 1, 2, 1, 3, 2)) + return Any.pack(BalanceContract.CancelAllUnfreezeV2Contract.newBuilder() .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))).build() ); } @@ -282,13 +188,13 @@ private Any getErrorContract() { ); } - private Any getCancelUnfreezeV2ContractInvalidAddress() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder().setOwnerAddress( + private Any getCancelAllUnfreezeV2ContractInvalidAddress() { + return Any.pack(BalanceContract.CancelAllUnfreezeV2Contract.newBuilder().setOwnerAddress( ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS_INVALID))).build()); } - private Any getCancelUnfreezeV2ContractInvalidAccount() { - return Any.pack(BalanceContract.CancelUnfreezeV2Contract.newBuilder().setOwnerAddress( + private Any getCancelAllUnfreezeV2ContractInvalidAccount() { + return Any.pack(BalanceContract.CancelAllUnfreezeV2Contract.newBuilder().setOwnerAddress( ByteString.copyFrom(ByteArray.fromHexString(OWNER_ACCOUNT_INVALID))).build() ); } diff --git a/framework/src/test/java/org/tron/core/actuator/DelegateResourceActuatorTest.java b/framework/src/test/java/org/tron/core/actuator/DelegateResourceActuatorTest.java index a232729d3de..c5ebd31dd08 100644 --- a/framework/src/test/java/org/tron/core/actuator/DelegateResourceActuatorTest.java +++ b/framework/src/test/java/org/tron/core/actuator/DelegateResourceActuatorTest.java @@ -120,7 +120,7 @@ private Any getLockedDelegateContractForBandwidth(String ownerAddress, String re .build()); } - private Any getOptimizeLockedDelegateContractForBandwidth(long unfreezeBalance, long lockPeriod) { + private Any getMaxDelegateLockPeriodContractForBandwidth(long unfreezeBalance, long lockPeriod) { return Any.pack(DelegateResourceContract.newBuilder() .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) .setReceiverAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))) @@ -131,7 +131,7 @@ private Any getOptimizeLockedDelegateContractForBandwidth(long unfreezeBalance, .build()); } - private Any getOptimizeLockedDelegateContractForEnergy(long unfreezeBalance, long lockPeriod) { + private Any getMaxDelegateLockPeriodContractForEnergy(long unfreezeBalance, long lockPeriod) { return Any.pack(DelegateResourceContract.newBuilder() .setOwnerAddress(ByteString.copyFrom(ByteArray.fromHexString(OWNER_ADDRESS))) .setReceiverAddress(ByteString.copyFrom(ByteArray.fromHexString(RECEIVER_ADDRESS))) @@ -434,26 +434,27 @@ public void testLockedDelegateResourceForBandwidth() { } @Test - public void testOptimizeLockedDelegateResourceForBandwidthWrongLockPeriod1() { - dbManager.getDynamicPropertiesStore().saveAllowOptimizeLockDelegateResource(1); + public void testMaxDelegateLockPeriodForBandwidthWrongLockPeriod1() { + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(1); freezeBandwidthForOwner(); long delegateBalance = 1_000_000_000L; DelegateResourceActuator actuator = new DelegateResourceActuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForBandwidth( + getMaxDelegateLockPeriodContractForBandwidth( delegateBalance, 370 * 24 * 3600)); assertThrows("The lock period of delegate resources cannot exceed 1 year!", ContractValidateException.class, actuator::validate); + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); } @Test - public void testOptimizeLockedDelegateResourceForBandwidthWrongLockPeriod2() { - dbManager.getDynamicPropertiesStore().saveAllowOptimizeLockDelegateResource(1); + public void testMaxDelegateLockPeriodForBandwidthWrongLockPeriod2() { + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(864000L); freezeBandwidthForOwner(); long delegateBalance = 1_000_000_000L; DelegateResourceActuator actuator = new DelegateResourceActuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForBandwidth( + getMaxDelegateLockPeriodContractForBandwidth( delegateBalance, 60)); TransactionResultCapsule ret = new TransactionResultCapsule(); @@ -467,22 +468,23 @@ public void testOptimizeLockedDelegateResourceForBandwidthWrongLockPeriod2() { DelegateResourceActuator actuator1 = new DelegateResourceActuator(); actuator1.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForBandwidth( + getMaxDelegateLockPeriodContractForBandwidth( delegateBalance, 30)); assertThrows("The lock period for bandwidth this time cannot be less than the remaining" + " time[60000s] of the last lock period for bandwidth!", ContractValidateException.class, actuator1::validate); + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); } @Test - public void testOptimizeLockedDelegateResourceForBandwidth() { - dbManager.getDynamicPropertiesStore().saveAllowOptimizeLockDelegateResource(1); + public void testMaxDelegateLockPeriodForBandwidth() { + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(864000L); dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(50_000L); freezeBandwidthForOwner(); long delegateBalance = 1_000_000_000L; DelegateResourceActuator actuator = new DelegateResourceActuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForBandwidth( + getMaxDelegateLockPeriodContractForBandwidth( delegateBalance, 60)); TransactionResultCapsule ret = new TransactionResultCapsule(); @@ -496,7 +498,7 @@ public void testOptimizeLockedDelegateResourceForBandwidth() { DelegateResourceActuator actuator1 = new DelegateResourceActuator(); actuator1.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForBandwidth( + getMaxDelegateLockPeriodContractForBandwidth( delegateBalance, 60)); TransactionResultCapsule ret1 = new TransactionResultCapsule(); @@ -517,14 +519,14 @@ public void testOptimizeLockedDelegateResourceForBandwidth() { } @Test - public void testOptimizeLockedDelegateResourceForEnergy() { - dbManager.getDynamicPropertiesStore().saveAllowOptimizeLockDelegateResource(1); + public void testMaxDelegateLockPeriodForEnergy() { + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(864000L); dbManager.getDynamicPropertiesStore().saveLatestBlockHeaderTimestamp(50_000L); freezeCpuForOwner(); long delegateBalance = 1_000_000_000L; DelegateResourceActuator actuator = new DelegateResourceActuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForEnergy( + getMaxDelegateLockPeriodContractForEnergy( delegateBalance, 60)); TransactionResultCapsule ret = new TransactionResultCapsule(); @@ -538,7 +540,7 @@ public void testOptimizeLockedDelegateResourceForEnergy() { DelegateResourceActuator actuator1 = new DelegateResourceActuator(); actuator1.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForEnergy( + getMaxDelegateLockPeriodContractForEnergy( delegateBalance, 60)); TransactionResultCapsule ret1 = new TransactionResultCapsule(); @@ -557,13 +559,13 @@ public void testOptimizeLockedDelegateResourceForEnergy() { } @Test - public void testOptimizeLockedDelegateResourceForEnergyWrongLockPeriod2() { - dbManager.getDynamicPropertiesStore().saveAllowOptimizeLockDelegateResource(1); + public void testMaxDelegateLockPeriodForEnergyWrongLockPeriod2() { + dbManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(864000L); freezeCpuForOwner(); long delegateBalance = 1_000_000_000L; DelegateResourceActuator actuator = new DelegateResourceActuator(); actuator.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForEnergy( + getMaxDelegateLockPeriodContractForEnergy( delegateBalance, 60)); TransactionResultCapsule ret = new TransactionResultCapsule(); @@ -577,7 +579,7 @@ public void testOptimizeLockedDelegateResourceForEnergyWrongLockPeriod2() { DelegateResourceActuator actuator1 = new DelegateResourceActuator(); actuator1.setChainBaseManager(dbManager.getChainBaseManager()).setAny( - getOptimizeLockedDelegateContractForEnergy( + getMaxDelegateLockPeriodContractForEnergy( delegateBalance, 30)); assertThrows("The lock period for energy this time cannot be less than the remaining" + " time[60000s] of the last lock period for energy!", @@ -776,6 +778,34 @@ public void commonErrorCheck() { actuatorTest.nullDBManger(); } + @Test + public void testSupportDelegateResource() { + dbManager.getDynamicPropertiesStore().saveAllowDelegateResource(0); + DelegateResourceActuator actuator = new DelegateResourceActuator(); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setAny(getDelegateContractForBandwidth( + OWNER_ADDRESS, + RECEIVER_ADDRESS, + 1_000_000_000L)); + assertThrows( + "No support for resource delegate", + ContractValidateException.class, actuator::validate); + } + + @Test + public void testSupportUnfreezeDelay() { + dbManager.getDynamicPropertiesStore().saveUnfreezeDelayDays(0); + DelegateResourceActuator actuator = new DelegateResourceActuator(); + actuator.setChainBaseManager(dbManager.getChainBaseManager()) + .setAny(getDelegateContractForBandwidth( + OWNER_ADDRESS, + RECEIVER_ADDRESS, + 1_000_000_000L)); + assertThrows( + "Not support Delegate resource transaction, need to be opened by the committee", + ContractValidateException.class, actuator::validate); + } + @Test public void testErrorContract() { DelegateResourceActuator actuator = new DelegateResourceActuator(); diff --git a/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java b/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java index 6bee877318a..6db02667746 100644 --- a/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java +++ b/framework/src/test/java/org/tron/core/actuator/utils/TransactionUtilTest.java @@ -148,7 +148,20 @@ public void testEstimateConsumeBandWidthSize() { dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); long estimateConsumeBandWidthSize = TransactionUtil.estimateConsumeBandWidthSize(ownerCapsule, dbManager.getChainBaseManager()); - assertEquals(278L, estimateConsumeBandWidthSize); + assertEquals(275L, estimateConsumeBandWidthSize); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); + } + + @Test + public void testEstimateConsumeBandWidthSize2() { + chainBaseManager.getDynamicPropertiesStore().saveUnfreezeDelayDays(14); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(864000L); + AccountCapsule ownerCapsule = + dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS)); + long estimateConsumeBandWidthSize = TransactionUtil.estimateConsumeBandWidthSize(ownerCapsule, + dbManager.getChainBaseManager()); + assertEquals(277L, estimateConsumeBandWidthSize); + chainBaseManager.getDynamicPropertiesStore().saveMaxDelegateLockPeriod(0); } } diff --git a/framework/src/test/java/org/tron/core/services/http/HttpServletTest.java b/framework/src/test/java/org/tron/core/services/http/HttpServletTest.java index 823a8f7ea1b..dfd4c569e3e 100644 --- a/framework/src/test/java/org/tron/core/services/http/HttpServletTest.java +++ b/framework/src/test/java/org/tron/core/services/http/HttpServletTest.java @@ -139,7 +139,7 @@ public class HttpServletTest { private VoteWitnessAccountServlet voteWitnessAccountServlet; private WithdrawBalanceServlet withdrawBalanceServlet; private WithdrawExpireUnfreezeServlet withdrawExpireUnfreezeServlet; - private CancelUnfreezeV2Servlet cancelUnfreezeV2Servlet; + private CancelAllUnfreezeV2Servlet cancelAllUnfreezeV2Servlet; private MockHttpServletRequest request; private MockHttpServletResponse response; @@ -276,7 +276,7 @@ public void setUp() { voteWitnessAccountServlet = new VoteWitnessAccountServlet(); withdrawBalanceServlet = new WithdrawBalanceServlet(); withdrawExpireUnfreezeServlet = new WithdrawExpireUnfreezeServlet(); - cancelUnfreezeV2Servlet = new CancelUnfreezeV2Servlet(); + cancelAllUnfreezeV2Servlet = new CancelAllUnfreezeV2Servlet(); request = new MockHttpServletRequest(); request.setCharacterEncoding("UTF-8"); response = new MockHttpServletResponse(); @@ -528,7 +528,7 @@ public void doPostTest() { voteWitnessAccountServlet.doPost(request, response); withdrawBalanceServlet.doPost(request, response); withdrawExpireUnfreezeServlet.doPost(request, response); - cancelUnfreezeV2Servlet.doPost(request, response); + cancelAllUnfreezeV2Servlet.doPost(request, response); } } diff --git a/protocol/src/main/protos/api/api.proto b/protocol/src/main/protos/api/api.proto index 1e37f425f50..d23d6e01729 100644 --- a/protocol/src/main/protos/api/api.proto +++ b/protocol/src/main/protos/api/api.proto @@ -281,7 +281,7 @@ service Wallet { rpc UnDelegateResource (UnDelegateResourceContract) returns (TransactionExtention) { } - rpc CancelUnfreezeV2 (CancelUnfreezeV2Contract) returns (TransactionExtention) { + rpc CancelAllUnfreezeV2 (CancelAllUnfreezeV2Contract) returns (TransactionExtention) { } //Please use UpdateAsset2 instead of this function. diff --git a/protocol/src/main/protos/core/Tron.proto b/protocol/src/main/protos/core/Tron.proto index 2ce19ba2708..f52c21162d6 100644 --- a/protocol/src/main/protos/core/Tron.proto +++ b/protocol/src/main/protos/core/Tron.proto @@ -374,7 +374,7 @@ message Transaction { WithdrawExpireUnfreezeContract = 56; DelegateResourceContract = 57; UnDelegateResourceContract = 58; - CancelUnfreezeV2Contract = 59; + CancelAllUnfreezeV2Contract = 59; } ContractType type = 1; google.protobuf.Any parameter = 2; @@ -423,7 +423,7 @@ message Transaction { bytes orderId = 25; repeated MarketOrderDetail orderDetails = 26; int64 withdraw_expire_amount = 27; - int64 cancel_unfreezeV2_amount = 28; + int64 cancel_all_unfreezeV2_amount = 28; } message raw { @@ -484,7 +484,7 @@ message TransactionInfo { int64 packingFee = 27; int64 withdraw_expire_amount = 28; - int64 cancel_unfreezeV2_amount = 29; + int64 cancel_all_unfreezeV2_amount = 29; } message TransactionRet { diff --git a/protocol/src/main/protos/core/contract/balance_contract.proto b/protocol/src/main/protos/core/contract/balance_contract.proto index 512b8fb81eb..ea1c96270d6 100644 --- a/protocol/src/main/protos/core/contract/balance_contract.proto +++ b/protocol/src/main/protos/core/contract/balance_contract.proto @@ -113,7 +113,6 @@ message UnDelegateResourceContract { bytes receiver_address = 4; } -message CancelUnfreezeV2Contract { +message CancelAllUnfreezeV2Contract { bytes owner_address = 1; - repeated int32 index = 2; } \ No newline at end of file