Skip to content

Commit e5e347d

Browse files
authored
Merge pull request #5147 from forfreeday/release_v4.7.1.1
feat(merge)release v4.7.1.1
2 parents da2673c + ff5fb5c commit e5e347d

29 files changed

+83
-1433
lines changed

actuator/src/main/java/org/tron/core/utils/TransactionUtil.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.tron.protos.Protocol.Transaction;
5050
import org.tron.protos.Protocol.Transaction.Contract;
5151
import org.tron.protos.Protocol.Transaction.Result.contractResult;
52-
import org.tron.protos.Protocol.TransactionSign;
5352
import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract;
5453
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;
5554
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
@@ -184,21 +183,6 @@ public static String makeUpperCamelMethod(String originName) {
184183
.replace("_", "");
185184
}
186185

187-
public static TransactionCapsule getTransactionSign(TransactionSign transactionSign) {
188-
byte[] privateKey = transactionSign.getPrivateKey().toByteArray();
189-
TransactionCapsule trx = new TransactionCapsule(transactionSign.getTransaction());
190-
trx.sign(privateKey);
191-
return trx;
192-
}
193-
194-
public TransactionCapsule addSign(TransactionSign transactionSign)
195-
throws PermissionException, SignatureException, SignatureFormatException {
196-
byte[] privateKey = transactionSign.getPrivateKey().toByteArray();
197-
TransactionCapsule trx = new TransactionCapsule(transactionSign.getTransaction());
198-
trx.addSign(privateKey, chainBaseManager.getAccountStore());
199-
return trx;
200-
}
201-
202186
public TransactionSignWeight getTransactionSignWeight(Transaction trx) {
203187
TransactionSignWeight.Builder tswBuilder = TransactionSignWeight.newBuilder();
204188
TransactionExtention.Builder trxExBuilder = TransactionExtention.newBuilder();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ public void payEnergyBill(DynamicPropertiesStore dynamicPropertiesStore,
192192
AccountCapsule caller,
193193
long percent, long originEnergyLimit, EnergyProcessor energyProcessor, long now)
194194
throws BalanceInsufficientException {
195+
196+
// Reset origin energy usage here! Because after stake 2.0, this field are reused for
197+
// recording pre-merge frozen energy for origin account. If total energy usage is zero, this
198+
// field will be a dirty record.
199+
this.setOriginEnergyUsage(0);
200+
195201
if (receipt.getEnergyUsageTotal() <= 0) {
196202
return;
197203
}

chainbase/src/main/java/org/tron/core/db/TransactionTrace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void pay() throws BalanceInsufficientException {
255255
AccountCapsule origin = accountStore.get(originAccount);
256256
AccountCapsule caller = accountStore.get(callerAccount);
257257
if (dynamicPropertiesStore.supportUnfreezeDelay()
258-
&& receipt.getReceipt().getResult().equals(contractResult.SUCCESS)) {
258+
&& getRuntimeResult().getException() == null && !getRuntimeResult().isRevert()) {
259259

260260
// just fo caller is not origin, we set the related field for origin account
261261
if (origin != null && !caller.getAddress().equals(origin.getAddress())) {

chainbase/src/main/java/org/tron/core/store/TransactionRetStore.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.tron.core.db.TransactionStore;
1515
import org.tron.core.db.TronStoreWithRevoking;
1616
import org.tron.core.exception.BadItemException;
17+
import org.tron.protos.Protocol;
1718
import org.tron.protos.Protocol.TransactionInfo;
1819

1920
@Slf4j(topic = "DB")
@@ -54,6 +55,17 @@ public TransactionInfoCapsule getTransactionInfo(byte[] key) throws BadItemExcep
5455
ByteString id = ByteString.copyFrom(key);
5556
for (TransactionInfo transactionResultInfo : result.getInstance().getTransactioninfoList()) {
5657
if (transactionResultInfo.getId().equals(id)) {
58+
Protocol.ResourceReceipt receipt = transactionResultInfo.getReceipt();
59+
// If query a result with dirty origin usage in receipt, we just reset it.
60+
if (receipt.getEnergyUsageTotal() == 0 && receipt.getOriginEnergyUsage() > 0) {
61+
transactionResultInfo =
62+
transactionResultInfo.toBuilder()
63+
.setReceipt(
64+
receipt.toBuilder()
65+
.clearOriginEnergyUsage()
66+
.build())
67+
.build();
68+
}
5769
return new TransactionInfoCapsule(transactionResultInfo);
5870
}
5971
}

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -648,18 +648,6 @@ public TransactionApprovedList getTransactionApprovedList(Transaction trx) {
648648
return tswBuilder.build();
649649
}
650650

651-
public byte[] pass2Key(byte[] passPhrase) {
652-
return Sha256Hash.hash(CommonParameter
653-
.getInstance().isECKeyCryptoEngine(), passPhrase);
654-
}
655-
656-
public byte[] createAddress(byte[] passPhrase) {
657-
byte[] privateKey = pass2Key(passPhrase);
658-
SignInterface ecKey = SignUtils.fromPrivate(privateKey,
659-
Args.getInstance().isECKeyCryptoEngine());
660-
return ecKey.getAddress();
661-
}
662-
663651
public Block getNowBlock() {
664652
List<BlockCapsule> blockList = chainBaseManager.getBlockStore().getBlockByLatestNum(1);
665653
if (CollectionUtils.isEmpty(blockList)) {
@@ -765,19 +753,26 @@ public DelegatedResourceList getDelegatedResourceV2(
765753
.createDbKeyV2(fromAddress.toByteArray(), toAddress.toByteArray(), false);
766754
DelegatedResourceCapsule unlockResource = chainBaseManager.getDelegatedResourceStore()
767755
.get(dbKey);
768-
if (unlockResource != null) {
756+
if (nonEmptyResource(unlockResource)) {
769757
builder.addDelegatedResource(unlockResource.getInstance());
770758
}
771759
dbKey = DelegatedResourceCapsule
772760
.createDbKeyV2(fromAddress.toByteArray(), toAddress.toByteArray(), true);
773761
DelegatedResourceCapsule lockResource = chainBaseManager.getDelegatedResourceStore()
774762
.get(dbKey);
775-
if (lockResource != null) {
763+
if (nonEmptyResource(lockResource)) {
776764
builder.addDelegatedResource(lockResource.getInstance());
777765
}
778766
return builder.build();
779767
}
780768

769+
private boolean nonEmptyResource(DelegatedResourceCapsule resource) {
770+
return Objects.nonNull(resource) && !(resource.getExpireTimeForBandwidth() == 0
771+
&& resource.getExpireTimeForEnergy() == 0
772+
&& resource.getFrozenBalanceForBandwidth() == 0
773+
&& resource.getFrozenBalanceForEnergy() == 0);
774+
}
775+
781776
public GrpcAPI.CanWithdrawUnfreezeAmountResponseMessage getCanWithdrawUnfreezeAmount(
782777
ByteString ownerAddress, long timestamp) {
783778
GrpcAPI.CanWithdrawUnfreezeAmountResponseMessage.Builder builder =

0 commit comments

Comments
 (0)