Install fabric-chaincode-java to raspberry 4 #fabric-questions #fabric-chaincode


Nikos Karamolegkos
 

Hello, I would like to build latest version of hypeledger fabric into a raspberry 4 (using java). As I can see in the bash script used by curl here (latest installation) the versions that are used are:

  • fabric 2.3.1
  • fabric-ca 1.4.9
  • fabric-chaincode-java 2.3.1

Unfortunately, there are not pre-built images for all these repositories so I have to build them from source. In order to build fabric 2.3.1 I can make some changes to the Dockerfile (as in master branch i.e add binutils-gold) in order to support raspberry. Respectively, I can do the same for the fabric-ca 1.4.9. The real problem is the fabric-chaincode-java 2.3.0 (there is no 2.3.1 tag in github!!), I have the same problem as here so I try to follow the suggested instructions but I fail. Specifically, when I run ../gradlew java_pluginExecutable -PskipAndroid=true

I end up with a message:

....

/usr/bin/ld: /usr/local/lib/libprotoc.a(plugin.pb.o):(.data.rel.ro+0x0): undefined reference to `descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
collect2: error: ld returned 1 exit status
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-compiler:linkJava_pluginExecutable'.
> A build operation failed.
      Linker failed while linking protoc-gen-grpc-java.

Are they any instructions with the prerequisites in order to build it?  Note that there is a  pre-build image but for the version 2.2.0 so there is way to build it. Finally, I have not seen any information about the compatible versions of the different repositories, for example can I use fabric 2.3.1 with the 2.2 fabric-chaincode-java or I would have a version mismatch? Thus, which versions are compatible with each other?

Thanks,

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Matthew White
 

Hello;

- From the perspective of the peer/ca/orderer etc that are written in Go, I know that others have managed to recompile for ARM. Understand it's possible, but not sure how the performance is though.. though I believe the Pi4 probably has the processor power esp, if an external drive is used rather than SD storage.

- The docker image you mention is from one of those that I know has done the build; normally the prereqs don't need building - so I can't really give you any pointers there I'm afraid. 

- In terms of compatibility I refer you to https://github.com/hyperledger/fabric-chaincode-java/blob/master/COMPATIBILITY.md 

Briefly:
- There is the wire protocol between peer and chaincode. This is compatible across versions... 1.4 peer can talk to a 2.2 chaincode vice/versa subject to the request function actually being there.
- For running the chaincodes, the peer will spin up a docker container - this will have a certain runtime (java/node etc) within it.  Can this support the version of library you want to run?
- The docker images come with a pre-cached version of the language libraries; you can override these should you wish. 


- Last thought;; personally if possible I'd used the Nodejs v2.x contract API - it has no native dependencies and is pure JS code. It should be easier to run.

 

Matthew

 

 

 


Brett T Logan <development.brett@...>
 

Somewhere I have the instructions on how to build this, but the net-net is, the Java protobuf library doesnt have a native distribution for ARM. You need to clone the protobuf repo (which will also have a missing dependency that will require you to build it as well, though I can't remember off the top of my head which one), and you will need to build it, and deploy it to your local maven repo on your machine, so the chaincode-java build process can find these two dependencies prebuilt in your local maven repo.

I'll try to dig up the RocketChat post, or mailing list post where I gave detailed instructions on doing this, but it's been a while and I'm not confident I'll find it.

Brett Logan

On Thu, Feb 25, 2021, 03:44 Nikos Karamolegkos <nkaram@...> wrote:

Hello, I would like to build latest version of hypeledger fabric into a raspberry 4 (using java). As I can see in the bash script used by curl here (latest installation) the versions that are used are:

  • fabric 2.3.1
  • fabric-ca 1.4.9
  • fabric-chaincode-java 2.3.1

Unfortunately, there are not pre-built images for all these repositories so I have to build them from source. In order to build fabric 2.3.1 I can make some changes to the Dockerfile (as in master branch i.e add binutils-gold) in order to support raspberry. Respectively, I can do the same for the fabric-ca 1.4.9. The real problem is the fabric-chaincode-java 2.3.0 (there is no 2.3.1 tag in github!!), I have the same problem as here so I try to follow the suggested instructions but I fail. Specifically, when I run ../gradlew java_pluginExecutable -PskipAndroid=true

I end up with a message:

....

/usr/bin/ld: /usr/local/lib/libprotoc.a(plugin.pb.o):(.data.rel.ro+0x0): undefined reference to `descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
collect2: error: ld returned 1 exit status
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-compiler:linkJava_pluginExecutable'.
> A build operation failed.
      Linker failed while linking protoc-gen-grpc-java.

Are they any instructions with the prerequisites in order to build it?  Note that there is a  pre-build image but for the version 2.2.0 so there is way to build it. Finally, I have not seen any information about the compatible versions of the different repositories, for example can I use fabric 2.3.1 with the 2.2 fabric-chaincode-java or I would have a version mismatch? Thus, which versions are compatible with each other?

Thanks,

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Brett T Logan <development.brett@...>
 

Also, the ld failure I believe can be solve by adding the binutils-gold package to the image. You can see the same problem on ARM was solved here for the fabric images:  https://github.com/hyperledger/fabric/commit/33886a4febc58f7d5f1278fe2246daffb31067a7


On Thu, Feb 25, 2021, 03:44 Nikos Karamolegkos <nkaram@...> wrote:

Hello, I would like to build latest version of hypeledger fabric into a raspberry 4 (using java). As I can see in the bash script used by curl here (latest installation) the versions that are used are:

  • fabric 2.3.1
  • fabric-ca 1.4.9
  • fabric-chaincode-java 2.3.1

Unfortunately, there are not pre-built images for all these repositories so I have to build them from source. In order to build fabric 2.3.1 I can make some changes to the Dockerfile (as in master branch i.e add binutils-gold) in order to support raspberry. Respectively, I can do the same for the fabric-ca 1.4.9. The real problem is the fabric-chaincode-java 2.3.0 (there is no 2.3.1 tag in github!!), I have the same problem as here so I try to follow the suggested instructions but I fail. Specifically, when I run ../gradlew java_pluginExecutable -PskipAndroid=true

I end up with a message:

....

/usr/bin/ld: /usr/local/lib/libprotoc.a(plugin.pb.o):(.data.rel.ro+0x0): undefined reference to `descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
collect2: error: ld returned 1 exit status
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-compiler:linkJava_pluginExecutable'.
> A build operation failed.
      Linker failed while linking protoc-gen-grpc-java.

Are they any instructions with the prerequisites in order to build it?  Note that there is a  pre-build image but for the version 2.2.0 so there is way to build it. Finally, I have not seen any information about the compatible versions of the different repositories, for example can I use fabric 2.3.1 with the 2.2 fabric-chaincode-java or I would have a version mismatch? Thus, which versions are compatible with each other?

Thanks,

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

Yes I found the trick with the binutils-gold. I made the changes to the Dockerfiles and I think that is enough. So I can build the fabric and the fabric-ca docker image and the native. The problem remains with the fabric-chaincode-java, I managed to compile the grpc after installing protobuf with the appropriate flags. Therefore, I add it to the maven local repository as suggested. However, the problem with the build of fabric-chaincode-java remains as it was. I don't know maybe I have to set some paths or envs.

Finally, if I make all this work I can write the steps to add it in your wiki.


On 25/2/21 3:40 μ.μ., Brett Logan wrote:
Also, the ld failure I believe can be solve by adding the binutils-gold package to the image. You can see the same problem on ARM was solved here for the fabric images:  https://github.com/hyperledger/fabric/commit/33886a4febc58f7d5f1278fe2246daffb31067a7

On Thu, Feb 25, 2021, 03:44 Nikos Karamolegkos <nkaram@...> wrote:

Hello, I would like to build latest version of hypeledger fabric into a raspberry 4 (using java). As I can see in the bash script used by curl here (latest installation) the versions that are used are:

  • fabric 2.3.1
  • fabric-ca 1.4.9
  • fabric-chaincode-java 2.3.1

Unfortunately, there are not pre-built images for all these repositories so I have to build them from source. In order to build fabric 2.3.1 I can make some changes to the Dockerfile (as in master branch i.e add binutils-gold) in order to support raspberry. Respectively, I can do the same for the fabric-ca 1.4.9. The real problem is the fabric-chaincode-java 2.3.0 (there is no 2.3.1 tag in github!!), I have the same problem as here so I try to follow the suggested instructions but I fail. Specifically, when I run ../gradlew java_pluginExecutable -PskipAndroid=true

I end up with a message:

....

/usr/bin/ld: /usr/local/lib/libprotoc.a(plugin.pb.o):(.data.rel.ro+0x0): undefined reference to `descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
collect2: error: ld returned 1 exit status
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-compiler:linkJava_pluginExecutable'.
> A build operation failed.
      Linker failed while linking protoc-gen-grpc-java.

Are they any instructions with the prerequisites in order to build it?  Note that there is a  pre-build image but for the version 2.2.0 so there is way to build it. Finally, I have not seen any information about the compatible versions of the different repositories, for example can I use fabric 2.3.1 with the 2.2 fabric-chaincode-java or I would have a version mismatch? Thus, which versions are compatible with each other?

Thanks,

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)
-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

Hello, any updates on that?

On 26/2/21 10:33 π.μ., Nikos Karamolegkos wrote:
Yes I found the trick with the binutils-gold. I made the changes to the Dockerfiles and I think that is enough. So I can build the fabric and the fabric-ca docker image and the native. The problem remains with the fabric-chaincode-java, I managed to compile the grpc after installing protobuf with the appropriate flags. Therefore, I add it to the maven local repository as suggested. However, the problem with the build of fabric-chaincode-java remains as it was. I don't know maybe I have to set some paths or envs.

Finally, if I make all this work I can write the steps to add it in your wiki.


On 25/2/21 3:40 μ.μ., Brett Logan wrote:
Also, the ld failure I believe can be solve by adding the binutils-gold package to the image. You can see the same problem on ARM was solved here for the fabric images:  https://github.com/hyperledger/fabric/commit/33886a4febc58f7d5f1278fe2246daffb31067a7

On Thu, Feb 25, 2021, 03:44 Nikos Karamolegkos <nkaram@...> wrote:

Hello, I would like to build latest version of hypeledger fabric into a raspberry 4 (using java). As I can see in the bash script used by curl here (latest installation) the versions that are used are:

  • fabric 2.3.1
  • fabric-ca 1.4.9
  • fabric-chaincode-java 2.3.1

Unfortunately, there are not pre-built images for all these repositories so I have to build them from source. In order to build fabric 2.3.1 I can make some changes to the Dockerfile (as in master branch i.e add binutils-gold) in order to support raspberry. Respectively, I can do the same for the fabric-ca 1.4.9. The real problem is the fabric-chaincode-java 2.3.0 (there is no 2.3.1 tag in github!!), I have the same problem as here so I try to follow the suggested instructions but I fail. Specifically, when I run ../gradlew java_pluginExecutable -PskipAndroid=true

I end up with a message:

....

/usr/bin/ld: /usr/local/lib/libprotoc.a(plugin.pb.o):(.data.rel.ro+0x0): undefined reference to `descriptor_table_google_2fprotobuf_2fdescriptor_2eproto'
collect2: error: ld returned 1 exit status
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':grpc-compiler:linkJava_pluginExecutable'.
> A build operation failed.
      Linker failed while linking protoc-gen-grpc-java.

Are they any instructions with the prerequisites in order to build it?  Note that there is a  pre-build image but for the version 2.2.0 so there is way to build it. Finally, I have not seen any information about the compatible versions of the different repositories, for example can I use fabric 2.3.1 with the 2.2 fabric-chaincode-java or I would have a version mismatch? Thus, which versions are compatible with each other?

Thanks,

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)
-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)
-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

Hello, I have built
1) protobuf 3.12.0 using ../autogen, /configure, make, make check, sudo make install. No problems, the protobuf pack is installed in usr/local/lib
2) export LDFLAGS="-L/usr/local/lib/", export CXXFLAGS="-I/usr/local/include/". Not sure if needed
3) From grpc/compiler I run:
a)
../gradlew java_pluginExecutable -Pprotoc=/usr/local/bin/protoc -PskipAndroid=true OK
b) .
./gradlew test -Pprotoc=/usr/local/bin/protoc -PskipAndroid=true OK
c)
../gradlew publishToMavenLocal -PskipAndroid=true -Pprotoc=/usr/local/bin/protoc OK after changing assertEq "$format" "elf64-little" $LINENO to assertEq "$format" "elf64-littleaarch64" $LINENO.  The output:

 * Skipping the build of Android projects because skipAndroid=true

> Configure project :grpc-compiler
*** Building codegen requires Protobuf version 3.12.0
*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin

> Task :grpc-compiler:checkArtifacts

Checking format of build/artifacts/java_plugin/protoc-gen-grpc-java.exe
Format=elf64-littleaarch64

Checking dependencies of build/artifacts/java_plugin/protoc-gen-grpc-java.exe
Checking for expected dependencies ...
 NEEDED               libpthread.so.0
 NEEDED               libc.so.6
 NEEDED               ld-linux-aarch64.so.1
Checking for unexpected dependencies ...
Dependencies look good.


BUILD SUCCESSFUL in 10s
11 actionable tasks: 7 executed, 4 up-to-date

4) From the fabric-chaincode-java folder I run: ./gradlew clean build install

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fabric-chaincode-protos:generateProto'.
> Could not resolve all files for configuration ':fabric-chaincode-protos:protobufToolsLocator_grpc'.
  > Could not find protoc-gen-grpc-java-linux-aarch_64.exe (io.grpc:protoc-gen-grpc-java:1.23.0).
    Searched in the following locations:
        https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-java/1.23.0/protoc-gen-grpc-java-1.23.0-linux-aarch_64.exe

The same problem which I started


Brett T Logan <development.brett@...>
 

I believe you need to add `mavenLocal()` to https://github.com/hyperledger/fabric-chaincode-java/blob/master/fabric-chaincode-protos/build.gradle#L13 like it is mentioned here: https://github.com/hyperledger/fabric-chaincode-java/blob/master/build.gradle#L23

The protos don't import your local maven repo.

Brett

On Mon, Mar 8, 2021 at 10:48 AM Nikos Karamolegkos <nkaram@...> wrote:
Hello, I have built
1) protobuf 3.12.0 using ../autogen, /configure, make, make check, sudo make install. No problems, the protobuf pack is installed in usr/local/lib
2) export LDFLAGS="-L/usr/local/lib/", export CXXFLAGS="-I/usr/local/include/". Not sure if needed
3) From grpc/compiler I run:
a)
../gradlew java_pluginExecutable -Pprotoc=/usr/local/bin/protoc -PskipAndroid=true OK
b) .
./gradlew test -Pprotoc=/usr/local/bin/protoc -PskipAndroid=true OK
c)
../gradlew publishToMavenLocal -PskipAndroid=true -Pprotoc=/usr/local/bin/protoc OK after changing assertEq "$format" "elf64-little" $LINENO to assertEq "$format" "elf64-littleaarch64" $LINENO.  The output:

 * Skipping the build of Android projects because skipAndroid=true

> Configure project :grpc-compiler
*** Building codegen requires Protobuf version 3.12.0
*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin

> Task :grpc-compiler:checkArtifacts

Checking format of build/artifacts/java_plugin/protoc-gen-grpc-java.exe
Format=elf64-littleaarch64

Checking dependencies of build/artifacts/java_plugin/protoc-gen-grpc-java.exe
Checking for expected dependencies ...
 NEEDED               libpthread.so.0
 NEEDED               libc.so.6
 NEEDED               ld-linux-aarch64.so.1
Checking for unexpected dependencies ...
Dependencies look good.


BUILD SUCCESSFUL in 10s
11 actionable tasks: 7 executed, 4 up-to-date

4) From the fabric-chaincode-java folder I run: ./gradlew clean build install

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fabric-chaincode-protos:generateProto'.
> Could not resolve all files for configuration ':fabric-chaincode-protos:protobufToolsLocator_grpc'.
  > Could not find protoc-gen-grpc-java-linux-aarch_64.exe (io.grpc:protoc-gen-grpc-java:1.23.0).
    Searched in the following locations:
        https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-java/1.23.0/protoc-gen-grpc-java-1.23.0-linux-aarch_64.exe

The same problem which I started


Nikos Karamolegkos
 

I have already tried that. The same error.

--

Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

I changed the grpc version to build.gradle file from 1.23.0 to 1.37.0-SNAPSHOT (latest) which was installed to local mvn repo and I solved the issue.No I have an new one :(

|  Results: FAILURE (229 tests, 227 successes, 1 failures, 1 skipped)  |
------------------------------------------------------------------------

229 tests completed, 1 failed, 1 skipped

> Task :fabric-chaincode-shim:test FAILED
> Task :fabric-chaincode-shim:jacocoTestReport
> Task :fabric-chaincode-shim:jacocoTestCoverageVerification

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fabric-chaincode-shim:test'.
> There were failing tests. See the report at: file:///home/ubuntu/fabric-chaincode-java/fabric-chaincode-shim/build/reports/tests/test/index.html

I checked the previous index.html file and the only failure I can see is:

<td class="failures">
<a href="classes/org.hyperledger.fabric.contract.ContractRouterTest.html">org.hyperledger.fabric.contract.ContractRouterTest</a>

I am looking to it. Any ideas?

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

I can not solve the issue in ./gradlew clean build install:

org.hyperledger.fabric.contract.ContractRouterTest > testStartingContractRouterWithStartingAChaincodeServer FAILED
    java.lang.AssertionError:
    Expected: is <SUCCESS>
         but: was <INTERNAL_SERVER_ERROR>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.junit.Assert.assertThat(Assert.java:956)
        at org.junit.Assert.assertThat(Assert.java:923)
        at org.hyperledger.fabric.contract.ContractRouterTest.testStartingContractRouterWithStartingAChaincodeServer(ContractRouterTest.java:428)

I can not find anything similar. What goes wrong?

-- 
Nikos Karamolegkos
R & D engineer at ICS-FORTH
Telecommunications and Networks Lab (TNL)


Nikos Karamolegkos
 

Brett did you find anything about rapsberries? Is there a list for fabric-chaincode-java with people willing to help?


Nikos Karamolegkos
 

I decided to apply a workaround and set as comments the part of the test creating this problem (Will this be a problem?). I just want to see what is coming next. So, the next problem is that adoptopenjdk/openjdk11:jdk-11.0.4_11-alpine used by the Dockerfile does not exist for arm64. So the error is
> Task :fabric-chaincode-docker:buildImage
Step 1/38 : FROM adoptopenjdk/openjdk11:jdk-11.0.4_11-alpine as builder

> Task :fabric-chaincode-docker:buildImage FAILED
:fabric-chaincode-docker:buildImage (Thread[Execution worker for ':' Thread 2,5,main]) completed. Took 5.526 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fabric-chaincode-docker:buildImage'.
> Could not build image: no matching manifest for linux/arm64/v8 in the manifest list entries

Can I replace it with something else?