Skip to content

Commit a2492c0

Browse files
committed
Merge tag 'GreatVoyage-v4.1.2'
2 parents 2292796 + ada332f commit a2492c0

751 files changed

Lines changed: 41872 additions & 2022 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Tron protobuf protocol document.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI`
15371537
Function = 2;
15381538
Event = 3;
15391539
Fallback = 4;
1540+
Receive = 5;
15401541
}
15411542
```
15421543

@@ -1617,6 +1618,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI`
16171618
Function = 2;
16181619
Event = 3;
16191620
Fallback = 4;
1621+
Receive = 5;
16201622
}
16211623
message Param {
16221624
bool indexed = 1;

actuator/src/main/java/org/tron/core/actuator/AccountPermissionUpdateActuator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public boolean execute(Object object) throws ContractExeException {
5353
accountStore.put(ownerAddress, account);
5454

5555
Commons.adjustBalance(accountStore, ownerAddress, -fee);
56-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), fee);
56+
if (chainBaseManager.getDynamicPropertiesStore().supportBlackHoleOptimization()) {
57+
chainBaseManager.getDynamicPropertiesStore().burnTrx(fee);
58+
} else {
59+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
60+
}
5761

5862
result.setStatus(fee, code.SUCESS);
5963
} catch (BalanceInsufficientException | InvalidProtocolBufferException e) {

actuator/src/main/java/org/tron/core/actuator/AssetIssueActuator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ public boolean execute(Object result) throws ContractExeException {
8585
}
8686

8787
Commons.adjustBalance(accountStore, ownerAddress, -fee);
88-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().getAddress().toByteArray(),
89-
fee);//send to blackhole
90-
88+
if (dynamicStore.supportBlackHoleOptimization()) {
89+
dynamicStore.burnTrx(fee);
90+
} else {
91+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);//send to blackhole
92+
}
9193
AccountCapsule accountCapsule = accountStore.get(ownerAddress);
9294
List<FrozenSupply> frozenSupplyList = assetIssueContract.getFrozenSupplyList();
9395
Iterator<FrozenSupply> iterator = frozenSupplyList.iterator();

actuator/src/main/java/org/tron/core/actuator/ClearABIContractActuator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.tron.protos.Protocol.Transaction.Result.code;
2020
import org.tron.protos.contract.SmartContractOuterClass.ClearABIContract;
2121

22+
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
23+
2224
@Slf4j(topic = "actuator")
2325
public class ClearABIContractActuator extends AbstractActuator {
2426

@@ -90,7 +92,7 @@ public boolean validate() throws ContractValidateException {
9092
if (accountCapsule == null) {
9193
throw new ContractValidateException(
9294
ActuatorConstant.ACCOUNT_EXCEPTION_STR
93-
+ readableOwnerAddress + "] not exists");
95+
+ readableOwnerAddress + NOT_EXIST_STR);
9496
}
9597

9698
byte[] contractAddress = contract.getContractAddress().toByteArray();

actuator/src/main/java/org/tron/core/actuator/CreateAccountActuator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.tron.core.actuator;
22

3+
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
4+
35
import com.google.protobuf.ByteString;
46
import com.google.protobuf.InvalidProtocolBufferException;
57
import java.util.Objects;
@@ -49,8 +51,11 @@ public boolean execute(Object result)
4951
Commons
5052
.adjustBalance(accountStore, accountCreateContract.getOwnerAddress().toByteArray(), -fee);
5153
// Add to blackhole address
52-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), fee);
53-
54+
if (dynamicStore.supportBlackHoleOptimization()) {
55+
dynamicStore.burnTrx(fee);
56+
} else {
57+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
58+
}
5459
ret.setStatus(fee, code.SUCESS);
5560
} catch (BalanceInsufficientException | InvalidProtocolBufferException e) {
5661
logger.debug(e.getMessage(), e);
@@ -95,7 +100,7 @@ public boolean validate() throws ContractValidateException {
95100
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
96101
throw new ContractValidateException(
97102
ActuatorConstant.ACCOUNT_EXCEPTION_STR
98-
+ readableOwnerAddress + "] not exists");
103+
+ readableOwnerAddress + NOT_EXIST_STR);
99104
}
100105

101106
final long fee = calcFee();

actuator/src/main/java/org/tron/core/actuator/ExchangeCreateActuator.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.core.actuator;
22

3+
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
34
import static org.tron.core.capsule.utils.TransactionUtil.isNumber;
45
import static org.tron.core.config.Parameter.ChainSymbol.TRX_SYMBOL_BYTES;
56

@@ -22,7 +23,6 @@
2223
import org.tron.core.store.DynamicPropertiesStore;
2324
import org.tron.core.store.ExchangeStore;
2425
import org.tron.core.store.ExchangeV2Store;
25-
import org.tron.core.utils.TransactionUtil;
2626
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
2727
import org.tron.protos.Protocol.Transaction.Result.code;
2828
import org.tron.protos.contract.ExchangeContract.ExchangeCreateContract;
@@ -118,9 +118,11 @@ public boolean execute(Object object) throws ContractExeException {
118118

119119
accountStore.put(accountCapsule.createDbKey(), accountCapsule);
120120
dynamicStore.saveLatestExchangeNum(id);
121-
122-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), fee);
123-
121+
if (dynamicStore.supportBlackHoleOptimization()) {
122+
dynamicStore.burnTrx(fee);
123+
} else {
124+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
125+
}
124126
ret.setExchangeId(id);
125127
ret.setStatus(fee, code.SUCESS);
126128
} catch (BalanceInsufficientException | InvalidProtocolBufferException e) {
@@ -161,7 +163,7 @@ public boolean validate() throws ContractValidateException {
161163
}
162164

163165
if (!accountStore.has(ownerAddress)) {
164-
throw new ContractValidateException("account[" + readableOwnerAddress + "] not exists");
166+
throw new ContractValidateException("account[" + readableOwnerAddress + NOT_EXIST_STR);
165167
}
166168

167169
AccountCapsule accountCapsule = accountStore.get(ownerAddress);

actuator/src/main/java/org/tron/core/actuator/ExchangeTransactionActuator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.core.actuator;
22

3+
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
34
import static org.tron.core.capsule.utils.TransactionUtil.isNumber;
45
import static org.tron.core.config.Parameter.ChainSymbol.TRX_SYMBOL_BYTES;
56

@@ -137,7 +138,7 @@ public boolean validate() throws ContractValidateException {
137138
}
138139

139140
if (!accountStore.has(ownerAddress)) {
140-
throw new ContractValidateException("account[" + readableOwnerAddress + "] not exists");
141+
throw new ContractValidateException("account[" + readableOwnerAddress + NOT_EXIST_STR);
141142
}
142143

143144
AccountCapsule accountCapsule = accountStore.get(ownerAddress);

actuator/src/main/java/org/tron/core/actuator/FreezeBalanceActuator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.core.actuator;
22

3+
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
34
import static org.tron.core.config.Parameter.ChainConstant.FROZEN_PERIOD;
45
import static org.tron.core.config.Parameter.ChainConstant.TRX_PRECISION;
56

@@ -142,7 +143,7 @@ public boolean validate() throws ContractValidateException {
142143
if (accountCapsule == null) {
143144
String readableOwnerAddress = StringUtil.createReadableString(ownerAddress);
144145
throw new ContractValidateException(
145-
ActuatorConstant.ACCOUNT_EXCEPTION_STR + readableOwnerAddress + "] not exists");
146+
ActuatorConstant.ACCOUNT_EXCEPTION_STR + readableOwnerAddress + NOT_EXIST_STR);
146147
}
147148

148149
long frozenBalance = freezeBalanceContract.getFrozenBalance();
@@ -207,7 +208,7 @@ public boolean validate() throws ContractValidateException {
207208
String readableOwnerAddress = StringUtil.createReadableString(receiverAddress);
208209
throw new ContractValidateException(
209210
ActuatorConstant.ACCOUNT_EXCEPTION_STR
210-
+ readableOwnerAddress + "] not exists");
211+
+ readableOwnerAddress + NOT_EXIST_STR);
211212
}
212213

213214
if (dynamicStore.getAllowTvmConstantinople() == 1

actuator/src/main/java/org/tron/core/actuator/MarketCancelOrderActuator.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
package org.tron.core.actuator;
1717

18+
import static org.tron.core.actuator.ActuatorConstant.CONTRACT_NOT_EXIST;
19+
import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST;
20+
import static org.tron.core.actuator.ActuatorConstant.TX_RESULT_NULL;
21+
1822
import com.google.protobuf.ByteString;
1923
import com.google.protobuf.InvalidProtocolBufferException;
2024
import java.util.Objects;
@@ -77,7 +81,7 @@ public boolean execute(Object object) throws ContractExeException {
7781

7882
TransactionResultCapsule ret = (TransactionResultCapsule) object;
7983
if (Objects.isNull(ret)) {
80-
throw new RuntimeException("TransactionResultCapsule is null");
84+
throw new RuntimeException(TX_RESULT_NULL);
8185
}
8286
long fee = calcFee();
8387

@@ -93,10 +97,14 @@ public boolean execute(Object object) throws ContractExeException {
9397

9498
// fee
9599
accountCapsule.setBalance(accountCapsule.getBalance() - fee);
96-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), fee);
97-
100+
if (dynamicStore.supportBlackHoleOptimization()) {
101+
dynamicStore.burnTrx(fee);
102+
} else {
103+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
104+
}
98105
// 1. return balance and token
99-
MarketUtils.returnSellTokenRemain(orderCapsule, accountCapsule, dynamicStore, assetIssueStore);
106+
MarketUtils
107+
.returnSellTokenRemain(orderCapsule, accountCapsule, dynamicStore, assetIssueStore);
100108

101109
MarketUtils.updateOrderState(orderCapsule, State.CANCELED, marketAccountStore);
102110
accountStore.put(orderCapsule.getOwnerAddress().toByteArray(), accountCapsule);
@@ -145,10 +153,10 @@ public boolean execute(Object object) throws ContractExeException {
145153
@Override
146154
public boolean validate() throws ContractValidateException {
147155
if (this.any == null) {
148-
throw new ContractValidateException("No contract!");
156+
throw new ContractValidateException(CONTRACT_NOT_EXIST);
149157
}
150158
if (chainBaseManager == null) {
151-
throw new ContractValidateException("No account store or dynamic store!");
159+
throw new ContractValidateException(STORE_NOT_EXIST);
152160
}
153161

154162
initStores();

actuator/src/main/java/org/tron/core/actuator/MarketSellAssetActuator.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
package org.tron.core.actuator;
1717

18+
import static org.tron.core.actuator.ActuatorConstant.CONTRACT_NOT_EXIST;
19+
import static org.tron.core.actuator.ActuatorConstant.STORE_NOT_EXIST;
20+
import static org.tron.core.actuator.ActuatorConstant.TX_RESULT_NULL;
1821
import static org.tron.core.capsule.utils.TransactionUtil.isNumber;
1922

2023
import com.google.protobuf.ByteString;
@@ -46,7 +49,6 @@
4649
import org.tron.core.store.MarketOrderStore;
4750
import org.tron.core.store.MarketPairPriceToOrderStore;
4851
import org.tron.core.store.MarketPairToPriceStore;
49-
import org.tron.core.utils.TransactionUtil;
5052
import org.tron.protos.Protocol.MarketOrder.State;
5153
import org.tron.protos.Protocol.MarketOrderDetail;
5254
import org.tron.protos.Protocol.MarketPrice;
@@ -101,7 +103,7 @@ public boolean execute(Object object) throws ContractExeException {
101103

102104
TransactionResultCapsule ret = (TransactionResultCapsule) object;
103105
if (Objects.isNull(ret)) {
104-
throw new RuntimeException("TransactionResultCapsule is null");
106+
throw new RuntimeException(TX_RESULT_NULL);
105107
}
106108

107109
long fee = calcFee();
@@ -124,8 +126,11 @@ public boolean execute(Object object) throws ContractExeException {
124126
// fee
125127
accountCapsule.setBalance(accountCapsule.getBalance() - fee);
126128
// add to blackhole address
127-
Commons.adjustBalance(accountStore, accountStore.getBlackhole().createDbKey(), fee);
128-
129+
if (dynamicStore.supportBlackHoleOptimization()) {
130+
dynamicStore.burnTrx(fee);
131+
} else {
132+
Commons.adjustBalance(accountStore, accountStore.getBlackhole(), fee);
133+
}
129134
// 1. transfer of balance
130135
transferBalanceOrToken(accountCapsule);
131136

@@ -160,10 +165,10 @@ public boolean execute(Object object) throws ContractExeException {
160165
@Override
161166
public boolean validate() throws ContractValidateException {
162167
if (this.any == null) {
163-
throw new ContractValidateException("No contract!");
168+
throw new ContractValidateException(CONTRACT_NOT_EXIST);
164169
}
165170
if (chainBaseManager == null) {
166-
throw new ContractValidateException("No account store or dynamic store!");
171+
throw new ContractValidateException(STORE_NOT_EXIST);
167172
}
168173

169174
initStores();
@@ -288,7 +293,7 @@ public long calcFee() {
288293

289294
/**
290295
* return marketPrice if matched, otherwise null
291-
* */
296+
*/
292297
private MarketPrice hasMatch(List<byte[]> priceKeysList, MarketPrice takerPrice) {
293298
if (priceKeysList.isEmpty()) {
294299
return null;
@@ -310,7 +315,6 @@ private void matchOrder(MarketOrderCapsule takerCapsule, MarketPrice takerPrice,
310315

311316
// makerPair not exists
312317
long makerPriceNumber = pairToPriceStore.getPriceNum(makerPair);
313-
314318
if (makerPriceNumber == 0) {
315319
return;
316320
}
@@ -319,7 +323,7 @@ private void matchOrder(MarketOrderCapsule takerCapsule, MarketPrice takerPrice,
319323
// get maker price list
320324
List<byte[]> priceKeysList = pairPriceToOrderStore
321325
.getPriceKeysList(MarketUtils.getPairPriceHeadKey(makerSellTokenID, makerBuyTokenID),
322-
(long)(MAX_MATCH_NUM + 1), makerPriceNumber, true);
326+
(long) (MAX_MATCH_NUM + 1), makerPriceNumber, true);
323327

324328
int matchOrderCount = 0;
325329
// match different price

0 commit comments

Comments
 (0)