Commit 2d3d042f authored by Alessandro Sorniotti's avatar Alessandro Sorniotti Committed by Yacov Manevich
Browse files

[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: default avatarAlessandro Sorniotti <ale.linux@sopit.net>
Signed-off-by: default avatarMatthias Neugschwandtner <eug@zurich.ibm.com>
parent 701cb44d
......@@ -27,7 +27,6 @@ import (
"github.com/hyperledger/fabric/core/scc/lscc"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset"
"github.com/hyperledger/fabric/protos/msp"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric/protos/utils"
"github.com/pkg/errors"
......@@ -619,41 +618,6 @@ func (vscc *Validator) getInstantiatedCC(chid, ccid string) (cd *ccprovider.Chai
return
}
func (vscc *Validator) deduplicateIdentity(cap *pb.ChaincodeActionPayload) ([]*common.SignedData, error) {
// this is the first part of the signed message
prespBytes := cap.Action.ProposalResponsePayload
// build the signature set for the evaluation
signatureSet := []*common.SignedData{}
signatureMap := make(map[string]struct{})
// loop through each of the endorsements and build the signature set
for _, endorsement := range cap.Action.Endorsements {
//unmarshal endorser bytes
serializedIdentity := &msp.SerializedIdentity{}
if err := proto.Unmarshal(endorsement.Endorser, serializedIdentity); err != nil {
logger.Errorf("Unmarshal endorser error: %s", err)
return nil, policyErr(fmt.Errorf("Unmarshal endorser error: %s", err))
}
identity := serializedIdentity.Mspid + string(serializedIdentity.IdBytes)
if _, ok := signatureMap[identity]; ok {
// Endorsement with the same identity has already been added
logger.Warningf("Ignoring duplicated identity, Mspid: %s, pem:\n%s", serializedIdentity.Mspid, serializedIdentity.IdBytes)
continue
}
signatureSet = append(signatureSet, &common.SignedData{
// set the data that is signed; concatenation of proposal response bytes and endorser ID
Data: append(prespBytes, endorsement.Endorser...),
// set the identity that signs the message: it's the endorser
Identity: endorsement.Endorser,
// set the signature
Signature: endorsement.Signature})
signatureMap[identity] = struct{}{}
}
logger.Debugf("Signature set is of size %d out of %d endorsement(s)", len(signatureSet), len(cap.Action.Endorsements))
return signatureSet, nil
}
type state struct {
State
}
......
......@@ -104,9 +104,16 @@ func (vscc *Validator) Validate(
return policyErr(err)
}
signatureSet, err := vscc.deduplicateIdentity(cap)
if err != nil {
return policyErr(err)
// construct signature set
signatureSet := []*common.SignedData{}
for _, endorsement := range cap.Action.Endorsements {
signatureSet = append(signatureSet, &common.SignedData{
// set the data that is signed; concatenation of proposal response bytes and endorser ID
Data: append(append([]byte{}, cap.Action.ProposalResponsePayload...), endorsement.Endorser...),
// set the identity that signs the message: it's the endorser
Identity: endorsement.Endorser,
// set the signature
Signature: endorsement.Signature})
}
// evaluate the signature set against the policy
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment