Browse Source

show exeState in sdk;

tags/1.1.1^2
zhaoguangwei 4 years ago
parent
commit
41845551b5
4 changed files with 19 additions and 30 deletions
  1. +9
    -7
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java
  2. +1
    -1
      source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayInterceptServiceHandler.java
  3. +8
    -21
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/TransactionBatchProcessor.java
  4. +1
    -1
      source/pom.xml

+ 9
- 7
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java View File

@@ -400,19 +400,20 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
int msgId = 0;

boolean isOK = true;
TransactionState transactionState = TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK;

for (int i = 0; i < commands.length; i++) {

byte[] txContent = commands[i];
try {
AsyncFuture<byte[]> asyncFuture = messageHandle.processOrdered(msgId++, txContent, realmName, batchId);
asyncFutureLinkedList.add(asyncFuture);
} catch (BlockRollbackException e) {

LOGGER.error("Error occurred while processing ordered messages! --" + e.getMessage(), e);

isOK = false;

// TODO: handle the BlockRollbackException in detail;
if (e instanceof DataVersionConflictException) {
transactionState = TransactionState.DATA_VERSION_CONFLICT;
}
break;
}
}
@@ -432,7 +433,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
} else {

for (int i = 0; i < commands.length; i++) {
responseLinkedList.add(createAppResponse(commands[i]));
responseLinkedList.add(createAppResponse(commands[i],transactionState));
}

Random random = new Random();
@@ -451,11 +452,12 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
}
}

public byte[] createAppResponse(byte[] command) {
public byte[] createAppResponse(byte[] command, TransactionState transactionState) {
TransactionRequest txRequest = BinaryProtocol.decode(command);

TxResponseMessage resp = new TxResponseMessage(txRequest.getTransactionContent().getHash());
resp.setExecutionState(TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK);
// resp.setExecutionState(TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK);
resp.setExecutionState(transactionState);

return BinaryProtocol.encode(resp, TransactionResponse.class);
}


+ 1
- 1
source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayInterceptServiceHandler.java View File

@@ -42,7 +42,7 @@ public class GatewayInterceptServiceHandler implements GatewayInterceptService {
private void contractCheck(final ContractCodeDeployOperation contractOP) {

// 校验chainCode
ContractJarUtils.verify(contractOP.getChainCode());
ContractJarUtils.verify(contractsPath, contractOP.getChainCode());
}

private static String jarRootDir() {


+ 8
- 21
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/TransactionBatchProcessor.java View File

@@ -5,29 +5,11 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import com.jd.blockchain.ledger.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.BlockRollbackException;
import com.jd.blockchain.ledger.BytesValue;
import com.jd.blockchain.ledger.ContractDoesNotExistException;
import com.jd.blockchain.ledger.DataAccountDoesNotExistException;
import com.jd.blockchain.ledger.IllegalTransactionException;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerException;
import com.jd.blockchain.ledger.LedgerPermission;
import com.jd.blockchain.ledger.LedgerSecurityException;
import com.jd.blockchain.ledger.Operation;
import com.jd.blockchain.ledger.OperationResult;
import com.jd.blockchain.ledger.OperationResultData;
import com.jd.blockchain.ledger.ParticipantDoesNotExistException;
import com.jd.blockchain.ledger.TransactionContent;
import com.jd.blockchain.ledger.TransactionRequest;
import com.jd.blockchain.ledger.TransactionResponse;
import com.jd.blockchain.ledger.TransactionRollbackException;
import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.ledger.UserDoesNotExistException;
import com.jd.blockchain.ledger.core.TransactionRequestExtension.Credential;
import com.jd.blockchain.service.TransactionBatchProcess;
import com.jd.blockchain.service.TransactionBatchResult;
@@ -63,7 +45,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess {

/**
* @param newBlockEditor 新区块的数据编辑器;
* @param ledgerQueryer 账本查询器,只包含新区块的前一个区块的数据集;即未提交新区块之前的经过共识的账本最新数据集;
* @param newBlockEditor 账本查询器,只包含新区块的前一个区块的数据集;即未提交新区块之前的经过共识的账本最新数据集;
* @param opHandles 操作处理对象注册表;
*/
public TransactionBatchProcessor(LedgerSecurityManager securityManager, LedgerEditor newBlockEditor,
@@ -153,6 +135,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess {

} catch (BlockRollbackException e) {
// 发生区块级别的处理异常,向上重新抛出异常进行处理,整个区块可能被丢弃;
resp = discard(request, e.getState());
LOGGER.error(String.format(
"Ignore transaction caused by BlockRollbackException! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s",
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(),
@@ -287,8 +270,12 @@ public class TransactionBatchProcessor implements TransactionBatchProcess {
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(),
e.getMessage()), e);
} catch (BlockRollbackException e) {
// 回滚整个区块;
// rollback all the block;
// TODO: handle the BlockRollbackException in detail;
result = TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK;
if (e instanceof DataVersionConflictException) {
result = TransactionState.DATA_VERSION_CONFLICT;
}
txCtx.rollback();
LOGGER.error(
String.format("Transaction was rolled back! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s",


+ 1
- 1
source/pom.xml View File

@@ -35,7 +35,7 @@
</modules>

<properties>
<bft-smart.version>0.2.0.RELEASE</bft-smart.version>
<bft-smart.version>0.3.0-SNAPSHOT</bft-smart.version>
<data-explorer.version>1.1.0.RELEASE</data-explorer.version>
<manager-explorer.version>1.1.0.RELEASE</manager-explorer.version>
<commons-io.version>2.4</commons-io.version>


Loading…
Cancel
Save