@@ -491,8 +491,16 @@ func (vscc *ValidatorOneValidSignature) ValidateLSCCInvocation(
491
491
492
492
switch lsccFunc {
493
493
case lscc .DEPLOY :
494
+
495
+ /******************************************************************/
496
+ /* security check 1 - cc not in the LCCC table of instantiated cc */
497
+ /******************************************************************/
498
+ if ccExistsOnLedger {
499
+ return fmt .Errorf ("Chaincode %s is already instantiated" , cdsArgs .ChaincodeSpec .ChaincodeId .Name )
500
+ }
501
+
494
502
/****************************************************************************/
495
- /* security check 0.a - validation of rwset (and of collections if enabled) */
503
+ /* security check 2 - validation of rwset (and of collections if enabled) */
496
504
/****************************************************************************/
497
505
if ac .PrivateChannelData () {
498
506
// do extra validation for collections
@@ -508,7 +516,7 @@ func (vscc *ValidatorOneValidSignature) ValidateLSCCInvocation(
508
516
}
509
517
510
518
/*****************************************************/
511
- /* security check 1 - check the instantiation policy */
519
+ /* security check 3 - check the instantiation policy */
512
520
/*****************************************************/
513
521
pol := cdRWSet .InstantiationPolicy
514
522
if pol == nil {
@@ -524,13 +532,6 @@ func (vscc *ValidatorOneValidSignature) ValidateLSCCInvocation(
524
532
return err
525
533
}
526
534
527
- /******************************************************************/
528
- /* security check 2 - cc not in the LCCC table of instantiated cc */
529
- /******************************************************************/
530
- if ccExistsOnLedger {
531
- return fmt .Errorf ("Chaincode %s is already instantiated" , cdsArgs .ChaincodeSpec .ChaincodeId .Name )
532
- }
533
-
534
535
case lscc .UPGRADE :
535
536
/********************************************/
536
537
/* security check 0.a - validation of rwset */
@@ -547,8 +548,15 @@ func (vscc *ValidatorOneValidSignature) ValidateLSCCInvocation(
547
548
return fmt .Errorf ("Upgrading non-existent chaincode %s" , cdsArgs .ChaincodeSpec .ChaincodeId .Name )
548
549
}
549
550
551
+ /**********************************************************/
552
+ /* security check 2 - existing cc's version was different */
553
+ /**********************************************************/
554
+ if cdLedger .Version == cdsArgs .ChaincodeSpec .ChaincodeId .Version {
555
+ return fmt .Errorf ("Existing version of the cc on the ledger (%s) should be different from the upgraded one" , cdsArgs .ChaincodeSpec .ChaincodeId .Version )
556
+ }
557
+
550
558
/*****************************************************/
551
- /* security check 2 - check the instantiation policy */
559
+ /* security check 3 - check the instantiation policy */
552
560
/*****************************************************/
553
561
pol := cdLedger .InstantiationPolicy
554
562
if pol == nil {
@@ -564,13 +572,6 @@ func (vscc *ValidatorOneValidSignature) ValidateLSCCInvocation(
564
572
return err
565
573
}
566
574
567
- /**********************************************************/
568
- /* security check 3 - existing cc's version was different */
569
- /**********************************************************/
570
- if cdLedger .Version == cdsArgs .ChaincodeSpec .ChaincodeId .Version {
571
- return fmt .Errorf ("Existing version of the cc on the ledger (%s) should be different from the upgraded one" , cdsArgs .ChaincodeSpec .ChaincodeId .Version )
572
- }
573
-
574
575
/******************************************************************/
575
576
/* security check 4 - check the instantiation policy in the rwset */
576
577
/******************************************************************/
0 commit comments