@@ -73,38 +73,35 @@ func NewTxValidator(ledger ledger.ValidatedLedger) Validator {
73
73
}
74
74
75
75
func (v * txValidator ) Validate (block * common.Block ) {
76
+ logger .Debug ("START Block Validation" )
77
+ defer logger .Debug ("END Block Validation" )
76
78
txsfltr := ledgerUtil .NewFilterBitArray (uint (len (block .Data .Data )))
77
79
for tIdx , d := range block .Data .Data {
78
80
if d != nil {
79
81
if env , err := utils .GetEnvelopeFromBlock (d ); err != nil {
80
82
logger .Warningf ("Error getting tx from block(%s)" , err )
83
+ txsfltr .Set (uint (tIdx ))
81
84
} else if env != nil {
82
85
// validate the transaction: here we check that the transaction
83
86
// is properly formed, properly signed and that the security
84
87
// chain binding proposal to endorsements to tx holds. We do
85
88
// NOT check the validity of endorsements, though. That's a
86
89
// job for VSCC below
90
+ logger .Debug ("Validating transaction peer.ValidateTransaction()" )
87
91
if payload , _ , err := peer .ValidateTransaction (env ); err != nil {
88
- // TODO: this code needs to receive a bit more attention and discussion:
89
- // it's not clear what it means if a transaction which causes a failure
90
- // in validation is just dropped on the floor
91
92
logger .Errorf ("Invalid transaction with index %d, error %s" , tIdx , err )
92
93
txsfltr .Set (uint (tIdx ))
93
94
} else {
94
95
//the payload is used to get headers
96
+ logger .Debug ("Validating transaction vscc tx validate" )
95
97
if err = v .vscc .VSCCValidateTx (payload , d ); err != nil {
96
- // TODO: this code needs to receive a bit more attention and discussion:
97
- // it's not clear what it means if a transaction which causes a failure
98
- // in validation is just dropped on the floor
99
98
txID := payload .Header .ChainHeader .TxID
100
- logger .Errorf ("isTxValidForVscc for transaction txId = %s returned error %s" , txID , err )
99
+ logger .Errorf ("VSCCValidateTx for transaction txId = %s returned error %s" , txID , err )
101
100
txsfltr .Set (uint (tIdx ))
102
101
continue
103
102
}
104
103
105
- if t , err := proto .Marshal (env ); err == nil {
106
- block .Data .Data = append (block .Data .Data , t )
107
- } else {
104
+ if _ , err := proto .Marshal (env ); err != nil {
108
105
logger .Warningf ("Cannot marshal transactoins %s" , err )
109
106
txsfltr .Set (uint (tIdx ))
110
107
}
@@ -132,6 +129,7 @@ func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []b
132
129
133
130
// Get transaction id
134
131
txid := payload .Header .ChainHeader .TxID
132
+ logger .Info ("[XXX remove me XXX] Transaction type," , common .HeaderType (payload .Header .ChainHeader .Type ))
135
133
if txid == "" {
136
134
err := fmt .Errorf ("transaction header does not contain transaction ID" )
137
135
logger .Errorf ("%s" , err )
@@ -153,24 +151,40 @@ func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []b
153
151
defer txsim .Done ()
154
152
ctxt := context .WithValue (context .Background (), chaincode .TXSimulatorKey , txsim )
155
153
156
- //generate an internal txid for executing system chaincode calls below on behalf
157
- //of original txid
158
- vscctxid := coreUtil .GenerateUUID ()
154
+ // get header extensions so we have the visibility field
155
+ hdrExt , err := utils .GetChaincodeHeaderExtension (payload .Header )
156
+ if err != nil {
157
+ return err
158
+ }
159
159
160
- // Extracting vscc from lccc
161
- /*
162
- data, err := chaincode.GetChaincodeDataFromLCCC(ctxt, vscctxid, nil, chainID, "vscc")
160
+ // TODO: Temporary solution until FAB-1422 get resolved
161
+ // Explanation: we actually deploying chaincode transaction,
162
+ // hence no lccc yet to query for the data, therefore currently
163
+ // introducing a workaround to skip obtaining LCCC data.
164
+ var data * chaincode.ChaincodeData
165
+ if hdrExt .ChaincodeID .Name != "lccc" {
166
+ // Extracting vscc from lccc
167
+ logger .Info ("Extracting chaincode data from LCCC txid = " , txid , "chainID" , chainID , "chaincode name" , hdrExt .ChaincodeID .Name )
168
+ data , err = chaincode .GetChaincodeDataFromLCCC (ctxt , txid , nil , chainID , hdrExt .ChaincodeID .Name )
163
169
if err != nil {
164
170
logger .Errorf ("Unable to get chaincode data from LCCC for txid %s, due to %s" , txid , err )
165
171
return err
166
172
}
167
- */
173
+ }
174
+
175
+ vscc := "vscc"
176
+ // Check whenever VSCC defined for chaincode data
177
+ if data != nil && data .Vscc != "" {
178
+ vscc = data .Vscc
179
+ }
168
180
181
+ vscctxid := coreUtil .GenerateUUID ()
169
182
// Get chaincode version
170
183
version := coreUtil .GetSysCCVersion ()
171
- cccid := chaincode .NewCCContext (chainID , " vscc" , version , vscctxid , true , nil )
184
+ cccid := chaincode .NewCCContext (chainID , vscc , version , vscctxid , true , nil )
172
185
173
186
// invoke VSCC
187
+ logger .Info ("Invoking VSCC txid" , txid , "chaindID" , chainID )
174
188
_ , _ , err = chaincode .ExecuteChaincode (ctxt , cccid , args )
175
189
if err != nil {
176
190
logger .Errorf ("VSCC check failed for transaction txid=%s, error %s" , txid , err )
0 commit comments