Skip to content

Commit aff237e

Browse files
authored
Merge pull request #3858 from tronprotocol/release_4.3
merge Release 4.3 to master
2 parents 34c3b56 + 1f9ca45 commit aff237e

File tree

359 files changed

+22329
-1320
lines changed

Some content is hidden

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

359 files changed

+22329
-1320
lines changed

actuator/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ jacocoTestReport {
7272
xml.enabled = true
7373
html.enabled = true
7474
}
75-
executionData = files('../framework/build/jacoco/jacocoTest.exec')
75+
executionData.from = '../framework/build/jacoco/jacocoTest.exec'
7676
afterEvaluate {
77-
classDirectories = files(classDirectories.files.collect {
77+
classDirectories.from = classDirectories.files.collect {
7878
fileTree(dir: it,)
79-
})
79+
}
8080
}
8181
}
8282

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
import lombok.extern.slf4j.Slf4j;
88
import org.tron.common.utils.DecodeUtil;
99
import org.tron.common.utils.StringUtil;
10+
import org.tron.core.capsule.AbiCapsule;
1011
import org.tron.core.capsule.AccountCapsule;
1112
import org.tron.core.capsule.ContractCapsule;
1213
import org.tron.core.capsule.TransactionResultCapsule;
1314
import org.tron.core.exception.ContractExeException;
1415
import org.tron.core.exception.ContractValidateException;
16+
import org.tron.core.store.AbiStore;
1517
import org.tron.core.store.AccountStore;
1618
import org.tron.core.store.ContractStore;
1719
import org.tron.core.vm.config.VMConfig;
1820
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
1921
import org.tron.protos.Protocol.Transaction.Result.code;
22+
import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI;
2023
import org.tron.protos.contract.SmartContractOuterClass.ClearABIContract;
2124

2225
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
@@ -36,15 +39,12 @@ public boolean execute(Object result) throws ContractExeException {
3639
}
3740

3841
long fee = calcFee();
39-
ContractStore contractStore = chainBaseManager.getContractStore();
42+
AbiStore abiStore = chainBaseManager.getAbiStore();
4043
try {
4144
ClearABIContract usContract = any.unpack(ClearABIContract.class);
4245

4346
byte[] contractAddress = usContract.getContractAddress().toByteArray();
44-
ContractCapsule deployedContract = contractStore.get(contractAddress);
45-
46-
deployedContract.clearABI();
47-
contractStore.put(contractAddress, deployedContract);
47+
abiStore.put(contractAddress, new AbiCapsule(ABI.getDefaultInstance()));
4848

4949
ret.setStatus(fee, code.SUCESS);
5050
} catch (InvalidProtocolBufferException e) {

actuator/src/main/java/org/tron/core/vm/LogInfoTriggerParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.tron.common.utils.StringUtil;
1414
import org.tron.core.capsule.ContractCapsule;
1515
import org.tron.core.db.TransactionTrace;
16+
import org.tron.core.store.StoreFactory;
1617
import org.tron.core.vm.repository.Repository;
1718
import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI;
1819

@@ -74,7 +75,8 @@ public List<ContractTrigger> parseLogInfos(List<LogInfo> logInfos, Repository de
7475
abiMap.put(strContractAddr, ABI.getDefaultInstance());
7576
continue;
7677
}
77-
ABI abi = contract.getInstance().getAbi();
78+
ABI abi = StoreFactory.getInstance().getChainBaseManager()
79+
.getAbiStore().get(contractAddress).getInstance();
7880
String creatorAddr = StringUtil.encode58Check(
7981
TransactionTrace
8082
.convertToTronAddress(contract.getInstance().getOriginAddress().toByteArray()));

actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public static class BatchValidateSign extends PrecompiledContract {
834834
private static final int MAX_SIZE = 16;
835835

836836
static {
837-
workers = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() / 2);
837+
workers = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() / 2 + 1);
838838
}
839839

840840
@Override

actuator/src/main/java/org/tron/core/vm/VM.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ public void step(Program program) {
9999
|| (!VMConfig.allowTvmConstantinople()
100100
&& (op == SHL || op == SHR || op == SAR || op == CREATE2 || op == EXTCODEHASH))
101101
|| (!VMConfig.allowTvmSolidity059() && op == ISCONTRACT)
102-
|| (!VMConfig.allowTvmIstanbul() && (op == SELFBALANCE || op == CHAINID)
103-
|| (!VMConfig.allowTvmFreeze() && (op == FREEZE || op == UNFREEZE || op == FREEZEEXPIRETIME)))
102+
|| (!VMConfig.allowTvmIstanbul() && (op == SELFBALANCE || op == CHAINID))
103+
|| (!VMConfig.allowTvmFreeze()
104+
&& (op == FREEZE || op == UNFREEZE || op == FREEZEEXPIRETIME))
104105
) {
105106
throw Program.Exception.invalidOpCode(program.getCurrentOp());
106107
}

actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class RepositoryImpl implements Repository {
6363
@Getter
6464
private AssetIssueV2Store assetIssueV2Store;
6565
@Getter
66+
private AbiStore abiStore;
67+
@Getter
6668
private CodeStore codeStore;
6769
@Getter
6870
private ContractStore contractStore;
@@ -112,6 +114,7 @@ protected void init(StoreFactory storeFactory, RepositoryImpl parent) {
112114
ChainBaseManager manager = storeFactory.getChainBaseManager();
113115
dynamicPropertiesStore = manager.getDynamicPropertiesStore();
114116
accountStore = manager.getAccountStore();
117+
abiStore = manager.getAbiStore();
115118
codeStore = manager.getCodeStore();
116119
contractStore = manager.getContractStore();
117120
assetIssueStore = manager.getAssetIssueStore();
@@ -784,7 +787,11 @@ private void commitContractCache(Repository deposit) {
784787
if (deposit != null) {
785788
deposit.putContract(key, value);
786789
} else {
787-
getContractStore().put(key.getData(), value.getContract());
790+
ContractCapsule contractCapsule = value.getContract();
791+
if (!abiStore.has(key.getData())) {
792+
abiStore.put(key.getData(), new AbiCapsule(contractCapsule));
793+
}
794+
getContractStore().put(key.getData(), contractCapsule);
788795
}
789796
}
790797
}));
@@ -945,4 +952,5 @@ public long getTotalEnergyWeight() {
945952
.orElseThrow(
946953
() -> new IllegalArgumentException("not found TOTAL_ENERGY_WEIGHT"));
947954
}
955+
948956
}

chainbase/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ jacocoTestReport {
102102
xml.enabled = true
103103
html.enabled = true
104104
}
105-
executionData = files('../framework/build/jacoco/jacocoTest.exec')
105+
executionData.from = '../framework/build/jacoco/jacocoTest.exec'
106106
afterEvaluate {
107-
classDirectories = files(classDirectories.files.collect {
107+
classDirectories.from = classDirectories.files.collect {
108108
fileTree(dir: it,)
109-
})
109+
}
110110
}
111111
}
112112

chainbase/src/main/java/org/tron/core/ChainBaseManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.tron.core.exception.HeaderNotFound;
3131
import org.tron.core.exception.ItemNotFoundException;
3232
import org.tron.core.service.MortgageService;
33+
import org.tron.core.store.AbiStore;
3334
import org.tron.core.store.AccountIdIndexStore;
3435
import org.tron.core.store.AccountIndexStore;
3536
import org.tron.core.store.AccountStore;
@@ -122,6 +123,9 @@ public class ChainBaseManager {
122123
private MarketPairToPriceStore marketPairToPriceStore;
123124
@Autowired
124125
@Getter
126+
private AbiStore abiStore;
127+
@Autowired
128+
@Getter
125129
private CodeStore codeStore;
126130
@Autowired
127131
@Getter
@@ -231,6 +235,7 @@ public void closeAllStore() {
231235
closeOneStore(witnessScheduleStore);
232236
closeOneStore(assetIssueStore);
233237
closeOneStore(dynamicPropertiesStore);
238+
closeOneStore(abiStore);
234239
closeOneStore(codeStore);
235240
closeOneStore(contractStore);
236241
closeOneStore(storageRowStore);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.tron.core.capsule;
2+
3+
import com.google.protobuf.InvalidProtocolBufferException;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.tron.protos.contract.SmartContractOuterClass.SmartContract.ABI;
6+
7+
8+
@Slf4j(topic = "capsule")
9+
public class AbiCapsule implements ProtoCapsule<ABI> {
10+
11+
private ABI abi;
12+
13+
public AbiCapsule(byte[] data) {
14+
try {
15+
this.abi = ABI.parseFrom(data);
16+
} catch (InvalidProtocolBufferException e) {
17+
logger.debug(e.getMessage());
18+
}
19+
}
20+
21+
public AbiCapsule(ContractCapsule contract) {
22+
this.abi = contract.getInstance().getAbi().toBuilder().build();
23+
}
24+
25+
public AbiCapsule(ABI abi) {
26+
this.abi = abi.toBuilder().build();
27+
}
28+
29+
@Override
30+
public byte[] getData() {
31+
return this.abi.toByteArray();
32+
}
33+
34+
@Override
35+
public ABI getInstance() {
36+
return this.abi;
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return this.abi.toString();
42+
}
43+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public class TransactionTrace {
5454

5555
private CodeStore codeStore;
5656

57+
private AbiStore abiStore;
58+
5759
private EnergyProcessor energyProcessor;
5860

5961
private TrxType trxType;
@@ -92,6 +94,7 @@ public TransactionTrace(TransactionCapsule trx, StoreFactory storeFactory,
9294
this.dynamicPropertiesStore = storeFactory.getChainBaseManager().getDynamicPropertiesStore();
9395
this.contractStore = storeFactory.getChainBaseManager().getContractStore();
9496
this.codeStore = storeFactory.getChainBaseManager().getCodeStore();
97+
this.abiStore = storeFactory.getChainBaseManager().getAbiStore();
9598
this.accountStore = storeFactory.getChainBaseManager().getAccountStore();
9699

97100
this.receipt = new ReceiptCapsule(Sha256Hash.ZERO_HASH);
@@ -297,6 +300,7 @@ public Runtime getRuntime() {
297300
}
298301

299302
public void deleteContract(byte[] address) {
303+
abiStore.delete(address);
300304
codeStore.delete(address);
301305
accountStore.delete(address);
302306
contractStore.delete(address);

0 commit comments

Comments
 (0)