Skip to content

Commit addaee5

Browse files
author
Jason Yellick
committed
[FAB-9688] Remove dangerous unused CCID.ChainID
The CCID struct has a ChainID field. This field affects the output of GetName(). There is a comment in GetName() indicating that if unset, the chaincode must be a chainless system chaincode, however, this field is in fact never set. If it were, the rest of the chaincode container logic would break, and we would spawn a container per chaincode per channel, instead of just per chaincode. This CR removes this unused field and the logic in GetName around it. Change-Id: I9f666d7f2c2942372a363bc301f275c56fe55228 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 72ef358 commit addaee5

File tree

3 files changed

+5
-43
lines changed

3 files changed

+5
-43
lines changed

core/chaincode/exectransaction_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *ccprovider.CCContex
530530

531531
if destroyImage {
532532
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
533-
dir := container.DestroyImageReq{CCID: ccintf.CCID{ChaincodeSpec: spec, NetworkID: theChaincodeSupport.peerNetworkID, PeerID: theChaincodeSupport.peerID, ChainID: cccid.ChainID}, Force: true, NoPrune: true}
533+
dir := container.DestroyImageReq{CCID: ccintf.CCID{ChaincodeSpec: spec, NetworkID: theChaincodeSupport.peerNetworkID, PeerID: theChaincodeSupport.peerID}, Force: true, NoPrune: true}
534534

535535
_, err = container.VMCProcess(ctxt, container.DOCKER, dir)
536536
if err != nil {

core/container/ccintf/ccintf.go

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package ccintf
@@ -21,9 +11,6 @@ package ccintf
2111
//Currently inproccontroller uses it. dockercontroller does not.
2212

2313
import (
24-
"encoding/hex"
25-
26-
"github.com/hyperledger/fabric/common/util"
2714
pb "github.com/hyperledger/fabric/protos/peer"
2815
"golang.org/x/net/context"
2916
)
@@ -50,7 +37,6 @@ type CCID struct {
5037
ChaincodeSpec *pb.ChaincodeSpec
5138
NetworkID string
5239
PeerID string
53-
ChainID string
5440
Version string
5541
}
5642

@@ -65,12 +51,5 @@ func (ccid *CCID) GetName() string {
6551
name = name + "-" + ccid.Version
6652
}
6753

68-
//this better be chainless system chaincode!
69-
if ccid.ChainID != "" {
70-
hash := util.ComputeSHA256([]byte(ccid.ChainID))
71-
hexstr := hex.EncodeToString(hash[:])
72-
name = name + "-" + hexstr
73-
}
74-
7554
return name
7655
}

core/container/ccintf/ccintf_test.go

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
/*
2-
Copyright IBM Corp. 2017 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package ccintf
188

199
import (
20-
"encoding/hex"
2110
"testing"
2211

23-
"github.com/hyperledger/fabric/common/util"
2412
pb "github.com/hyperledger/fabric/protos/peer"
2513
"github.com/stretchr/testify/assert"
2614
)
@@ -30,11 +18,6 @@ func TestGetName(t *testing.T) {
3018
ccid := &CCID{ChaincodeSpec: spec, Version: "ver"}
3119
name := ccid.GetName()
3220
assert.Equal(t, "ccname-ver", name, "unexpected name")
33-
34-
ccid.ChainID = GetCCHandlerKey()
35-
hash := hex.EncodeToString(util.ComputeSHA256([]byte(ccid.ChainID)))
36-
name = ccid.GetName()
37-
assert.Equal(t, "ccname-ver-"+hash, name, "unexpected name with hash")
3821
}
3922

4023
func TestBadCCID(t *testing.T) {

0 commit comments

Comments
 (0)