Skip to content

Commit 2d3d042

Browse files
ale-linuxyacovm
authored andcommitted
[FAB-11554] Remove deduplicateIdentity
The deduplicateIdentity function is no longer required given that the policy engine already deduplicates identities. Change-Id: I1e3ba1cf892db1d7ce1e028cd9fe4aca831345ff Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net> Signed-off-by: Matthias Neugschwandtner <eug@zurich.ibm.com>
1 parent 701cb44 commit 2d3d042

File tree

2 files changed

+10
-39
lines changed

2 files changed

+10
-39
lines changed

core/handlers/validation/builtin/1.3/lscc_validation_logic.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/hyperledger/fabric/core/scc/lscc"
2828
"github.com/hyperledger/fabric/protos/common"
2929
"github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset"
30-
"github.com/hyperledger/fabric/protos/msp"
3130
pb "github.com/hyperledger/fabric/protos/peer"
3231
"github.com/hyperledger/fabric/protos/utils"
3332
"github.com/pkg/errors"
@@ -619,41 +618,6 @@ func (vscc *Validator) getInstantiatedCC(chid, ccid string) (cd *ccprovider.Chai
619618
return
620619
}
621620

622-
func (vscc *Validator) deduplicateIdentity(cap *pb.ChaincodeActionPayload) ([]*common.SignedData, error) {
623-
// this is the first part of the signed message
624-
prespBytes := cap.Action.ProposalResponsePayload
625-
626-
// build the signature set for the evaluation
627-
signatureSet := []*common.SignedData{}
628-
signatureMap := make(map[string]struct{})
629-
// loop through each of the endorsements and build the signature set
630-
for _, endorsement := range cap.Action.Endorsements {
631-
//unmarshal endorser bytes
632-
serializedIdentity := &msp.SerializedIdentity{}
633-
if err := proto.Unmarshal(endorsement.Endorser, serializedIdentity); err != nil {
634-
logger.Errorf("Unmarshal endorser error: %s", err)
635-
return nil, policyErr(fmt.Errorf("Unmarshal endorser error: %s", err))
636-
}
637-
identity := serializedIdentity.Mspid + string(serializedIdentity.IdBytes)
638-
if _, ok := signatureMap[identity]; ok {
639-
// Endorsement with the same identity has already been added
640-
logger.Warningf("Ignoring duplicated identity, Mspid: %s, pem:\n%s", serializedIdentity.Mspid, serializedIdentity.IdBytes)
641-
continue
642-
}
643-
signatureSet = append(signatureSet, &common.SignedData{
644-
// set the data that is signed; concatenation of proposal response bytes and endorser ID
645-
Data: append(prespBytes, endorsement.Endorser...),
646-
// set the identity that signs the message: it's the endorser
647-
Identity: endorsement.Endorser,
648-
// set the signature
649-
Signature: endorsement.Signature})
650-
signatureMap[identity] = struct{}{}
651-
}
652-
653-
logger.Debugf("Signature set is of size %d out of %d endorsement(s)", len(signatureSet), len(cap.Action.Endorsements))
654-
return signatureSet, nil
655-
}
656-
657621
type state struct {
658622
State
659623
}

core/handlers/validation/builtin/1.3/validation_logic.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,16 @@ func (vscc *Validator) Validate(
104104
return policyErr(err)
105105
}
106106

107-
signatureSet, err := vscc.deduplicateIdentity(cap)
108-
if err != nil {
109-
return policyErr(err)
107+
// construct signature set
108+
signatureSet := []*common.SignedData{}
109+
for _, endorsement := range cap.Action.Endorsements {
110+
signatureSet = append(signatureSet, &common.SignedData{
111+
// set the data that is signed; concatenation of proposal response bytes and endorser ID
112+
Data: append(append([]byte{}, cap.Action.ProposalResponsePayload...), endorsement.Endorser...),
113+
// set the identity that signs the message: it's the endorser
114+
Identity: endorsement.Endorser,
115+
// set the signature
116+
Signature: endorsement.Signature})
110117
}
111118

112119
// evaluate the signature set against the policy

0 commit comments

Comments
 (0)