Skip to content

Commit

Permalink
Merge "[FAB-3536] Remove CONFIG tx check in the ledger code"
Browse files Browse the repository at this point in the history
  • Loading branch information
christo4ferris authored and Gerrit Code Review committed May 3, 2017
2 parents 4313018 + 25f340a commit 2a3ad9d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
5 changes: 5 additions & 0 deletions core/committer/txvalidator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ func (v *txValidator) Validate(block *common.Block) error {
return err
}
logger.Debugf("config transaction received for chain %s", channel)
} else {
logger.Warningf("Unknown transaction type [%s] in block number [%d] transaction index [%d]",
common.HeaderType(chdr.Type), block.Header.Number, tIdx)
txsfltr.SetFlag(tIdx, peer.TxValidationCode_UNKNOWN_TX_TYPE)
continue
}

if _, err := proto.Marshal(env); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ func (v *Validator) validateEndorserTX(envBytes []byte, doMVCCValidation bool, u
return txRWSet, txResult, err
}

// TODO validate configuration transaction
func (v *Validator) validateConfigTX(env *common.Envelope) (bool, error) {
return true, nil
}

// ValidateAndPrepareBatch implements method in Validator interface
func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidation bool) (*statedb.UpdateBatch, error) {
logger.Debugf("New block arrived for validation:%#v, doMVCCValidation=%t", block, doMVCCValidation)
Expand Down Expand Up @@ -116,31 +111,27 @@ func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidatio
return nil, err
}

if common.HeaderType(chdr.Type) == common.HeaderType_ENDORSER_TRANSACTION {
txRWSet, txResult, err := v.validateEndorserTX(envBytes, doMVCCValidation, updates)
txType := common.HeaderType(chdr.Type)

if err != nil {
return nil, err
}
if txType != common.HeaderType_ENDORSER_TRANSACTION {
logger.Debugf("Skipping mvcc validation for Block [%d] Transaction index [%d] because, the transaction type is [%s]",
block.Header.Number, txIndex, txType)
continue
}

txsFilter.SetFlag(txIndex, txResult)
txRWSet, txResult, err := v.validateEndorserTX(envBytes, doMVCCValidation, updates)

//txRWSet != nil => t is valid
if txRWSet != nil {
committingTxHeight := version.NewHeight(block.Header.Number, uint64(txIndex))
addWriteSetToBatch(txRWSet, committingTxHeight, updates)
txsFilter.SetFlag(txIndex, peer.TxValidationCode_VALID)
}
} else if common.HeaderType(chdr.Type) == common.HeaderType_CONFIG {
_, err := v.validateConfigTX(env)
if err != nil {
return nil, err
}

if err != nil {
return nil, err
}
txsFilter.SetFlag(txIndex, txResult)

//txRWSet != nil => t is valid
if txRWSet != nil {
committingTxHeight := version.NewHeight(block.Header.Number, uint64(txIndex))
addWriteSetToBatch(txRWSet, committingTxHeight, updates)
txsFilter.SetFlag(txIndex, peer.TxValidationCode_VALID)
} else {
logger.Errorf("Skipping transaction %d that's not an endorsement or configuration %d", txIndex, chdr.Type)
txsFilter.SetFlag(txIndex, peer.TxValidationCode_UNKNOWN_TX_TYPE)
}

if txsFilter.IsValid(txIndex) {
Expand All @@ -150,7 +141,6 @@ func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidatio
logger.Warningf("Block [%d] Transaction index [%d] TxId [%s] marked as invalid by state validator. Reason code [%d]",
block.Header.Number, txIndex, chdr.TxId, txsFilter.Flag(txIndex))
}

}
block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = txsFilter
return updates, nil
Expand Down

0 comments on commit 2a3ad9d

Please sign in to comment.