Skip to content

Commit

Permalink
Merge pull request #3866 from tronprotocol/release_4.3
Browse files Browse the repository at this point in the history
release 4.2.2
  • Loading branch information
zhang0125 authored Jun 21, 2021
2 parents 858378a + 5f6b75c commit 0ba5c5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.tron.common.logsfilter.trigger.ContractTrigger;
import org.tron.common.runtime.vm.LogInfo;
import org.tron.common.utils.StringUtil;
import org.tron.core.capsule.AbiCapsule;
import org.tron.core.capsule.ContractCapsule;
import org.tron.core.db.TransactionTrace;
import org.tron.core.store.StoreFactory;
Expand Down Expand Up @@ -75,8 +76,14 @@ public List<ContractTrigger> parseLogInfos(List<LogInfo> logInfos, Repository de
abiMap.put(strContractAddr, ABI.getDefaultInstance());
continue;
}
ABI abi = StoreFactory.getInstance().getChainBaseManager()
.getAbiStore().get(contractAddress).getInstance();
AbiCapsule abiCapsule = StoreFactory.getInstance().getChainBaseManager()
.getAbiStore().get(contractAddress);
ABI abi;
if (abiCapsule == null || abiCapsule.getInstance() == null) {
abi = ABI.getDefaultInstance();
} else {
abi = abiCapsule.getInstance();
}
String creatorAddr = StringUtil.encode58Check(
TransactionTrace
.convertToTronAddress(contract.getInstance().getOriginAddress().toByteArray()));
Expand Down
17 changes: 11 additions & 6 deletions framework/src/main/java/org/tron/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2471,15 +2471,20 @@ public Transaction triggerContract(TriggerSmartContract
Return.Builder retBuilder)
throws ContractValidateException, ContractExeException, HeaderNotFound, VMIllegalException {

AbiStore abiStore = chainBaseManager.getAbiStore();
byte[] contractAddress = triggerSmartContract.getContractAddress()
.toByteArray();
AbiCapsule abiCapsule = abiStore.get(contractAddress);
if (abiCapsule == null) {
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(contractAddress);
if (contractCapsule == null) {
throw new ContractValidateException(
"No contract or not a valid smart contract");
}
SmartContract.ABI abi = abiCapsule.getInstance();
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(contractAddress);
SmartContract.ABI abi;
if (abiCapsule == null || abiCapsule.getData() == null) {
abi = SmartContract.ABI.getDefaultInstance();
} else {
abi = abiCapsule.getInstance();
}

byte[] selector = WalletUtil.getSelector(
triggerSmartContract.getData().toByteArray());
Expand Down Expand Up @@ -2580,7 +2585,7 @@ public SmartContract getContract(GrpcAPI.BytesMessage bytesMessage) {
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(address);
if (Objects.nonNull(contractCapsule)) {
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(address);
if (Objects.nonNull(abiCapsule)) {
if (abiCapsule != null && abiCapsule.getInstance() != null) {
contractCapsule = new ContractCapsule(
contractCapsule.getInstance().toBuilder().setAbi(abiCapsule.getInstance()).build());
}
Expand Down Expand Up @@ -2609,7 +2614,7 @@ public SmartContractDataWrapper getContractInfo(GrpcAPI.BytesMessage bytesMessag
ContractCapsule contractCapsule = chainBaseManager.getContractStore().get(address);
if (Objects.nonNull(contractCapsule)) {
AbiCapsule abiCapsule = chainBaseManager.getAbiStore().get(address);
if (Objects.nonNull(abiCapsule)) {
if (abiCapsule != null && abiCapsule.getInstance() != null) {
contractCapsule = new ContractCapsule(
contractCapsule.getInstance().toBuilder().setAbi(abiCapsule.getInstance()).build());
}
Expand Down

0 comments on commit 0ba5c5c

Please sign in to comment.