@@ -29,10 +29,13 @@ import (
2929 ledgerUtil "github.com/hyperledger/fabric/core/ledger/util"
3030 "github.com/hyperledger/fabric/msp"
3131
32+ "github.com/hyperledger/fabric/common/policies"
3233 "github.com/hyperledger/fabric/protos/common"
3334 "github.com/hyperledger/fabric/protos/peer"
3435 "github.com/hyperledger/fabric/protos/utils"
3536 "github.com/op/go-logging"
37+
38+ "github.com/hyperledger/fabric/common/cauthdsl"
3639)
3740
3841// Support provides all of the needed to evaluate the VSCC
@@ -45,6 +48,13 @@ type Support interface {
4548
4649 // Apply attempts to apply a configtx to become the new config
4750 Apply (configtx * common.ConfigEnvelope ) error
51+
52+ // PolicyManager returns the policies.Manager for the channel
53+ PolicyManager () policies.Manager
54+
55+ // GetMSPIDs returns the IDs for the application MSPs
56+ // that have been defined in the channel
57+ GetMSPIDs (cid string ) []string
4858}
4959
5060//Validator interface which defines API to validate block transactions
@@ -58,7 +68,7 @@ type Validator interface {
5868// and vscc execution, in order to increase
5969// testability of txValidator
6070type vsccValidator interface {
61- VSCCValidateTx (payload * common.Payload , envBytes []byte ) error
71+ VSCCValidateTx (payload * common.Payload , envBytes []byte , env * common. Envelope ) error
6272}
6373
6474// vsccValidator implementation which used to call
@@ -148,7 +158,7 @@ func (v *txValidator) Validate(block *common.Block) error {
148158
149159 //the payload is used to get headers
150160 logger .Debug ("Validating transaction vscc tx validate" )
151- if err = v .vscc .VSCCValidateTx (payload , d ); err != nil {
161+ if err = v .vscc .VSCCValidateTx (payload , d , env ); err != nil {
152162 txID := txID
153163 logger .Errorf ("VSCCValidateTx for transaction txId = %s returned error %s" , txID , err )
154164 txsfltr .SetFlag (tIdx , peer .TxValidationCode_ENDORSEMENT_POLICY_FAILURE )
@@ -191,7 +201,8 @@ func (v *txValidator) Validate(block *common.Block) error {
191201 return nil
192202}
193203
194- func (v * vsccValidatorImpl ) VSCCValidateTx (payload * common.Payload , envBytes []byte ) error {
204+ func (v * vsccValidatorImpl ) VSCCValidateTx (payload * common.Payload , envBytes []byte , env * common.Envelope ) error {
205+ // get channel header
195206 chdr , err := utils .UnmarshalChannelHeader (payload .Header .ChannelHeader )
196207 if err != nil {
197208 return err
@@ -226,22 +237,25 @@ func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []b
226237 return err
227238 }
228239
229- // LSCC should not undergo standard VSCC type of
230- // validation. It should instead go through system
231- // policy validation to determine whether the issuer
232- // is entitled to deploy a chaincode on our chain
233- // VSCCValidateTx should
234- if hdrExt .ChaincodeId .Name == "lscc" {
235- // TODO: until FAB-1934 is in, we need to stop here
236- logger .Debugf ("Invocation of LSCC detected, no further VSCC validation necessary" )
237- return nil
238- }
239-
240- // obtain name of the VSCC and the policy from LSCC
241- vscc , policy , err := v .ccprovider .GetCCValidationInfoFromLSCC (ctxt , txid , nil , nil , chainID , hdrExt .ChaincodeId .Name )
242- if err != nil {
243- logger .Errorf ("Unable to get chaincode data from LSCC for txid %s, due to %s" , txid , err )
244- return err
240+ var vscc string
241+ var policy []byte
242+ if hdrExt .ChaincodeId .Name != "lscc" {
243+ // when we are validating any chaincode other than
244+ // LSCC, we need to ask LSCC to give us the name
245+ // of VSCC and of the policy that should be used
246+
247+ // obtain name of the VSCC and the policy from LSCC
248+ vscc , policy , err = v .ccprovider .GetCCValidationInfoFromLSCC (ctxt , txid , nil , nil , chainID , hdrExt .ChaincodeId .Name )
249+ if err != nil {
250+ logger .Errorf ("Unable to get chaincode data from LSCC for txid %s, due to %s" , txid , err )
251+ return err
252+ }
253+ } else {
254+ // when we are validating LSCC, we use the default
255+ // VSCC and a default policy that requires one signature
256+ // from any of the members of the channel
257+ vscc = "vscc"
258+ policy = cauthdsl .SignedByAnyMember (v .support .GetMSPIDs (chainID ))
245259 }
246260
247261 // build arguments for VSCC invocation
0 commit comments