Skip to content

Commit 77cabfc

Browse files
committed
FAB-186 Implementation of Endorser and ESCC logic
https://jira.hyperledger.org/browse/FAB-186 This push-request implements the endorser and ESCC logic that are exercised when a proposal is received by the peer. There are still a few missing pieces, namely signature generation and verification, verification of the validity of the signing certificate and replay attack protection. They will be added as soon as COP/BCSSP interfaces are ready. Change-Id: I35ecd3306605aca6c93399363648d228f397896a Signed-off-by: Alessandro Sorniotti <[email protected]>
1 parent d221a6b commit 77cabfc

17 files changed

+887
-141
lines changed

bddtests/chaincode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func createPropsalID() string {
3939
}
4040

4141
// createChaincodeDeploymentSpec Returns a deployment proposal of chaincode type
42-
func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec) (proposal *pb.Proposal, err error) {
42+
func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec, creator []byte) (proposal *pb.Proposal, err error) {
4343
var ccDeploymentSpecBytes []byte
4444
if ccDeploymentSpecBytes, err = proto.Marshal(ccChaincodeDeploymentSpec); err != nil {
4545
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
@@ -49,5 +49,5 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
4949
CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
5050
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
5151
// make proposal
52-
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec)
52+
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec, creator)
5353
}

bddtests/endorser_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func (b *BDDContext) userCreatesADeploymentProposalUsingChaincodeDeploymentSpec(
9494
return errRetFunc()
9595
}
9696
var proposal *pb.Proposal
97-
if proposal, err = createProposalForChaincode(ccDeploymentSpec); err != nil {
97+
// TODO: how should we get a cert from the command line?
98+
if proposal, err = createProposalForChaincode(ccDeploymentSpec, []byte("cert")); err != nil {
9899

99100
}
100101
if _, err = userRegistration.SetTagValue(proposalAlias, proposal); err != nil {

core/chaincode/chaincode_support.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb.
521521
var depPayload []byte
522522

523523
//hopefully we are restarting from existing image and the deployed transaction exists
524-
depPayload, err = getCDSFromLCCC(context, string(DefaultChain), chaincode)
524+
depPayload, err = GetCDSFromLCCC(context, string(DefaultChain), chaincode)
525525
if err != nil {
526526
return cID, cMsg, fmt.Errorf("Could not get deployment transaction from LCCC for %s - %s", chaincode, err)
527527
}

core/chaincode/chaincodeexec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func createTx(typ pb.Transaction_Type, ccname string, args [][]byte) (*pb.Transa
3838
return tx, nil
3939
}
4040

41-
func getCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) {
41+
func GetCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) {
4242
payload, _, err := ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)})
4343
return payload, err
4444
}

core/endorser/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func SetupTestConfig() {
5757
viper.AutomaticEnv()
5858
replacer := strings.NewReplacer(".", "_")
5959
viper.SetEnvKeyReplacer(replacer)
60-
viper.SetConfigName("endorser") // name of config file (without extension)
61-
viper.AddConfigPath("./") // path to look for the config file in
62-
err := viper.ReadInConfig() // Find and read the config file
63-
if err != nil { // Handle errors reading the config file
60+
viper.SetConfigName("endorser_test") // name of config file (without extension)
61+
viper.AddConfigPath("./") // path to look for the config file in
62+
err := viper.ReadInConfig() // Find and read the config file
63+
if err != nil { // Handle errors reading the config file
6464
panic(fmt.Errorf("Fatal error config file: %s \n", err))
6565
}
6666

0 commit comments

Comments
 (0)