Commit 0370ada6 authored by Gregory Haskins's avatar Gregory Haskins
Browse files

Revert "Merge "Fix FAB-578" into v0.6"

This reverts commit 562a35fd, reversing
changes made to 4a78b412.  This was
done because we inadvertently merged a good chunk of master when
patch a96b9edc was submitted to the v0.6 branch.  We will
cherry-pick a96b9edc

 in a later patch to restore the fix
in the proper way.

Change-Id: Ib16c0220e65697a68a5140960b82780c175d9fa2
Signed-off-by: default avatarGreg Haskins <gregory.haskins@gmail.com>
parent 7e20032b
......@@ -26,8 +26,3 @@ go-carpet-coverage*
# make node-sdk copied files
sdk/node/lib/protos/*
report.xml
.settings
.project
.gradle
build/
bin/
......@@ -37,7 +37,7 @@
# - dist-clean - superset of 'clean' that also removes persistent state
PROJECT_NAME = hyperledger/fabric
BASE_VERSION = 0.7.0
BASE_VERSION = 0.6.1-preview
IS_RELEASE = false
ifneq ($(IS_RELEASE),true)
......@@ -47,16 +47,13 @@ else
PROJECT_VERSION=$(BASE_VERSION)
endif
DOCKER_TAG=$(shell uname -m)-$(PROJECT_VERSION)
PKGNAME = github.com/$(PROJECT_NAME)
GO_LDFLAGS = -X github.com/hyperledger/fabric/metadata.Version=$(PROJECT_VERSION)
CGO_FLAGS = CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy"
UID = $(shell id -u)
ARCH=$(shell uname -m)
CHAINTOOL_RELEASE=v0.9.1
BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release)
DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE)
EXECUTABLES = go docker git curl
K := $(foreach exec,$(EXECUTABLES),\
......@@ -66,9 +63,13 @@ K := $(foreach exec,$(EXECUTABLES),\
SUBDIRS = gotools sdk/node
SUBDIRS:=$(strip $(SUBDIRS))
# Make our baseimage depend on any changes to images/base or scripts/provision
BASEIMAGE_RELEASE = $(shell cat ./images/base/release)
BASEIMAGE_DEPS = $(shell git ls-files images/base scripts/provision)
JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
PROJECT_FILES = $(shell git ls-files)
IMAGES = src ccenv peer membersrvc javaenv
IMAGES = base src ccenv peer membersrvc javaenv
all: peer membersrvc checks
......@@ -121,14 +122,14 @@ linter: gotools
# we may later inject the binary into a different docker environment
# This is necessary since we cannot guarantee that binaries built
# on the host natively will be compatible with the docker env.
%/bin/protoc-gen-go: Makefile
%/bin/protoc-gen-go: build/image/base/.dummy Makefile
@echo "Building $@"
@mkdir -p $(@D)
@docker run -i \
--user=$(UID) \
-v $(abspath vendor/github.com/golang/protobuf):/opt/gopath/src/github.com/golang/protobuf \
-v $(abspath $(@D)):/opt/gopath/bin \
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) go install github.com/golang/protobuf/protoc-gen-go
hyperledger/fabric-baseimage go install github.com/golang/protobuf/protoc-gen-go
build/bin/chaintool: Makefile
@echo "Installing chaintool"
......@@ -171,19 +172,25 @@ build/bin/block-listener:
@echo "Binary available as $@"
@touch $@
build/bin/%: $(PROJECT_FILES)
build/bin/%: build/image/base/.dummy $(PROJECT_FILES)
@mkdir -p $(@D)
@echo "$@"
$(CGO_FLAGS) GOBIN=$(abspath $(@D)) go install -ldflags "$(GO_LDFLAGS)" $(PKGNAME)/$(@F)
@echo "Binary available as $@"
@touch $@
# Special override for base-image.
build/image/base/.dummy: $(BASEIMAGE_DEPS)
@echo "Building docker base-image"
@mkdir -p $(@D)
@./scripts/provision/docker.sh $(BASEIMAGE_RELEASE)
@touch $@
# Special override for src-image
build/image/src/.dummy: $(PROJECT_FILES)
build/image/src/.dummy: build/image/base/.dummy $(PROJECT_FILES)
@echo "Building docker src-image"
@mkdir -p $(@D)
@cat images/src/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
@git ls-files | tar -jcT - > $(@D)/gopath.tar.bz2
......@@ -195,7 +202,6 @@ build/image/src/.dummy: $(PROJECT_FILES)
build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-gen-go build/image/ccenv/bin/chaintool Makefile
@echo "Building docker ccenv-image"
@cat images/ccenv/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
docker build -t $(PROJECT_NAME)-ccenv $(@D)
......@@ -210,10 +216,7 @@ build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-ge
build/image/javaenv/.dummy: Makefile $(JAVASHIM_DEPS)
@echo "Building docker javaenv-image"
@mkdir -p $(@D)
@cat images/javaenv/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
@cat images/javaenv/Dockerfile.in > $(@D)/Dockerfile
@git ls-files core/chaincode/shim/java | tar -jcT - > $(@D)/javashimsrc.tar.bz2
@git ls-files protos core/chaincode/shim/table.proto settings.gradle | tar -jcT - > $(@D)/protos.tar.bz2
docker build -t $(PROJECT_NAME)-javaenv $(@D)
......@@ -226,7 +229,6 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
@echo "Building docker $(TARGET)-image"
@mkdir -p $(@D)/bin
@cat images/app/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
cp build/docker/bin/$(TARGET) $(@D)/bin
......@@ -238,6 +240,10 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
protos: gotools
./devenv/compile_protos.sh
base-image-clean:
-docker rmi -f $(PROJECT_NAME)-baseimage
-@rm -rf build/image/base ||:
src-image-clean: ccenv-image-clean peer-image-clean membersrvc-image-clean
%-image-clean:
......
......@@ -25,7 +25,6 @@ import (
"time"
"github.com/golang/protobuf/proto"
logging "github.com/op/go-logging"
"github.com/spf13/viper"
"golang.org/x/net/context"
......@@ -35,7 +34,6 @@ import (
"github.com/hyperledger/fabric/core/container/ccintf"
"github.com/hyperledger/fabric/core/crypto"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/flogging"
pb "github.com/hyperledger/fabric/protos"
)
......@@ -149,21 +147,6 @@ func NewChaincodeSupport(chainname ChainName, getPeerEndpoint func() (*pb.PeerEn
s.keepalive = time.Duration(t) * time.Second
}
viper.SetEnvPrefix("CORE")
viper.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
chaincodeLogLevelString := viper.GetString("logging.chaincode")
chaincodeLogLevel, err := logging.LogLevel(chaincodeLogLevelString)
if err == nil {
s.chaincodeLogLevel = chaincodeLogLevel.String()
} else {
chaincodeLogger.Infof("chaincode logging level %s is invalid. defaulting to %s\n", chaincodeLogLevelString, flogging.DefaultLoggingLevel().String())
s.chaincodeLogLevel = flogging.DefaultLoggingLevel().String()
}
return s
}
......@@ -189,7 +172,6 @@ type ChaincodeSupport struct {
peerTLSKeyFile string
peerTLSSvrHostOrd string
keepalive time.Duration
chaincodeLogLevel string
}
// DuplicateChaincodeHandlerError returned if attempt to register same chaincodeID while a stream already exists.
......@@ -308,11 +290,6 @@ func (chaincodeSupport *ChaincodeSupport) getArgsAndEnv(cID *pb.ChaincodeID, cLa
} else {
envs = append(envs, "CORE_PEER_TLS_ENABLED=false")
}
if chaincodeSupport.chaincodeLogLevel != "" {
envs = append(envs, "CORE_LOGGING_CHAINCODE="+chaincodeSupport.chaincodeLogLevel)
}
switch cLang {
case pb.ChaincodeSpec_GOLANG, pb.ChaincodeSpec_CAR:
//chaincode executable will be same as the name of the chaincode
......
......@@ -165,6 +165,15 @@ peer:
# networkId: test
networkId: dev
Dockerfile: |
from hyperledger/fabric-baseimage:latest
# Copy GOPATH src and install Peer
COPY src $GOPATH/src
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
# The Address this Peer will listen on
listenAddress: 0.0.0.0:21212
# The Address this Peer will bind to for providing services
......@@ -354,16 +363,17 @@ chaincode:
# This is the basis for the Golang Dockerfile. Additional commands will
# be appended depedendent upon the chaincode specification.
Dockerfile: |
FROM hyperledger/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION)
COPY src $GOPATH/src
WORKDIR $GOPATH
from hyperledger/fabric-baseimage
#from utxo:0.1.0
COPY src $GOPATH/src
WORKDIR $GOPATH
car:
# This is the basis for the CAR Dockerfile. Additional commands will
# be appended depedendent upon the chaincode specification.
Dockerfile: |
FROM hyperledger/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION)
FROM hyperledger/fabric-baseimage
# timeout in millisecs for starting up a container and waiting for Register
# to come through. 1sec should be plenty for chaincode unit tests
......
......@@ -827,18 +827,6 @@ func TestChaincodeInvokeChaincode(t *testing.T) {
go grpcServer.Serve(lis)
err = chaincodeInvokeChaincode(t, "")
if err != nil {
t.Fail()
t.Logf("Failed chaincode invoke chaincode : %s", err)
closeListenerAndSleep(lis)
return
}
closeListenerAndSleep(lis)
}
func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
var ctxt = context.Background()
// Deploy first chaincode
......@@ -848,7 +836,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}
_, err = deploy(ctxt, spec1)
chaincodeID1 := spec1.ChaincodeID.Name
......@@ -856,6 +844,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID1, err)
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
closeListenerAndSleep(lis)
return
}
......@@ -870,7 +859,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
f = "init"
args = util.ToChaincodeArgs(f, "e", "0")
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
_, err = deploy(ctxt, spec2)
chaincodeID2 := spec2.ChaincodeID.Name
......@@ -879,6 +868,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
t.Logf("Error initializing chaincode %s(%s)", chaincodeID2, err)
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2})
closeListenerAndSleep(lis)
return
}
......@@ -888,7 +878,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
f = "invoke"
args = util.ToChaincodeArgs(f, "e", "1")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
var uuid string
_, uuid, _, err = invoke(ctxt, spec2, pb.Transaction_CHAINCODE_INVOKE)
......@@ -898,6 +888,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
t.Logf("Error invoking <%s>: %s", chaincodeID2, err)
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2})
closeListenerAndSleep(lis)
return
}
......@@ -908,67 +899,13 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
t.Logf("Incorrect final state after transaction for <%s>: %s", chaincodeID1, err)
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2})
closeListenerAndSleep(lis)
return
}
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
GetChain(DefaultChain).Stop(ctxt, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2})
return
}
func TestChaincodeInvokeChaincodeWithSec(t *testing.T) {
testDBWrapper.CleanDB(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
}
time.Sleep(2 * time.Second)
var peerLis net.Listener
if peerLis, err = initPeer(); err != nil {
finitMemSrvc(memSrvcLis)
t.Fail()
t.Logf("Error registering user %s", err)
return
}
if err = crypto.RegisterClient("jim", nil, "jim", "6avZQLwcUe9b"); err != nil {
finitMemSrvc(memSrvcLis)
finitPeer(peerLis)
t.Fail()
t.Logf("Error registering user %s", err)
return
}
//login as jim and test chaincode-chaincode interaction with security
if err = chaincodeInvokeChaincode(t, "jim"); err != nil {
finitMemSrvc(memSrvcLis)
finitPeer(peerLis)
t.Fail()
t.Logf("Error executing test %s", err)
return
}
//cleanup
finitMemSrvc(memSrvcLis)
finitPeer(peerLis)
closeListenerAndSleep(lis)
}
// Test the execution of a chaincode that invokes another chaincode with wrong parameters. Should receive error from
......
......@@ -161,9 +161,9 @@ func (handler *Handler) deleteRangeQueryIterator(txContext *transactionContext,
delete(txContext.rangeQueryIteratorMap, txid)
}
//THIS CAN BE REMOVED ONCE WE FULL SUPPORT (Invoke and Query) CONFIDENTIALITY WITH CC-CALLING-CC
//Only invocation are allowed, not queries
func (handler *Handler) canCallChaincode(txid string, isQuery bool) *pb.ChaincodeMessage {
//THIS CAN BE REMOVED ONCE WE SUPPORT CONFIDENTIALITY WITH CC-CALLING-CC
//we dissallow chaincode-chaincode interactions till confidentiality implications are understood
func (handler *Handler) canCallChaincode(txid string) *pb.ChaincodeMessage {
secHelper := handler.chaincodeSupport.getSecHelper()
if secHelper == nil {
return nil
......@@ -176,9 +176,7 @@ func (handler *Handler) canCallChaincode(txid string, isQuery bool) *pb.Chaincod
} else if txctx.transactionSecContext == nil {
errMsg = fmt.Sprintf("[%s]Error transaction context is nil while checking for confidentiality. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR)
} else if txctx.transactionSecContext.ConfidentialityLevel != pb.ConfidentialityLevel_PUBLIC {
if isQuery {
errMsg = fmt.Sprintf("[%s]Error chaincode-chaincode interactions not supported for with privacy enabled. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR)
}
errMsg = fmt.Sprintf("[%s]Error chaincode-chaincode interactions not supported for with privacy enabled. Sending %s", shorttxid(txid), pb.ChaincodeMessage_ERROR)
}
if errMsg != "" {
......@@ -211,12 +209,10 @@ func (handler *Handler) encryptOrDecrypt(encrypt bool, txid string, payload []by
var err error
if txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_DEPLOY {
if enc, err = secHelper.GetStateEncryptor(handler.deployTXSecContext, handler.deployTXSecContext); err != nil {
chaincodeLogger.Errorf("error getting crypto encryptor for deploy tx :%s", err)
return nil, fmt.Errorf("error getting crypto encryptor for deploy tx :%s", err)
}
} else if txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_INVOKE || txctx.transactionSecContext.Type == pb.Transaction_CHAINCODE_QUERY {
if enc, err = secHelper.GetStateEncryptor(handler.deployTXSecContext, txctx.transactionSecContext); err != nil {
chaincodeLogger.Errorf("error getting crypto encryptor %s", err)
return nil, fmt.Errorf("error getting crypto encryptor %s", err)
}
} else {
......@@ -1050,9 +1046,7 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) {
err = ledgerObj.DeleteState(chaincodeID, key)
} else if msg.Type.String() == pb.ChaincodeMessage_INVOKE_CHAINCODE.String() {
//check and prohibit C-call-C for CONFIDENTIAL txs
chaincodeLogger.Debugf("[%s] C-call-C", shorttxid(msg.Txid))
if triggerNextStateMsg = handler.canCallChaincode(msg.Txid, false); triggerNextStateMsg != nil {
if triggerNextStateMsg = handler.canCallChaincode(msg.Txid); triggerNextStateMsg != nil {
return
}
chaincodeSpec := &pb.ChaincodeSpec{}
......@@ -1066,21 +1060,12 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) {
// Get the chaincodeID to invoke
newChaincodeID := chaincodeSpec.ChaincodeID.Name
chaincodeLogger.Debugf("[%s] C-call-C %s", shorttxid(msg.Txid), newChaincodeID)
// Create the transaction object
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: chaincodeSpec}
transaction, _ := pb.NewChaincodeExecute(chaincodeInvocationSpec, msg.Txid, pb.Transaction_CHAINCODE_INVOKE)
tsc := handler.getTxContext(msg.Txid).transactionSecContext
transaction.Nonce = tsc.Nonce
transaction.ConfidentialityLevel = tsc.ConfidentialityLevel
transaction.ConfidentialityProtocolVersion = tsc.ConfidentialityProtocolVersion
transaction.Metadata = tsc.Metadata
transaction.Cert = tsc.Cert
// cd the new chaincode if not already running
// Launch the new chaincode if not already running
_, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(context.Background(), transaction)
if launchErr != nil {
payload := []byte(launchErr.Error())
......@@ -1232,7 +1217,7 @@ func (handler *Handler) initializeSecContext(tx, depTx *pb.Transaction) error {
return nil
}
func (handler *Handler) setChaincodeSecurityContext(tx, depTx *pb.Transaction, msg *pb.ChaincodeMessage) error {
func (handler *Handler) setChaincodeSecurityContext(tx *pb.Transaction, msg *pb.ChaincodeMessage) error {
chaincodeLogger.Debug("setting chaincode security context...")
if msg.SecurityContext == nil {
msg.SecurityContext = &pb.ChaincodeSecurityContext{}
......@@ -1263,13 +1248,6 @@ func (handler *Handler) setChaincodeSecurityContext(tx, depTx *pb.Transaction, m
return err
}
msg.SecurityContext.Payload = ctorMsgRaw
// TODO: add deploy metadata
if depTx != nil {
msg.SecurityContext.ParentMetadata = depTx.Metadata
} else {
msg.SecurityContext.ParentMetadata = handler.deployTXSecContext.Metadata
}
msg.SecurityContext.Payload = ctorMsgRaw
msg.SecurityContext.TxTimestamp = tx.Timestamp
}
......@@ -1311,7 +1289,7 @@ func (handler *Handler) initOrReady(txid string, initArgs [][]byte, tx *pb.Trans
}
//if security is disabled the context elements will just be nil
if err := handler.setChaincodeSecurityContext(tx, depTx, ccMsg); err != nil {
if err := handler.setChaincodeSecurityContext(tx, ccMsg); err != nil {
return nil, err
}
......@@ -1339,7 +1317,7 @@ func (handler *Handler) handleQueryChaincode(msg *pb.ChaincodeMessage) {
}()
//check and prohibit C-call-C for CONFIDENTIAL txs
if serialSendMsg = handler.canCallChaincode(msg.Txid, true); serialSendMsg != nil {
if serialSendMsg = handler.canCallChaincode(msg.Txid); serialSendMsg != nil {
return
}
......@@ -1359,16 +1337,6 @@ func (handler *Handler) handleQueryChaincode(msg *pb.ChaincodeMessage) {
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: chaincodeSpec}
transaction, _ := pb.NewChaincodeExecute(chaincodeInvocationSpec, msg.Txid, pb.Transaction_CHAINCODE_QUERY)
tsc := handler.getTxContext(msg.Txid).transactionSecContext
transaction.Nonce = tsc.Nonce
transaction.ConfidentialityLevel = tsc.ConfidentialityLevel
transaction.ConfidentialityProtocolVersion = tsc.ConfidentialityProtocolVersion
transaction.Metadata = tsc.Metadata
transaction.Cert = tsc.Cert
chaincodeLogger.Debugf("[%s]Invoking another chaincode", shorttxid(msg.Txid))
// Launch the new chaincode if not already running
_, chaincodeInput, launchErr := handler.chaincodeSupport.Launch(context.Background(), transaction)
if launchErr != nil {
......@@ -1498,7 +1466,7 @@ func (handler *Handler) sendExecuteMessage(msg *pb.ChaincodeMessage, tx *pb.Tran
}
//if security is disabled the context elements will just be nil
if err := handler.setChaincodeSecurityContext(tx, nil, msg); err != nil {
if err := handler.setChaincodeSecurityContext(tx, msg); err != nil {
return nil, err
}
......
......@@ -68,7 +68,10 @@ func Start(cc Chaincode) error {
backendFormatter := logging.NewBackendFormatter(backend, format)
logging.SetBackend(backendFormatter).SetLevel(logging.Level(shimLoggingLevel), "shim")
SetChaincodeLoggingLevel()
viper.SetEnvPrefix("CORE")
viper.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
flag.StringVar(&peerAddress, "peer.address", "", "peer address")
......@@ -102,31 +105,6 @@ func Start(cc Chaincode) error {
return err
}
// IsEnabledForLogLevel checks to see if the chaincodeLogger is enabled for a specific logging level
// used primarily for testing
func IsEnabledForLogLevel(logLevel string) bool {
lvl, _ := logging.LogLevel(logLevel)
return chaincodeLogger.IsEnabledFor(lvl)
}
// SetChaincodeLoggingLevel sets the chaincode logging level to the value
// of CORE_LOGGING_CHAINCODE set from core.yaml by chaincode_support.go
func SetChaincodeLoggingLevel() {
viper.SetEnvPrefix("CORE")
viper.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
viper.SetEnvKeyReplacer(replacer)
chaincodeLogLevelString := viper.GetString("logging.chaincode")
chaincodeLogLevel, err := LogLevel(chaincodeLogLevelString)
if err == nil {
SetLoggingLevel(chaincodeLogLevel)
} else {
chaincodeLogger.Infof("error with chaincode log level: %s level= %s\n", err, chaincodeLogLevelString)
}
}
// StartInProc is an entry point for system chaincodes bootstrap. It is not an
// API for chaincodes.
func StartInProc(env []string, args []string, cc Chaincode, recv <-chan *pb.ChaincodeMessage, send chan<- *pb.ChaincodeMessage) error {
......
......@@ -19,8 +19,6 @@ package shim
import (
"fmt"
"testing"
"github.com/spf13/viper"
)
func TestMockStateRangeQueryIterator(t *testing.T) {
......@@ -52,17 +50,3 @@ func TestMockStateRangeQueryIterator(t *testing.T) {
}
}
}
// TestSetChaincodeLoggingLevel uses the utlity function defined in chaincode.go to
// set the chaincodeLogger's logging level
func TestSetChaincodeLoggingLevel(t *testing.T) {
// set log level to a non-default level
testLogLevelString := "debug"
viper.Set("logging.chaincode", testLogLevelString)
SetChaincodeLoggingLevel()
if !IsEnabledForLogLevel(testLogLevelString) {
t.FailNow()
}
}
......@@ -45,6 +45,14 @@ peer:
# networkId: test
networkId: dev
Dockerfile: |
from hyperledger/fabric-baseimage
# Copy GOPATH src and install Peer
COPY src $GOPATH/src
RUN mkdir -p /var/hyperledger/db
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
# The Address this Peer will bind to for providing services
address: 0.0.0.0:7051
# Whether the Peer should programmatically determine the address to bind to. This case is useful for docker containers.
......@@ -178,9 +186,9 @@ chaincode:
# This is the basis for the Golang Dockerfile. Additional commands will be appended depedendent upon the chaincode specification.
Dockerfile: |
FROM hyperledger/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION)
COPY src $GOPATH/src
WORKDIR $GOPATH
from hyperledger/fabric-baseimage
COPY src $GOPATH/src
WORKDIR $GOPATH
#timeout for starting up a container and waiting for Register to come through
startuptimeout: 20000
......
......@@ -451,9 +451,15 @@
"type": "object",
"properties": {
"type": {
"type": "integer",
"default": 1,
"example": 1,
"type": "string",
"default": "GOLANG",
"example": "GOLANG",