Commit c663e90b authored by Lucas Kuhring's avatar Lucas Kuhring
Browse files

Add new log format for validation logs

parent 71838920
......@@ -109,7 +109,7 @@ func (lc *LedgerCommitter) CommitWithPvtData(blockAndPvtData *ledger.BlockAndPvt
firstTransaction := chdr.TxId
*/
//fmt.Printf("{\"ts\":" + strconv.FormatInt(time.Now().UnixNano(), 10) + ",\"msg\":\"FABRIC PERF Validation\",\"block\":\"" + strconv.Itoa(int(blockAndPvtData.Block.GetHeader().GetNumber())) + "\",\"STEP\":3}\n")
fmt.Printf(strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(blockAndPvtData.Block.GetHeader().GetNumber())) + " (Step 3)\n")
fmt.Println("3," + strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(blockAndPvtData.Block.GetHeader().GetNumber())))
}
if config.Log.Validation {
......
......@@ -341,59 +341,34 @@ func (v *TxValidator) validateTx(req *blockValidationRequest, results chan<- *bl
return
}
// Validate tx with vscc and policy
logger.Debug("Validating transaction vscc tx validate")
err, cde := v.Vscc.VSCCValidateTx(tIdx, payload, d, block)
if err != nil {
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error: %s", txID, err)
switch err.(type) {
case *commonerrors.VSCCExecutionFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
case *commonerrors.VSCCInfoLookupFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
default:
results <- &blockValidationResult{
tIdx: tIdx,
validationCode: cde,
}
return
}
}
strVSCC := os.Getenv("STREAMCHAIN_VSCC")
var strVSCC = os.Getenv("STREAMCHAIN_VSCC")
if strVSCC == "" || strVSCC == "true" {
// Validate tx with vscc and policy
logger.Debug("Validating transaction vscc tx validate")
err, cde := v.Vscc.VSCCValidateTx(tIdx, payload, d, block)
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error: %s", txID, err)
switch err.(type) {
case *commonerrors.VSCCExecutionFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
case *commonerrors.VSCCInfoLookupFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
default:
results <- &blockValidationResult{
tIdx: tIdx,
validationCode: cde,
if err != nil {
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error: %s", txID, err)
switch err.(type) {
case *commonerrors.VSCCExecutionFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
case *commonerrors.VSCCInfoLookupFailureError:
results <- &blockValidationResult{
tIdx: tIdx,
err: err,
}
return
default:
results <- &blockValidationResult{
tIdx: tIdx,
validationCode: cde,
}
return
}
return
}
}
......
......@@ -309,7 +309,7 @@ func (l *kvLedger) CommitWithPvtData(pvtdataAndBlock *ledger.BlockAndPvtData) er
if config.Log.FullCommit {
//fmt.Printf("{\"ts\":" + strconv.FormatInt(time.Now().UnixNano(), 10) + ",\"msg\":\"FABRIC PERF Validation\",\"block\":" + strconv.Itoa(int(blockNo)) + ",\"STEP\":2}\n")
fmt.Printf(strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(blockNo)) + " (Step 2)\n")
fmt.Println("2," + strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(blockNo)))
}
elapsedBlockProcessing := time.Since(startBlockProcessing)
......
......@@ -157,7 +157,26 @@ func (c *coordinator) VerifyBlock(block *common.Block, privateDataSets util.PvtD
if config.Log.FullCommit {
//fmt.Printf("{\"ts\":" + strconv.FormatInt(time.Now().UnixNano(), 10) + ",\"msg\":\"FABRIC PERF Validation\",\"block\":" + strconv.Itoa(int(block.Header.Number)) + ",\"STEP\":0}\n")
fmt.Printf(strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(block.Header.Number)) + " (Step 0)\n")
fmt.Println("0," + strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(block.Header.Number)))
}
txcount := -1
if block != nil && block.Metadata != nil && block.Metadata.Metadata != nil && block.Data != nil && block.Data.Data != nil {
txcount = 0
txsFilter := ha.TxValidationFlags(block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER])
if len(txsFilter) == 0 {
txsFilter = ha.NewTxValidationFlags(len(block.Data.Data))
block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = txsFilter
}
for txIndex := range block.Data.Data {
if txsFilter.IsInvalid(txIndex) {
continue
}
txcount++
}
}
if config.Log.Validation {
......@@ -201,7 +220,7 @@ func (c *coordinator) StoreBlock(block *common.Block, privateDataSets util.PvtDa
if config.Log.FullCommit {
//fmt.Printf("{\"ts\":" + strconv.FormatInt(time.Now().UnixNano(), 10) + ",\"msg\":\"FABRIC PERF Validation\",\"block\":" + strconv.Itoa(int(block.Header.Number)) + ",\"STEP\":1}\n")
fmt.Printf(strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(block.Header.Number)) + " (Step 1)\n")
fmt.Println("1," + strconv.FormatInt(time.Now().UnixNano(), 10) + "," + strconv.Itoa(int(block.Header.Number)))
}
blockAndPvtData := &ledger.BlockAndPvtData{
......
......@@ -15,7 +15,6 @@ import (
"time"
pb "github.com/golang/protobuf/proto"
vsccErrors "github.com/hyperledger/fabric/common/errors"
"github.com/hyperledger/fabric/gossip/api"
"github.com/hyperledger/fabric/gossip/comm"
common2 "github.com/hyperledger/fabric/gossip/common"
......@@ -703,13 +702,6 @@ func (s *GossipStateProviderImpl) deliverPayloads() {
continue
}
}
if err := s.commitBlock(rawBlock, p); err != nil {
if executionErr, isExecutionErr := err.(*vsccErrors.VSCCExecutionFailureError); isExecutionErr {
logger.Errorf("Failed executing VSCC due to %v. Aborting chain processing", executionErr)
return
}
logger.Panicf("Cannot commit block to the ledger due to %+v", errors.WithStack(err))
}
job := &PipelineData{rawBlock, p, payload.SeqNum}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment