Skip to content

Commit

Permalink
Remove code which uses membersrvcs package
Browse files Browse the repository at this point in the history
Membership services has been moved to it own
repository and we need to remove it from fabric
master.  This change set starts that process by
removing any code which interacted directly / indirectly
with the membersrvc package. This includes:
- removing a majority of core/crypto (FAB-934)
- removing security related code from the peer
  - peer
  - endorser
  - devops
  - rest
- removing security code from chaincode
- removed membersrvc from Makefile

Was going to break it into smaller tasks,
but turns out it is easier to do it this way

Fixes FAB-1001,FAB-1002,FAB-1003,FAB-1004,FAB-1005

Change-Id: I88f70d4d1bee87a241f74b2e9580e2b4d4e40a4d
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Nov 7, 2016
1 parent c28bd05 commit db7a41f
Show file tree
Hide file tree
Showing 79 changed files with 55 additions and 18,339 deletions.
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# - checks - runs all tests/checks
# - peer - builds the fabric peer binary
# - orderer - builds the fabric orderer binary
# - membersrvc - builds the membersrvc binary
# - unit-test - runs the go-test based unit tests
# - behave - runs the behave test
# - behave-deps - ensures pre-requisites are availble for running behave manually
Expand All @@ -31,7 +30,6 @@
# - images[-clean] - ensures all docker images are available[/cleaned]
# - peer-image[-clean] - ensures the peer-image is available[/cleaned] (for behave, etc)
# - orderer-image[-clean] - ensures the orderer-image is available[/cleaned] (for behave, etc)
# - membersrvc-image[-clean] - ensures the membersrvc-image is available[/cleaned] (for behave, etc)
# - protos - generate all protobuf artifacts based on .proto files
# - clean - cleans the build area
# - dist-clean - superset of 'clean' that also removes persistent state
Expand Down Expand Up @@ -69,17 +67,20 @@ SUBDIRS:=$(strip $(SUBDIRS))
GOSHIM_DEPS = $(shell ./scripts/goListFiles.sh github.com/hyperledger/fabric/core/chaincode/shim | sort | uniq)
JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
PROJECT_FILES = $(shell git ls-files)
IMAGES = src ccenv peer membersrvc javaenv orderer
IMAGES = src ccenv peer javaenv orderer


all: peer orderer membersrvc checks
all: peer orderer checks

checks: linter unit-test behave

.PHONY: $(SUBDIRS)
$(SUBDIRS):
cd $@ && $(MAKE)

membersrvc-image:
@echo "membersrvc has been removed from this build"

.PHONY: peer
peer: build/bin/peer
peer-image: build/image/peer/.dummy
Expand All @@ -88,10 +89,6 @@ peer-image: build/image/peer/.dummy
orderer: build/bin/orderer
orderer-image: build/image/orderer/.dummy

.PHONY: membersrvc
membersrvc: build/bin/membersrvc
membersrvc-image: build/image/membersrvc/.dummy

unit-test: peer-image gotools
@./scripts/goUnitTests.sh $(DOCKER_TAG) "$(GO_LDFLAGS)"

Expand All @@ -111,7 +108,6 @@ linter: gotools
go vet ./core/...
go vet ./events/...
go vet ./examples/...
go vet ./membersrvc/...
go vet ./peer/...
go vet ./protos/...
go vet ./orderer/...
Expand Down Expand Up @@ -144,7 +140,7 @@ build/bin/chaintool: Makefile
# JIRA FAB-243 - Mark build/docker/bin artifacts explicitly as secondary
# since they are never referred to directly. This prevents
# the makefile from deleting them inadvertently.
.SECONDARY: build/docker/bin/peer build/docker/bin/orderer build/docker/bin/membersrvc
.SECONDARY: build/docker/bin/peer build/docker/bin/orderer

# We (re)build a package within a docker context but persist the $GOPATH/pkg
# directory so that subsequent builds are faster
Expand Down Expand Up @@ -247,7 +243,7 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
protos: gotools
./devenv/compile_protos.sh

src-image-clean: ccenv-image-clean peer-image-clean orderer-image-clean membersrvc-image-clean
src-image-clean: ccenv-image-clean peer-image-clean orderer-image-clean

%-image-clean:
$(eval TARGET = ${patsubst %-image-clean,%,${@}})
Expand Down
146 changes: 17 additions & 129 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger"
"github.com/hyperledger/fabric/core/util"
"github.com/hyperledger/fabric/membersrvc/ca"
pb "github.com/hyperledger/fabric/protos"
putils "github.com/hyperledger/fabric/protos/utils"

Expand All @@ -53,42 +52,6 @@ func getNowMillis() int64 {
return nanos / 1000000
}

//initialize memberservices and startup
func initMemSrvc() (net.Listener, error) {
//start clean
finitMemSrvc(nil)

ca.CacheConfiguration() // Cache configuration

aca := ca.NewACA()
eca := ca.NewECA(aca)
tca := ca.NewTCA(eca)
tlsca := ca.NewTLSCA(eca)

sockp, err := net.Listen("tcp", viper.GetString("server.port"))
if err != nil {
return nil, err
}

var opts []grpc.ServerOption
server := grpc.NewServer(opts...)

aca.Start(server)
eca.Start(server)
tca.Start(server)
tlsca.Start(server)

go server.Serve(sockp)

return sockp, nil
}

//cleanup memberservice debris
func finitMemSrvc(lis net.Listener) {
closeListenerAndSleep(lis)
os.RemoveAll(filepath.Join(os.TempDir(), "ca"))
}

//initialize peer and start up. If security==enabled, login as vp
func initPeer() (net.Listener, error) {
//start clean
Expand Down Expand Up @@ -120,15 +83,7 @@ func initPeer() (net.Listener, error) {
// Install security object for peer
var secHelper crypto.Peer
if viper.GetBool("security.enabled") {
enrollID := viper.GetString("security.enrollID")
enrollSecret := viper.GetString("security.enrollSecret")
if err = crypto.RegisterValidator(enrollID, nil, enrollID, enrollSecret); nil != err {
return nil, err
}
secHelper, err = crypto.InitValidator(enrollID, nil)
if nil != err {
return nil, err
}
//TODO: Integrate new crypto / idp code
}

ccStartupTimeout := time.Duration(chaincodeStartupTimeoutDefault) * time.Millisecond
Expand Down Expand Up @@ -216,57 +171,31 @@ func getDeploymentSpec(context context.Context, spec *pb.ChaincodeSpec) (*pb.Cha
func createDeployTransaction(dspec *pb.ChaincodeDeploymentSpec, uuid string) (*pb.Transaction, error) {
var tx *pb.Transaction
var err error
var sec crypto.Client
if dspec.ChaincodeSpec.SecureContext != "" {
sec, err = crypto.InitClient(dspec.ChaincodeSpec.SecureContext, nil)
defer crypto.CloseClient(sec)

if nil != err {
return nil, err
}
//TODO: integrate new crypto / idp code if applicable

tx, err = sec.NewChaincodeDeployTransaction(dspec, uuid, attributes...)
if nil != err {
return nil, err
}
} else {
tx, err = pb.NewChaincodeDeployTransaction(dspec, uuid)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
tx, err = pb.NewChaincodeDeployTransaction(dspec, uuid)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s ", err)
}
return tx, nil
}

func createTransaction(invokeTx bool, spec *pb.ChaincodeInvocationSpec, uuid string) (*pb.Transaction, error) {
var tx *pb.Transaction
var err error
var sec crypto.Client
if nil != sec {
sec, err = crypto.InitClient(spec.ChaincodeSpec.SecureContext, nil)
defer crypto.CloseClient(sec)
if nil != err {
return nil, err
}
if invokeTx {
tx, err = sec.NewChaincodeExecute(spec, uuid, attributes...)
} else {
tx, err = sec.NewChaincodeQuery(spec, uuid, attributes...)
}
if nil != err {
return nil, err
}

//TODO: integrate new crypto / idp code if applicable

var t pb.Transaction_Type
if invokeTx {
t = pb.Transaction_CHAINCODE_INVOKE
} else {
var t pb.Transaction_Type
if invokeTx {
t = pb.Transaction_CHAINCODE_INVOKE
} else {
t = pb.Transaction_CHAINCODE_QUERY
}
tx, err = pb.NewChaincodeExecute(spec, uuid, t)
if nil != err {
return nil, err
}
t = pb.Transaction_CHAINCODE_QUERY
}
tx, err = pb.NewChaincodeExecute(spec, uuid, t)
if nil != err {
return nil, err
}
return tx, nil
}
Expand Down Expand Up @@ -1069,48 +998,7 @@ func TestChaincodeQueryChaincodeWithSec(t *testing.T) {

viper.Set("security.enabled", "true")

//Initialize crypto
if err := crypto.Init(); err != nil {
panic(fmt.Errorf("Failed initializing the crypto layer [%s]", err))
}

//set paths for memberservice to pick up
viper.Set("peer.fileSystemPath", filepath.Join(os.TempDir(), "hyperledger", "production"))
viper.Set("server.rootpath", filepath.Join(os.TempDir(), "ca"))

var err error
var memSrvcLis net.Listener
if memSrvcLis, err = initMemSrvc(); err != nil {
t.Fail()
t.Logf("Error registering user %s", err)
return
}

defer finitMemSrvc(memSrvcLis)

time.Sleep(2 * time.Second)

var peerLis net.Listener
if peerLis, err = initPeer(); err != nil {
t.Fail()
t.Logf("Error registering user %s", err)
return
}

defer finitPeer(peerLis)

if err = crypto.RegisterClient("jim", nil, "jim", "6avZQLwcUe9b"); err != nil {
t.Fail()
t.Logf("Error registering user %s", err)
return
}

//login as jim and test chaincode-chaincode interaction with security
if err = chaincodeQueryChaincode("jim"); err != nil {
t.Fail()
t.Logf("Error executing test %s", err)
return
}
//TODO: integrate new crypto / idp code if applicable
}

// Test the invocation of a transaction.
Expand Down
Loading

0 comments on commit db7a41f

Please sign in to comment.