Skip to content

Commit

Permalink
FAB-186 Implementation of Endorser and ESCC logic
Browse files Browse the repository at this point in the history
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 <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Nov 9, 2016
1 parent d221a6b commit 77cabfc
Show file tree
Hide file tree
Showing 17 changed files with 887 additions and 141 deletions.
4 changes: 2 additions & 2 deletions bddtests/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func createPropsalID() string {
}

// createChaincodeDeploymentSpec Returns a deployment proposal of chaincode type
func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec) (proposal *pb.Proposal, err error) {
func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymentSpec, creator []byte) (proposal *pb.Proposal, err error) {
var ccDeploymentSpecBytes []byte
if ccDeploymentSpecBytes, err = proto.Marshal(ccChaincodeDeploymentSpec); err != nil {
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
Expand All @@ -49,5 +49,5 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
// make proposal
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec)
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec, creator)
}
3 changes: 2 additions & 1 deletion bddtests/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (b *BDDContext) userCreatesADeploymentProposalUsingChaincodeDeploymentSpec(
return errRetFunc()
}
var proposal *pb.Proposal
if proposal, err = createProposalForChaincode(ccDeploymentSpec); err != nil {
// TODO: how should we get a cert from the command line?
if proposal, err = createProposalForChaincode(ccDeploymentSpec, []byte("cert")); err != nil {

}
if _, err = userRegistration.SetTagValue(proposalAlias, proposal); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb.
var depPayload []byte

//hopefully we are restarting from existing image and the deployed transaction exists
depPayload, err = getCDSFromLCCC(context, string(DefaultChain), chaincode)
depPayload, err = GetCDSFromLCCC(context, string(DefaultChain), chaincode)
if err != nil {
return cID, cMsg, fmt.Errorf("Could not get deployment transaction from LCCC for %s - %s", chaincode, err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/chaincode/chaincodeexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func createTx(typ pb.Transaction_Type, ccname string, args [][]byte) (*pb.Transa
return tx, nil
}

func getCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) {
func GetCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) {
payload, _, err := ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)})
return payload, err
}
Expand Down
8 changes: 4 additions & 4 deletions core/endorser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func SetupTestConfig() {
viper.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
viper.SetConfigName("endorser") // name of config file (without extension)
viper.AddConfigPath("./") // path to look for the config file in
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
viper.SetConfigName("endorser_test") // name of config file (without extension)
viper.AddConfigPath("./") // path to look for the config file in
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}

Expand Down
Loading

0 comments on commit 77cabfc

Please sign in to comment.