Saturday, February 29, 2020

Hyperledger Problems and Fixes


Problem 1: 
Error: got unexpected status: BAD_REQUEST -- error validating channel creation transaction for new channel 'carsales', could not successfully apply update to template configuration: error authorizing update: error validating DeltaSet: policy for [Group]  /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied


Solution: 
Remove old channel, chaincode, and other information
$> sudo rm -rf /var/hyperledger

Then, restart all services so that information in the above folder will be recreated. E.g.,

Restart orderer
$> sudo systemctl start fabric-orderer.service

Restart peer
$> sudo systemctl start fabric-peer0-org1.service



Problem 2:
My peer nodes are behind a firewall. The docker container created for building the chaincode cannot resolve URL.

When running peer chaincode instantiate ..., I got
2020-03-10 13:52:58.465 EST [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-03-10 13:52:58.466 EST [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "Copying from /chaincode/input/src/ to /tmp/tmp.sERrFqHiCD
Gradle build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
  Required by:
      project :
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://hyperledger.jfrog.io/hyperledger/fabric-maven/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://hyperledger.jfrog.io/hyperledger/fabric-maven/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > hyperledger.jfrog.io
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > repo.maven.apache.org: Temporary failure in name resolution
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://repository.mulesoft.org/nexus/content/repositories/public/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://repository.mulesoft.org/nexus/content/repositories/public/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > repository.mulesoft.org
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://repo1.maven.org/maven2/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://repo1.maven.org/maven2/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > repo1.maven.org
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://jcenter.bintray.com/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://jcenter.bintray.com/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > jcenter.bintray.com
   > Could not resolve org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:1.4.5.
      > Could not get resource 'https://jitpack.io/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
         > Could not GET 'https://jitpack.io/org/hyperledger/fabric-chaincode-java/fabric-chaincode-shim/1.4.5/fabric-chaincode-shim-1.4.5.pom'.
            > jitpack.io
> Could not resolve com.owlike:genson:1.5.
  Required by:
      project :
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://hyperledger.jfrog.io/hyperledger/fabric-maven/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://hyperledger.jfrog.io/hyperledger/fabric-maven/com/owlike/genson/1.5/genson-1.5.pom'.
            > hyperledger.jfrog.io: Temporary failure in name resolution
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://repo.maven.apache.org/maven2/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://repo.maven.apache.org/maven2/com/owlike/genson/1.5/genson-1.5.pom'.
            > repo.maven.apache.org
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://repository.mulesoft.org/nexus/content/repositories/public/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://repository.mulesoft.org/nexus/content/repositories/public/com/owlike/genson/1.5/genson-1.5.pom'.
            > repository.mulesoft.org: Temporary failure in name resolution
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://repo1.maven.org/maven2/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://repo1.maven.org/maven2/com/owlike/genson/1.5/genson-1.5.pom'.
            > repo1.maven.org: Temporary failure in name resolution
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://jcenter.bintray.com/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://jcenter.bintray.com/com/owlike/genson/1.5/genson-1.5.pom'.
            > jcenter.bintray.com: Temporary failure in name resolution
   > Could not resolve com.owlike:genson:1.5.
      > Could not get resource 'https://jitpack.io/com/owlike/genson/1.5/genson-1.5.pom'.
         > Could not GET 'https://jitpack.io/com/owlike/genson/1.5/genson-1.5.pom'.
            > jitpack.io: Temporary failure in name resolution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 22s
1 actionable task: 1 executed

"

Solution1 (Manual):
In the terminal of peer0org1, run this to attach to the docker
$> docker exec -it $(docker ps | grep hyperledger/fabric-javaenv | cut -d" " -f1) bash
In the attached docker terminal, run this 
$> sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf
Solution2 (Automated):
$> ssh -n -f USER_NAME@Peer0Org1Address "bash $PEER_ROOT/configDNS.bash 3" &
The content of the configDNS.bash is
```
sleep $SLEEP_TIME
docker exec -t $(docker ps | grep hyperledger/fabric-javaenv | cut -d" " -f1) bash -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf'
```

RISC-v emulator

Changes are based on https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html For Ubuntu/Debian, in addition to sud...