Skip to content

Commit df2dad9

Browse files
authored
smartbft config verifier import names (#5215)
Signed-off-by: Hagar Meir <[email protected]>
1 parent 44aec11 commit df2dad9

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

orderer/consensus/smartbft/configverifier.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"fmt"
1111

1212
"github.com/hyperledger/fabric-lib-go/common/flogging"
13-
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
14-
mspa "github.com/hyperledger/fabric-protos-go-apiv2/msp"
13+
"github.com/hyperledger/fabric-protos-go-apiv2/common"
14+
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
1515
protosorderer "github.com/hyperledger/fabric-protos-go-apiv2/orderer"
1616
"github.com/hyperledger/fabric-protos-go-apiv2/orderer/smartbft"
1717
"github.com/hyperledger/fabric/common/channelconfig"
@@ -27,14 +27,14 @@ import (
2727

2828
// Filters applies the filters on the outer envelope
2929
type Filters interface {
30-
ApplyFilters(channel string, env *cb.Envelope) error
30+
ApplyFilters(channel string, env *common.Envelope) error
3131
}
3232

3333
//go:generate mockery -dir . -name ConfigUpdateProposer -case underscore -output mocks
3434

3535
// ConfigUpdateProposer produces a ConfigEnvelope
3636
type ConfigUpdateProposer interface {
37-
ProposeConfigUpdate(channel string, configtx *cb.Envelope) (*cb.ConfigEnvelope, error)
37+
ProposeConfigUpdate(channel string, configtx *common.Envelope) (*common.ConfigEnvelope, error)
3838
}
3939

4040
//go:generate mockery -dir . -name Bundle -case underscore -output mocks
@@ -60,7 +60,7 @@ type ConfigBlockValidator struct {
6060
}
6161

6262
// ValidateConfig validates config from envelope
63-
func (cbv *ConfigBlockValidator) ValidateConfig(envelope *cb.Envelope) error {
63+
func (cbv *ConfigBlockValidator) ValidateConfig(envelope *common.Envelope) error {
6464
payload, err := protoutil.UnmarshalPayload(envelope.Payload)
6565
if err != nil {
6666
return err
@@ -80,18 +80,18 @@ func (cbv *ConfigBlockValidator) ValidateConfig(envelope *cb.Envelope) error {
8080
}
8181

8282
switch chdr.Type {
83-
case int32(cb.HeaderType_CONFIG):
84-
configEnvelope := &cb.ConfigEnvelope{}
83+
case int32(common.HeaderType_CONFIG):
84+
configEnvelope := &common.ConfigEnvelope{}
8585
if err = proto.Unmarshal(payload.Data, configEnvelope); err != nil {
8686
return fmt.Errorf("data unmarshalling error: %s", err)
8787
}
8888
return cbv.verifyConfigUpdateMsg(envelope, configEnvelope, chdr)
8989
default:
90-
return errors.Errorf("unexpected envelope type %s", cb.HeaderType_name[chdr.Type])
90+
return errors.Errorf("unexpected envelope type %s", common.HeaderType_name[chdr.Type])
9191
}
9292
}
9393

94-
func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) error {
94+
func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *common.Config) error {
9595
if conf == nil {
9696
return fmt.Errorf("empty Config")
9797
}
@@ -116,39 +116,39 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
116116
return fmt.Errorf("no values in 'Orderer' group")
117117
}
118118

119-
ords := &cb.Orderers{}
119+
ords := &common.Orderers{}
120120
if err := proto.Unmarshal(conf.ChannelGroup.Groups["Orderer"].Values["Orderers"].Value, ords); err != nil {
121121
return err
122122
}
123123

124124
n := len(ords.ConsenterMapping)
125125
f := (n - 1) / 3
126126

127-
var identities []*mspa.MSPPrincipal
128-
var pols []*cb.SignaturePolicy
127+
var identities []*msp.MSPPrincipal
128+
var pols []*common.SignaturePolicy
129129
for i, consenter := range ords.ConsenterMapping {
130130
if consenter == nil {
131131
return fmt.Errorf("consenter %d in the mapping is empty", i)
132132
}
133-
pols = append(pols, &cb.SignaturePolicy{
134-
Type: &cb.SignaturePolicy_SignedBy{
133+
pols = append(pols, &common.SignaturePolicy{
134+
Type: &common.SignaturePolicy_SignedBy{
135135
SignedBy: int32(i),
136136
},
137137
})
138-
identities = append(identities, &mspa.MSPPrincipal{
139-
PrincipalClassification: mspa.MSPPrincipal_IDENTITY,
140-
Principal: protoutil.MarshalOrPanic(&mspa.SerializedIdentity{Mspid: consenter.MspId, IdBytes: consenter.Identity}),
138+
identities = append(identities, &msp.MSPPrincipal{
139+
PrincipalClassification: msp.MSPPrincipal_IDENTITY,
140+
Principal: protoutil.MarshalOrPanic(&msp.SerializedIdentity{Mspid: consenter.MspId, IdBytes: consenter.Identity}),
141141
})
142142
}
143143

144144
quorumSize := policies.ComputeBFTQuorum(n, f)
145-
sp := &cb.SignaturePolicyEnvelope{
145+
sp := &common.SignaturePolicyEnvelope{
146146
Rule: policydsl.NOutOf(int32(quorumSize), pols),
147147
Identities: identities,
148148
}
149149

150-
expectedConfigPol := &cb.Policy{
151-
Type: int32(cb.Policy_SIGNATURE),
150+
expectedConfigPol := &common.Policy{
151+
Type: int32(common.Policy_SIGNATURE),
152152
Value: protoutil.MarshalOrPanic(sp),
153153
}
154154

@@ -189,7 +189,7 @@ func (cbv *ConfigBlockValidator) checkConsentersMatchPolicy(conf *cb.Config) err
189189
return nil
190190
}
191191

192-
func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *cb.Envelope, confEnv *cb.ConfigEnvelope, chdr *cb.ChannelHeader) error {
192+
func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *common.Envelope, confEnv *common.ConfigEnvelope, chdr *common.ChannelHeader) error {
193193
if confEnv == nil || confEnv.LastUpdate == nil || confEnv.Config == nil {
194194
return errors.New("invalid config envelope")
195195
}
@@ -206,7 +206,7 @@ func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *cb.Envelope, conf
206206
return errors.New("inner channelheader is nil")
207207
}
208208

209-
typ := cb.HeaderType(chdr.Type)
209+
typ := common.HeaderType(chdr.Type)
210210

211211
cbv.Logger.Infof("Applying filters for config update of type %s to channel %s", typ, chdr.ChannelId)
212212

@@ -215,7 +215,7 @@ func (cbv *ConfigBlockValidator) verifyConfigUpdateMsg(outEnv *cb.Envelope, conf
215215
return err
216216
}
217217

218-
var expectedConfigEnv *cb.ConfigEnvelope
218+
var expectedConfigEnv *common.ConfigEnvelope
219219
channelID, err := protoutil.ChannelID(confEnv.LastUpdate)
220220
if err != nil {
221221
return errors.Errorf("error extracting channel ID from config update")

0 commit comments

Comments
 (0)