Skip to content

Commit 0045a79

Browse files
author
Jason Yellick
committed
[FAB-2030] Fix protos with uppercase abbreviations
https://jira.hyperledger.org/browse/FAB-2030 According to the proto style guide, fields should be lower_underscored which generally converts nicely to golang as LowerUnderscored. However, for certain cases, like chaincode_id, this converts to ChaincodeId rather than as desired to ChaincodeID. This change updates the problematic fields to use the correct proto style, and updates the golang to expect the appropriate (although odd) output. Note, per the proto devs, golang/protobuf#53 there is no intent to modify the protoc generation to attempt to produce upper case ID API, etc. Still, the odd golang results seem worth following the style guide. Note, this CR also changes chainID to channel_id as these lines were already being affected and a community apparently came to a decision that the world channel is preferable to the word chain. https://jira.hyperledger.org/browse/FAB-2033 Change-Id: I9c5ebab88fc8d7f45335c904a56676c55a467e5d Signed-off-by: Jason Yellick <[email protected]>
1 parent 31b9c40 commit 0045a79

File tree

97 files changed

+611
-609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+611
-609
lines changed

bddtests/chaincode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
func createChaincodeSpec(ccType string, path string, args [][]byte) *pb.ChaincodeSpec {
3030
// make chaincode spec for chaincode to be deployed
3131
ccSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[ccType]),
32-
ChaincodeID: &pb.ChaincodeID{Path: path},
32+
ChaincodeId: &pb.ChaincodeID{Path: path},
3333
Input: &pb.ChaincodeInput{Args: args}}
3434
return ccSpec
3535

@@ -46,7 +46,7 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
4646
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
4747
}
4848
lcChaincodeSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG,
49-
ChaincodeID: &pb.ChaincodeID{Name: "lccc"},
49+
ChaincodeId: &pb.ChaincodeID{Name: "lccc"},
5050
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
5151
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
5252

common/cauthdsl/cauthdsl_builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func SignedByMspMember(mspId string) *cb.SignaturePolicyEnvelope {
8080
// specify the principal: it's a member of the msp we just found
8181
principal := &cb.MSPPrincipal{
8282
PrincipalClassification: cb.MSPPrincipal_ROLE,
83-
Principal: utils.MarshalOrPanic(&cb.MSPRole{Role: cb.MSPRole_MEMBER, MSPIdentifier: mspId})}
83+
Principal: utils.MarshalOrPanic(&cb.MSPRole{Role: cb.MSPRole_MEMBER, MspIdentifier: mspId})}
8484

8585
// create the policy: it requires exactly 1 signature from the first (and only) principal
8686
p := &cb.SignaturePolicyEnvelope{

common/cauthdsl/policyparser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func secondPass(args ...interface{}) (interface{}, error) {
148148
/* build the principal we've been told */
149149
p := &common.MSPPrincipal{
150150
PrincipalClassification: common.MSPPrincipal_ROLE,
151-
Principal: utils.MarshalOrPanic(&common.MSPRole{MSPIdentifier: subm[0][1], Role: r})}
151+
Principal: utils.MarshalOrPanic(&common.MSPRole{MspIdentifier: subm[0][1], Role: r})}
152152
ctx.principals = append(ctx.principals, p)
153153

154154
/* create a SignaturePolicy that requires a signature from

common/cauthdsl/policyparser_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ func TestAnd(t *testing.T) {
3333

3434
principals = append(principals, &common.MSPPrincipal{
3535
PrincipalClassification: common.MSPPrincipal_ROLE,
36-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
36+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
3737

3838
principals = append(principals, &common.MSPPrincipal{
3939
PrincipalClassification: common.MSPPrincipal_ROLE,
40-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
40+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
4141

4242
p2 := &common.SignaturePolicyEnvelope{
4343
Version: 0,
@@ -56,11 +56,11 @@ func TestOr(t *testing.T) {
5656

5757
principals = append(principals, &common.MSPPrincipal{
5858
PrincipalClassification: common.MSPPrincipal_ROLE,
59-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
59+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
6060

6161
principals = append(principals, &common.MSPPrincipal{
6262
PrincipalClassification: common.MSPPrincipal_ROLE,
63-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
63+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
6464

6565
p2 := &common.SignaturePolicyEnvelope{
6666
Version: 0,
@@ -79,15 +79,15 @@ func TestComplex1(t *testing.T) {
7979

8080
principals = append(principals, &common.MSPPrincipal{
8181
PrincipalClassification: common.MSPPrincipal_ROLE,
82-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
82+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
8383

8484
principals = append(principals, &common.MSPPrincipal{
8585
PrincipalClassification: common.MSPPrincipal_ROLE,
86-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "C"})})
86+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "C"})})
8787

8888
principals = append(principals, &common.MSPPrincipal{
8989
PrincipalClassification: common.MSPPrincipal_ROLE,
90-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
90+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
9191

9292
p2 := &common.SignaturePolicyEnvelope{
9393
Version: 0,
@@ -106,19 +106,19 @@ func TestComplex2(t *testing.T) {
106106

107107
principals = append(principals, &common.MSPPrincipal{
108108
PrincipalClassification: common.MSPPrincipal_ROLE,
109-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
109+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
110110

111111
principals = append(principals, &common.MSPPrincipal{
112112
PrincipalClassification: common.MSPPrincipal_ROLE,
113-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
113+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
114114

115115
principals = append(principals, &common.MSPPrincipal{
116116
PrincipalClassification: common.MSPPrincipal_ROLE,
117-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_ADMIN, MSPIdentifier: "C"})})
117+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_ADMIN, MspIdentifier: "C"})})
118118

119119
principals = append(principals, &common.MSPPrincipal{
120120
PrincipalClassification: common.MSPPrincipal_ROLE,
121-
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "D"})})
121+
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "D"})})
122122

123123
p2 := &common.SignaturePolicyEnvelope{
124124
Version: 0,

common/configtx/manager.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ type configManager struct {
5959
callOnUpdate []func(api.Manager)
6060
}
6161

62-
// computeChainIDAndSequence returns the chain id and the sequence number for a config envelope
62+
// computeChannelIdAndSequence returns the chain id and the sequence number for a config envelope
6363
// or an error if there is a problem with the config envelope
64-
func computeChainIDAndSequence(config *cb.Config) (string, uint64, error) {
64+
func computeChannelIdAndSequence(config *cb.Config) (string, uint64, error) {
6565
if len(config.Items) == 0 {
6666
return "", 0, errors.New("Empty envelope unsupported")
6767
}
@@ -72,11 +72,11 @@ func computeChainIDAndSequence(config *cb.Config) (string, uint64, error) {
7272
return "", 0, fmt.Errorf("Header not set")
7373
}
7474

75-
if config.Header.ChainID == "" {
75+
if config.Header.ChannelId == "" {
7676
return "", 0, fmt.Errorf("Header chainID was not set")
7777
}
7878

79-
chainID := config.Header.ChainID
79+
chainID := config.Header.ChannelId
8080

8181
if err := validateChainID(chainID); err != nil {
8282
return "", 0, err
@@ -146,7 +146,7 @@ func NewManagerImpl(configtx *cb.ConfigEnvelope, initializer api.Initializer, ca
146146
return nil, err
147147
}
148148

149-
chainID, seq, err := computeChainIDAndSequence(config)
149+
chainID, seq, err := computeChannelIdAndSequence(config)
150150
if err != nil {
151151
return nil, fmt.Errorf("Error computing chain ID and sequence: %s", err)
152152
}
@@ -206,7 +206,7 @@ func (cm *configManager) processConfig(configtx *cb.ConfigEnvelope) (configMap m
206206
return nil, err
207207
}
208208

209-
chainID, seq, err := computeChainIDAndSequence(config)
209+
chainID, seq, err := computeChannelIdAndSequence(config)
210210
if err != nil {
211211
return nil, err
212212
}

common/configtx/manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func makeConfigItem(id, modificationPolicy string, lastModified uint64, data []b
7777

7878
func makeMarshaledConfig(chainID string, configItems ...*cb.ConfigItem) []byte {
7979
config := &cb.Config{
80-
Header: &cb.ChainHeader{ChainID: chainID},
80+
Header: &cb.ChainHeader{ChannelId: chainID},
8181
Items: configItems,
8282
}
8383
return utils.MarshalOrPanic(config)

common/configtx/template.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ func (st *simpleTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error) {
9898

9999
marshaledConfig, err := proto.Marshal(&cb.ConfigNext{
100100
Header: &cb.ChainHeader{
101-
ChainID: chainID,
102-
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
101+
ChannelId: chainID,
102+
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
103103
},
104104
Channel: channel,
105105
})
@@ -173,8 +173,8 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error
173173

174174
marshaledConfig, err := proto.Marshal(&cb.ConfigNext{
175175
Header: &cb.ChainHeader{
176-
ChainID: chainID,
177-
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
176+
ChannelId: chainID,
177+
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
178178
},
179179
Channel: channel,
180180
})

common/configtx/test/msp.template

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ qp6CP8TFHZ9bw5nRtZxIEDAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxI
1515
EDAKBggqhkjOPQQDAgNHADBEAiAHp5Rbp9Em1G/UmKn8WsCbqDfWecVbZPQj3RK4
1616
oG5kQQIgQAe4OOKYhJdh3f7URaKfGTf492/nmRmtK+ySKjpHSrU=
1717
-----END CERTIFICATE-----
18-
�-----BEGIN CERTIFICATE-----
18+
"�-----BEGIN CERTIFICATE-----
1919
MIICYjCCAgmgAwIBAgIUB3CTDOU47sUC5K4kn/Caqnh114YwCgYIKoZIzj0EAwIw
2020
fzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh
2121
biBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAK
@@ -30,7 +30,7 @@ qp6CP8TFHZ9bw5nRtZxIEDAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxI
3030
EDAKBggqhkjOPQQDAgNHADBEAiAHp5Rbp9Em1G/UmKn8WsCbqDfWecVbZPQj3RK4
3131
oG5kQQIgQAe4OOKYhJdh3f7URaKfGTf492/nmRmtK+ySKjpHSrU=
3232
-----END CERTIFICATE-----
33-
*
33+
2
3434
�-----BEGIN CERTIFICATE-----
3535
MIICjDCCAjKgAwIBAgIUBEVwsSx0TmqdbzNwleNBBzoIT0wwCgYIKoZIzj0EAwIw
3636
fzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh

common/ledger/blkstorage/fsblkstorage/block_serialization.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,5 @@ func extractTxID(txEnvelopBytes []byte) (string, error) {
207207
if err != nil {
208208
return "", nil
209209
}
210-
return txPayload.Header.ChainHeader.TxID, nil
210+
return txPayload.Header.ChainHeader.TxId, nil
211211
}

core/chaincode/chaincode_support.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
482482
}
483483
}
484484
if cds != nil {
485-
cID = cds.ChaincodeSpec.ChaincodeID
485+
cID = cds.ChaincodeSpec.ChaincodeId
486486
cMsg = cds.ChaincodeSpec.Input
487487
cLang = cds.ChaincodeSpec.Type
488488
} else {
489-
cID = ci.ChaincodeSpec.ChaincodeID
489+
cID = ci.ChaincodeSpec.ChaincodeId
490490
cMsg = ci.ChaincodeSpec.Input
491491
}
492492

core/chaincode/chaincodeexec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
//create a chaincode invocation spec
3232
func createCIS(ccname string, args [][]byte) (*pb.ChaincodeInvocationSpec, error) {
3333
var err error
34-
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: ccname}, Input: &pb.ChaincodeInput{Args: args}}}
34+
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: ccname}, Input: &pb.ChaincodeInput{Args: args}}}
3535
if nil != err {
3636
return nil, err
3737
}

core/chaincode/concurrency_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
5252

5353
args := util.ToChaincodeArgs("init", "")
5454

55-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
55+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
5656

5757
cccid := ccprovider.NewCCContext(chainID, "nkpi", "0", "", false, nil)
5858

@@ -85,7 +85,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
8585
args = util.ToChaincodeArgs("get", newkey)
8686
}
8787

88-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
88+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
8989

9090
//start with a new background
9191
_, _, results[qnum], err = invoke(context.Background(), chainID, spec)

core/chaincode/exectransaction.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func Execute(ctxt context.Context, cccid *ccprovider.CCContext, spec interface{}
8585
}
8686

8787
if resp.ChaincodeEvent != nil {
88-
resp.ChaincodeEvent.ChaincodeID = cccid.Name
89-
resp.ChaincodeEvent.TxID = cccid.TxID
88+
resp.ChaincodeEvent.ChaincodeId = cccid.Name
89+
resp.ChaincodeEvent.TxId = cccid.TxID
9090
}
9191

9292
if resp.Type == pb.ChaincodeMessage_COMPLETED {

0 commit comments

Comments
 (0)