Skip to content

Commit

Permalink
[FAB-11554] Remove deduplicateIdentity
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ale-linux authored and yacovm committed Aug 23, 2018
1 parent 701cb44 commit 2d3d042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
36 changes: 0 additions & 36 deletions core/handlers/validation/builtin/1.3/lscc_validation_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
13 changes: 10 additions & 3 deletions core/handlers/validation/builtin/1.3/validation_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d3d042

Please sign in to comment.