hacera / daml-on-fabric

HACERA's work with Digital Asset on enabling DAML applications to run on Hyperledger Fabric
Apache License 2.0
27 stars 5 forks source link

Chaincode provision deployment fails if fabric 2.0.0-beta or latest are used #17

Closed dasormeter closed 4 years ago

dasormeter commented 4 years ago

Problem

daml-on-fabric chaincode deployment fails if attempting to deploy to a fabric network running 2.0 or 2.0.0-beta

With Fabric main github repo moving to 2.0.0-beta, a number of go dependencies for chaincode that previously could be pulled from master are no longer in the github repo, leading to errors uploading that chaincode to new 2.0 versions. Namely, these are the shim, proto/peer and logging dependencies noted below in the release notes.

https://github.com/hyperledger/fabric/releases/tag/v2.0.0-beta

FAB-5177: The ccenv build image no longer includes the shim

The shim package and dependencies for go chaincode are no longer included in the chaincode build environment. Chaincode packages that do not include their own dependencies will no longer successfully build on the peer. We strongly recommend that existing go chaincode be updated to vendor the github.com/hyperledger/fabric-chaincode-go/shim package and its dependencies. While there are many tools for managing vendored dependencies, we recommend moving directly to go modules and vendoring with go mod vendor.

FAB-15366: Logger removed from chaincode shim

Chaincode that used the shim's NewLogger() will need to shift to a new logging mechanism. Chaincode logging is intended to be the responsibility of the application developer. As such it should be handled using tools and libraries that make the most sense to the chaincode developer and the application in general. Chaincode developers can forward STDOUT and STDERR from the chaincode container to the peer container by setting CORE_VM_DOCKER_ATTACHSTDOUT=true. While not recommended for production, once enabled, each chaincode will receive its own logging channel and STDOUT and STDERR will be integrated in the peers log on a per-line basis. A production grade approach would be to run a log aggregation service and forward your logs to the aggregation service.

Steps to reproduce

(in one terminal window) 1) go to root of directory where you have daml-on-fabric repo checked out 2) Open file .env in vim or your text edit of choice and change these two lines to version :2.0.0-beta https://github.com/hacera/daml-on-fabric/blob/6750ef7ca53b663ca4b030b38f657a2cf78e4d1b/.env#L1-L2 3) cd /src/test/fixture 4) Open file fabric.sh in vim or your text edit of choice and change these two lines to version :2.0.0-beta https://github.com/hacera/daml-on-fabric/blob/6750ef7ca53b663ca4b030b38f657a2cf78e4d1b/src/test/fixture/fabric.sh#L23-L24 5) ./restart_fabric.sh

(in another terminal window - this provisions the chaincode to the network) 6) sbt "run --port 6865 --role provision"

Error

Installing chaincode daml_on_fabric : version 1.4 [error] (run-main-0) com.hacera.FabricContextException: response { [error] status: 500 [error] message: "could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 \"/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:11:2: cannot find package \"github.com/hyperledger/fabric/core/chaincode/shim\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/core/chaincode/shim\n/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:12:2: cannot find package \"github.com/hyperledger/fabric/protos/peer\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/protos/peer\n\"" [error] } [error] payload: "\n f(FB\260\334\345\213D\336\244SF\330\265\344\336-;\205}\251\277\243\344\352p\001 \036\215\022\367\006\032\345\006\b\364\003\022\337\006could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 \"/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:11:2: cannot find package \"github.com/hyperledger/fabric/core/chaincode/shim\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/core/chaincode/shim\n/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:12:2: cannot find package \"github.com/hyperledger/fabric/protos/peer\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/protos/peer\n\"\"\r\022\004lscc\032\005syscc" [error] com.hacera.FabricContextException: response { [error] status: 500 [error] message: "could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 \"/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:11:2: cannot find package \"github.com/hyperledger/fabric/core/chaincode/shim\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/core/chaincode/shim\n/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:12:2: cannot find package \"github.com/hyperledger/fabric/protos/peer\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/protos/peer\n\"" [error] } [error] payload: "\n f(FB\260\334\345\213D\336\244SF\330\265\344\336-;\205}\251\277\243\344\352p\001 \036\215\022\367\006\032\345\006\b\364\003\022\337\006could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 \"/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:11:2: cannot find package \"github.com/hyperledger/fabric/core/chaincode/shim\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/core/chaincode/shim\n/chaincode/input/src/github.com/daml_on_fabric/daml_on_fabric.go:12:2: cannot find package \"github.com/hyperledger/fabric/protos/peer\" in any of:\n\t/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)\n\t/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)\n\t/go/src/github.com/hyperledger/fabric/protos/peer\n\"\"\r\022\004lscc\032\005syscc" [error] [error] at com.hacera.FabricContext.ensureChaincode(FabricContext.java:618) [error] at com.hacera.DAMLKVConnector.(DAMLKVConnector.java:71) [error] at com.hacera.DAMLKVConnector.get(DAMLKVConnector.java:26) [error] at com.hacera.ExampleDamlOnFabricServer$.delayedEndpoint$com$hacera$ExampleDamlOnFabricServer$1(ExampleDamlOnFabricServer.scala:46) [error] at com.hacera.ExampleDamlOnFabricServer$delayedInit$body.apply(ExampleDamlOnFabricServer.scala:33) [error] at scala.Function0.apply$mcV$sp(Function0.scala:39) [error] at scala.Function0.apply$mcV$sp$(Function0.scala:39) [error] at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17) [error] at scala.App.$anonfun$main$1$adapted(App.scala:80) [error] at scala.collection.immutable.List.foreach(List.scala:392) [error] at scala.App.main(App.scala:80) [error] at scala.App.main$(App.scala:78) [error] at com.hacera.ExampleDamlOnFabricServer$.main(ExampleDamlOnFabricServer.scala:33) [error] at com.hacera.ExampleDamlOnFabricServer.main(ExampleDamlOnFabricServer.scala) [error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [error] at java.base/java.lang.reflect.Method.invoke(Method.java:566) [error] Nonzero exit code: 1 [error] (Compile / run) Nonzero exit code: 1 [error] Total time: 17 s, completed Jan 15, 2020, 10:47:29 PM