Skip to content

Commit 25f340a

Browse files
committed
[FAB-3536] Remove CONFIG tx check in the ledger code
This CR - Removes the check for CONFIG transaction in statebased validation code - Moves the check for unknown transaction type to core/committer/txvalidator/validator.go Change-Id: Ifa78a1bd759208180c723c335f3176e64a21dd26 Signed-off-by: manish <[email protected]>
1 parent 0aff6e4 commit 25f340a

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

core/committer/txvalidator/validator.go

+5
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ func (v *txValidator) Validate(block *common.Block) error {
204204
return err
205205
}
206206
logger.Debugf("config transaction received for chain %s", channel)
207+
} else {
208+
logger.Warningf("Unknown transaction type [%s] in block number [%d] transaction index [%d]",
209+
common.HeaderType(chdr.Type), block.Header.Number, tIdx)
210+
txsfltr.SetFlag(tIdx, peer.TxValidationCode_UNKNOWN_TX_TYPE)
211+
continue
207212
}
208213

209214
if _, err := proto.Marshal(env); err != nil {

core/ledger/kvledger/txmgmt/validator/statebasedval/state_based_validator.go

+16-26
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ func (v *Validator) validateEndorserTX(envBytes []byte, doMVCCValidation bool, u
7373
return txRWSet, txResult, err
7474
}
7575

76-
// TODO validate configuration transaction
77-
func (v *Validator) validateConfigTX(env *common.Envelope) (bool, error) {
78-
return true, nil
79-
}
80-
8176
// ValidateAndPrepareBatch implements method in Validator interface
8277
func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidation bool) (*statedb.UpdateBatch, error) {
8378
logger.Debugf("New block arrived for validation:%#v, doMVCCValidation=%t", block, doMVCCValidation)
@@ -116,31 +111,27 @@ func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidatio
116111
return nil, err
117112
}
118113

119-
if common.HeaderType(chdr.Type) == common.HeaderType_ENDORSER_TRANSACTION {
120-
txRWSet, txResult, err := v.validateEndorserTX(envBytes, doMVCCValidation, updates)
114+
txType := common.HeaderType(chdr.Type)
121115

122-
if err != nil {
123-
return nil, err
124-
}
116+
if txType != common.HeaderType_ENDORSER_TRANSACTION {
117+
logger.Debugf("Skipping mvcc validation for Block [%d] Transaction index [%d] because, the transaction type is [%s]",
118+
block.Header.Number, txIndex, txType)
119+
continue
120+
}
125121

126-
txsFilter.SetFlag(txIndex, txResult)
122+
txRWSet, txResult, err := v.validateEndorserTX(envBytes, doMVCCValidation, updates)
127123

128-
//txRWSet != nil => t is valid
129-
if txRWSet != nil {
130-
committingTxHeight := version.NewHeight(block.Header.Number, uint64(txIndex))
131-
addWriteSetToBatch(txRWSet, committingTxHeight, updates)
132-
txsFilter.SetFlag(txIndex, peer.TxValidationCode_VALID)
133-
}
134-
} else if common.HeaderType(chdr.Type) == common.HeaderType_CONFIG {
135-
_, err := v.validateConfigTX(env)
124+
if err != nil {
125+
return nil, err
126+
}
136127

137-
if err != nil {
138-
return nil, err
139-
}
128+
txsFilter.SetFlag(txIndex, txResult)
129+
130+
//txRWSet != nil => t is valid
131+
if txRWSet != nil {
132+
committingTxHeight := version.NewHeight(block.Header.Number, uint64(txIndex))
133+
addWriteSetToBatch(txRWSet, committingTxHeight, updates)
140134
txsFilter.SetFlag(txIndex, peer.TxValidationCode_VALID)
141-
} else {
142-
logger.Errorf("Skipping transaction %d that's not an endorsement or configuration %d", txIndex, chdr.Type)
143-
txsFilter.SetFlag(txIndex, peer.TxValidationCode_UNKNOWN_TX_TYPE)
144135
}
145136

146137
if txsFilter.IsValid(txIndex) {
@@ -150,7 +141,6 @@ func (v *Validator) ValidateAndPrepareBatch(block *common.Block, doMVCCValidatio
150141
logger.Warningf("Block [%d] Transaction index [%d] TxId [%s] marked as invalid by state validator. Reason code [%d]",
151142
block.Header.Number, txIndex, chdr.TxId, txsFilter.Flag(txIndex))
152143
}
153-
154144
}
155145
block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = txsFilter
156146
return updates, nil

0 commit comments

Comments
 (0)